Skip to content

Commit

Permalink
rpc: reverse the order of listtransactions to align with lbrycrd
Browse files Browse the repository at this point in the history
  • Loading branch information
roylee17 committed Aug 8, 2022
1 parent 610ec20 commit 46f4df5
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -2093,13 +2093,9 @@ func (w *Wallet) ListTransactions(from, count int) ([]btcjson.ListTransactionsRe
// include the next count transactions.
skipped := 0
n := 0

rangeFn := func(details []wtxmgr.TxDetails) (bool, error) {
// Iterate over transactions at this height in reverse order.
// This does nothing for unmined transactions, which are
// unsorted, but it will process mined transactions in the
// reverse order they were marked mined.
for i := len(details) - 1; i >= 0; i-- {

for _, detail := range details {
if from > skipped {
skipped++
continue
Expand All @@ -2110,7 +2106,7 @@ func (w *Wallet) ListTransactions(from, count int) ([]btcjson.ListTransactionsRe
return true, nil
}

jsonResults := listTransactions(tx, &details[i],
jsonResults := listTransactions(tx, &detail,
w.Manager, syncBlock.Height, w.chainParams)
txList = append(txList, jsonResults...)

Expand All @@ -2124,8 +2120,10 @@ func (w *Wallet) ListTransactions(from, count int) ([]btcjson.ListTransactionsRe

// Return newer results first by starting at mempool height and working
// down to the genesis block.
return w.TxStore.RangeTransactions(txmgrNs, -1, 0, rangeFn)
// return w.TxStore.RangeTransactions(txmgrNs, -1, 0, rangeFn)
return w.TxStore.RangeTransactions(txmgrNs, 0, -1, rangeFn)
})

return txList, err
}

Expand Down

0 comments on commit 46f4df5

Please sign in to comment.