Wallet/RPC: Add listsincetx method with a stateless (server-side) long polling option#13262
Wallet/RPC: Add listsincetx method with a stateless (server-side) long polling option#13262jonasschnelli wants to merge 4 commits intobitcoin:masterfrom
Conversation
89661ee to
ecb2e20
Compare
promag
left a comment
There was a problem hiding this comment.
Concept ACK.
I'm not aware of the wtxOrdered details, but is the key always increasing? Also, it's a multimap so the same key can have multiple transactions, isn't that a problem?
Some comments though.
src/wallet/wallet.cpp
Outdated
src/wallet/wallet.cpp
Outdated
There was a problem hiding this comment.
Can this be nullptr? Could assert(pwtx) instead?
src/wallet/wallet.h
Outdated
There was a problem hiding this comment.
Could keep wtxOrdered back iterator instead:
TxItems::const_iterator m_latest_wtx = wtxOrdered.rbegin();
Then above could be:
if (m_latest_wtxid != wtxOrdered.rbegin()) {
...
}There was a problem hiding this comment.
I prefer to keep a non references object in this case.
src/wallet/wallet.cpp
Outdated
There was a problem hiding this comment.
... = wtxOrdered.rbegin()->second.first;
src/wallet/wallet.cpp
Outdated
There was a problem hiding this comment.
Missing notify on m_cond_txadd?
src/wallet/rpcwallet.cpp
Outdated
There was a problem hiding this comment.
txid is required, should be out of ( ).
src/wallet/rpcwallet.cpp
Outdated
There was a problem hiding this comment.
Should be
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id");which is the error used in other calls.
src/wallet/rpcwallet.cpp
Outdated
There was a problem hiding this comment.
clang-format would fix a few other minor things as well
src/wallet/rpcwallet.cpp
Outdated
There was a problem hiding this comment.
Fixed the above; polltime is correct
src/wallet/rpcwallet.cpp
Outdated
ecb2e20 to
d68f662
Compare
d68f662 to
139ade1
Compare
|
promag
left a comment
There was a problem hiding this comment.
Will play around, just some nits that could be fixed meanwhile.
src/wallet/rpcwallet.cpp
Outdated
src/rpc/client.cpp
Outdated
contrib/push/example_walletnotify.py
Outdated
51ea1fd to
2f505ac
Compare
|
You could note that this is not the same as |
Good point. |
contrib/push/example_walletnotify.py
Outdated
contrib/push/example_walletnotify.py
Outdated
contrib/push/example_walletnotify.py
Outdated
src/wallet/rpcwallet.cpp
Outdated
There was a problem hiding this comment.
I don't understand that comment.
There was a problem hiding this comment.
s/then/than: If greater than zero, wait with ...
src/wallet/rpcwallet.cpp
Outdated
There was a problem hiding this comment.
IMO cs_main should always be locked before cs_wallet, especially with the usage of ListTransactions() and its subclass.
src/wallet/rpcwallet.cpp
Outdated
There was a problem hiding this comment.
Could have a limit argument? Otherwise it would dump the whole wallet?
There was a problem hiding this comment.
I thought of it,... but would like to keep it simple for a first implementation (limit could follow next)
src/wallet/rpcwallet.cpp
Outdated
There was a problem hiding this comment.
Should not use request.params[1].isNum() otherwise the caller can pass a string (for example) and it won't raise an error. I suggest to change to:
if (transactions.empty() && !request.params[1].isNull() && request.params[1].get_int() > 0)2f505ac to
3f1b0a1
Compare
3f1b0a1 to
2dadbc8
Compare
| Needs rebase |
| There hasn't been much activity lately and the patch still needs rebase, so I am closing this for now. Please let me know when you want to continue working on this, so the pull request can be re-opened. |
This adds a new wallet RPC call
listsincetxthat allows to list follow-up transactions (in order /wtxOrdered) from a specified transaction.If the latest transaction was used as base-point for finding follow-up transactions and the long-polling timeout if set greater then zero, it will wait until new transactions has been found or the timeout has been expired (http push channel). Used together with a https proxy, one can build a very robust wallet transaction push channel (that can bypass NATs, proxys, etc.)
This does allow to build a wallet-notify push channel without keeping client-states on the server side.
It does also allow clients to effectively sync the transaction list.
A client can simply loop over
listsincetx(<newest_known_txid>, 30/*timeout*/)and will immediately get new txns once they arrive.Mitigates #13237
Related #7949
This (or a similar) approach was once discussed during an IRC meeting (can't find it anymore in the logs).