Skip to content

Conversation

hosseinzoda
Copy link

@hosseinzoda hosseinzoda commented Dec 8, 2018

Added fifth param to listtransactions named options, options may be an object containing paginatebypointer (boolean default: false) and nextpagepointer (string default: OMITTED).

With paginatebypointer output will have the following changes.

  1. Return transactions is ordered by most recent transactions. Though the default does reverse the order after transactions are fetched and clipped.
  2. skip argument has no effect. Instead nextpagepointer will be used for pagination.
  3. Return value is an object containing, records (array of txs) and nextpagepointer (string)

@hosseinzoda hosseinzoda force-pushed the master branch 3 times, most recently from 249c196 to 0115b7a Compare December 9, 2018 12:06
@promag
Copy link
Contributor

promag commented Dec 9, 2018

Is there a strong reason to not improve existing listtransactions without being a breaking change?

@hosseinzoda
Copy link
Author

@promag listtransactions has been used in many tests. I don't know what will happen. If change number one gets added to it.

  1. Return transactions is ordered by most recent transactions. Though the original rpc does reverse the order after transactions are fetched and clipped.

There's an odd reverse call at listtransactions which is not in this one.
https://github.com/bitcoin/bitcoin/blob/fc1710fbf3ce840f0b647913be8b821089b00f5e/src/wallet/rpcwallet.cpp#L1494

Other than that adding nextpagepointer will break compatibility with listtransactions params. Only if one accepts it as interger and string and keeps the behaviour the same.

@jonasschnelli
Copy link
Contributor

I general I like the idea of a pointer (seems more reliable) and the sort.
Not sure about cloning the call.

@kristapsk
Copy link
Contributor

@promag listtransactions has been used in many tests. I don't know what will happen. If change number one gets added to it.

I would not worry about tests, you should anyway run the functional tests yourself if you change something in RPC. Sort order could be added as an additional optional boolean parameter IMO. As well as other changes.

@hosseinzoda
Copy link
Author

Who thinks this line should get removed from listtransactions?

https://github.com/bitcoin/bitcoin/blob/fc1710fbf3ce840f0b647913be8b821089b00f5e/src/wallet/rpcwallet.cpp#L1494

@sipa
Copy link
Member

sipa commented Dec 9, 2018

@hosseinamin Well we can't remove that line; there are likely end users who rely on its behavior, even if it is suboptimal. We can make it optional by adding an extra flag, though.

@kristapsk
Copy link
Contributor

kristapsk commented Dec 9, 2018

Breaking userspace is bad, so changing default behaviour of any RPC should be avoided.

@hosseinzoda
Copy link
Author

That's why i did cloned the rpc call. This is how new functionality can come in without messing with userspace.

@jonasschnelli
Copy link
Contributor

That's why i did cloned the rpc call. This is how new functionality can come in without messing with userspace.

Cloning is one way, backward compatible parameterising would be another (see how the account system was removed).

@hosseinzoda
Copy link
Author

hosseinzoda commented Dec 9, 2018

Okay. How's this?

  1. skip param can morph to nextpagepointer when string is given.
  2. adding nonlegacy parameter at the end to avoid messing with userspace.

@hosseinzoda
Copy link
Author

I think skip accepts string as input. It will convert to integer. A bit more work is needed to detect between the two.

@hosseinzoda
Copy link
Author

It's also seems like changes on ListTransactions2 is trivial. ListTransactions with no change works.

@hosseinzoda
Copy link
Author

@jonasschnelli Removed listransactions2, And did parametrize it.
I will try later to write some tests for it.

@hosseinzoda hosseinzoda force-pushed the master branch 4 times, most recently from 6dd543e to d788aae Compare December 10, 2018 13:31
} else if (i == 1) {
try {
nextVOut = std::stoul(s);
} catch (std::invalid_argument &e) {
Copy link
Contributor

@practicalswift practicalswift Dec 10, 2018

Choose a reason for hiding this comment

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

Drop &e? Applies to the three cases below as well :-)

@kristapsk
Copy link
Contributor

I'm not sure a single parameter that changes multiple things is a right way to go. Wouln't be better to be able to specify sorting order and paging behaviour independently? Besides I don't like "old behaviour vs new behaviour" boolean also because in future there could be a different one "new new behaviour".

@@ -57,7 +57,9 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "waitfornewblock", 0, "timeout" },
{ "listtransactions", 1, "count" },
{ "listtransactions", 2, "skip" },
{ "listtransactions", 2, "nextpagepointer" },
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Isn't this typically called an index rather than a pointer?

{ "listtransactions", 3, "include_watchonly" },
{ "listtransactions", 4, "newversion" },
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: The newversion won't be new forever :-) Can you come up with a time independent name?

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 11, 2018

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #16341 (WIP: Introduce ScriptPubKeyMan interface and use it for key and script management (aka wallet boxes) by achow101)
  • #16240 (JSONRPCRequest-aware RPCHelpMan by kallewoof)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@hosseinzoda
Copy link
Author

Okay. I agree. Want to change newversion to flags. Though don't have time to do it now.

@hosseinzoda hosseinzoda changed the title nextpagepointer & list ordering options for listtransactions nextpagepointer flag for listtransactions Jan 22, 2019
@laanwj
Copy link
Member

laanwj commented Jan 22, 2019

Linter error from travis:

This diff appears to have added new lines with trailing whitespace.
The following changes were suspected:
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
@@ -1455,2 +1492,113 @@ UniValue listtransactions(const JSONRPCRequest& request)
+
+
+
+
+
^---- failure generated from test/lint/lint-whitespace.sh

@hosseinzoda
Copy link
Author

This PR needs review.

@hosseinzoda hosseinzoda changed the title nextpagepointer flag for listtransactions rpc listtransactions new argument options (paginatebypointer impl) May 22, 2019
@hosseinzoda
Copy link
Author

Hey guys. This commit is ready for merge.

Added fifth param to `listtransactions` named `options`, `options` may be an object containing `paginatebypointer` (boolean default: false) and `nextpagepointer` (string default: OMITTED).

With `paginatebypointer` output will have the following changes.

1. Return transactions is ordered by most recent transactions. Though the default does reverse the order after transactions are fetched and clipped.
2. `skip` argument has no effect. Instead `nextpagepointer` will be used for pagination.
3. Return value is an object containing, records (array of txs) and nextpagepointer (string)
@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 9, 2019

Needs rebase

@adamjonas
Copy link
Member

Checking in on this. It's been a while since there was a rebase and there doesn't appear to be strong conviction from the reviewers on the concept/approach.

@hosseinzoda
Copy link
Author

hosseinzoda commented May 19, 2020

I wasted my time on this pull-request. No need for the merge anymore. Lets dump it in garbage.

@kristapsk
Copy link
Contributor

I still think this would have been a good functionality conceptually.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.