Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wallet-rpc: switch the order of transactions returned to most recent #475

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/wallet/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ class RPC extends RPCBase {
const valid = new Validator(args);
let name = valid.str(0);
const count = valid.u32(1, 10);
const from = valid.u32(2, 0);
const skip = valid.u32(2, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also change the argument name in the help message up on line 1228

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, adding this in

const watchOnly = valid.bool(3, false);

if (wallet.watchOnly !== watchOnly)
Expand All @@ -1248,11 +1248,12 @@ class RPC extends RPCBase {

common.sortTX(txs);

const end = from + count;
const to = Math.min(end, txs.length);
const start = txs.length - skip - 1;
const end = start - count;
const to = Math.max(end, -1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer a 0 here and a >= below

const out = [];

for (let i = from; i < to; i++) {
for (let i = start; i > to; i--) {
const wtx = txs[i];
const json = await this._toListTX(wtx);
out.push(json);
Expand Down