This change partially reverts #13075 and #14023.
Fixes #14382
-deprecatedrpc
as workaround.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
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.
@Saicere originally reported the issue so they might be able to say whether there’s a benefit to backporting.
As far as I am concerned, it’s not really a big deal whether or not it’s backported to the 0.17 branch as long as it’s in before accounts are removed entirely. If you were using accounts in your application, you are probably running 0.17 with -deprecatedrpc=accounts
anyway while RPC-facing code is updated.
1374@@ -1375,8 +1375,9 @@ static void MaybePushAddress(UniValue & entry, const CTxDestination &dest)
1375 * @param fLong Whether to include the JSON version of the transaction.
1376 * @param ret The UniValue into which the result is stored.
1377 * @param filter The "is mine" filter bool.
1378+ * @param filter_label Optional label string to filter incoming transactions.
1379 */
1380-static void ListTransactions(CWallet* const pwallet, const CWalletTx& wtx, int nMinDepth, bool fLong, UniValue& ret, const isminefilter& filter) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
1381+static void ListTransactions(CWallet* const pwallet, const CWalletTx& wtx, int nMinDepth, bool fLong, UniValue& ret, const isminefilter& filter, const std::string* filter_label) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
I think changing the signature is better because makes it easier to verify in the diff that there aren’t other calls that should be passing along label values. It may also make it more likely that new RPC methods added in the future will support filtering by label.
In general, I think default arguments in c++ can make code difficult to read, and should be used sparingly. If I see nullptr /* filter label */
I can see that the code actually intended to pass null instead of just forgetting to override the default. I also like being able to count from the end when functions take a lot of arguments.
Concept ACK. For completeness, this functionality was hidden behind a deprecation switch in #12953 (based on #11497). The functionality was marked deprecated in #5575.
Apologies - it was my oversight that this functionality got dropped. I’m happy to backport this to V0.17 once this gets merged. I aim to review this week.
96@@ -97,9 +97,10 @@ def run_test(self):
97 txid = self.nodes[1].sendtoaddress(multisig["address"], 0.1)
98 self.nodes[1].generate(1)
99 self.sync_all()
100- assert not [tx for tx in self.nodes[0].listtransactions(dummy="*", count=100, skip=0, include_watchonly=False) if "label" in tx and tx["label"] == "watchonly"]
101- txs = [tx for tx in self.nodes[0].listtransactions(dummy="*", count=100, skip=0, include_watchonly=True) if "label" in tx and tx['label'] == 'watchonly']
102- assert_array_result(txs, {"category": "receive", "amount": Decimal("0.1")}, {"txid": txid})
103+ assert(len(self.nodes[0].listtransactions("watchonly", 100, 0, False)) == 0)
96@@ -97,9 +97,10 @@ def run_test(self):
97 txid = self.nodes[1].sendtoaddress(multisig["address"], 0.1)
98 self.nodes[1].generate(1)
99 self.sync_all()
100- assert not [tx for tx in self.nodes[0].listtransactions(dummy="*", count=100, skip=0, include_watchonly=False) if "label" in tx and tx["label"] == "watchonly"]
101- txs = [tx for tx in self.nodes[0].listtransactions(dummy="*", count=100, skip=0, include_watchonly=True) if "label" in tx and tx['label'] == 'watchonly']
102- assert_array_result(txs, {"category": "receive", "amount": Decimal("0.1")}, {"txid": txid})
103+ assert(len(self.nodes[0].listtransactions("watchonly", 100, 0, False)) == 0)
104+ assert_array_result(self.nodes[0].listtransactions("watchonly", 100, 0, True),
Tested ACK 8fcb76508493cd09d4895e7f3ad11cc5b945056e with a couple of nits. @MarcoFalke - I’ll go ahead and open a PR for backporting. A couple of questions:
1464@@ -1461,9 +1465,11 @@ UniValue listtransactions(const JSONRPCRequest& request)
1465 if (request.fHelp || request.params.size() > 4)
1466 throw std::runtime_error(
1467 "listtransactions (dummy count skip include_watchonly)\n"
dummy
needs to be changed to label
here.
1463@@ -1460,10 +1464,12 @@ UniValue listtransactions(const JSONRPCRequest& request)
1464
1465 if (request.fHelp || request.params.size() > 4)
1466 throw std::runtime_error(
1467- "listtransactions (dummy count skip include_watchonly)\n"
1468+ "listtransactions (label count skip include_watchonly)\n"
(
and before )
?
listreceivedbylabel
than to listtransactions
(as the latter is about all transactions which affect the balance of the wallet - and formerly account) rather than just incoming payments. Would it make sense to add it as an extra option to listreceivedbylabel
(verbose or so), or a separate RPC, instead?
Would it make sense to add it as an extra option to
listreceivedbylabel
(verbose or so), or a separate RPC, instead?
listreceivedbylabel
doesn’t take a label argument or list transactions in any way, it just lists total received coins per label, as per the code.
Would it make sense to add it as an extra option to listreceivedbylabel (verbose or so), or a separate RPC, instead?
It’d be good to improve listreceivedbylabel. But filtering by label in listtransactions
used to work previously and I think was just removed by accident.
You could maybe say that listtransactions
shouldn’t return labels or filter by label at all, since outgoing transactions won’t have labels. But I don’t think it makes sense to keep returning labels and only remove the ability to filter them.
1374@@ -1375,8 +1375,9 @@ static void MaybePushAddress(UniValue & entry, const CTxDestination &dest)
1375 * @param fLong Whether to include the JSON version of the transaction.
1376 * @param ret The UniValue into which the result is stored.
1377 * @param filter The "is mine" filter bool.
filter_ismine
1355@@ -1352,10 +1356,12 @@ UniValue listtransactions(const JSONRPCRequest& request)
1356
1357 if (request.fHelp || request.params.size() > 4)
1358 throw std::runtime_error(
1359- "listtransactions (dummy count skip include_watchonly)\n"
1360+ "listtransactions ( label count skip include_watchonly )\n"
From the documentation below, label is a string, so should be surrounded by quotation marks in the oneline doc.
0 "listtransactions ( \"label\" count skip include_watchonly )\n"
re: #14411 (review)
From the documentation below, label is a string, so should be surrounded by quotation marks in the oneline doc.
Done in rebase.
This change partially reverts #13075 and #14023.
Fixes #14382
Suggested by MeshCollider <dobsonsa68@gmail.com> in
https://github.com/bitcoin/bitcoin/pull/14411#discussion_r232134086
ryanofsky
MarcoFalke
DrahtBot
Saicere
kristapsk
promag
jnewbery
sipa
meshcollider
Labels
Wallet
Milestone
0.18.0