-
Notifications
You must be signed in to change notification settings - Fork 38.8k
wallet: Do not treat default constructed types as None-type #20410
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
Conversation
fa0bce7 to
fa4120f
Compare
|
Would this change not disable using The RPCExamples for |
|
You can pass JSON-None if you'd like to use positional args |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, 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. |
|
Oh, it looks like bitcoin-cli can not properly pass JSON-None? Sounds like a bug |
You can just use |
|
An example? I haven't managed to make it work via the CLI. |
|
It doesn't work for strings because cli will convert |
Thanks, done. |
fa4120f to
fa31347
Compare
|
Building and testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and the code and CLI examples look good. Perhaps keep the placeholder test coverage but with conf_target=None.
Yes, in that case you cannot pass any other kind of JSON type except strings. It's kind of annoying, but there is no non-ambigious way of doing so because every argument is a valid string. Special-casing the string "null" in bitcoin-cli would be awful. At least named arguments can achieve this. |
fa31347 to
fa7df9b
Compare
|
Tested ACK fa7df9be0d1034d2bbbde19a45b1e706368b4c1b |
|
A separate issue I found while testing this: in the as-yet unreleased |
|
Do you have steps to reproduce? This works fine locally: |
|
Oh good, thanks, sorry for noise. One of my "null"s was spelled "nul". I think the third week of full lockdown and lack of my usual balance from outdoor sport are getting to me... |
|
This |
fa7df9b to
fa69c2c
Compare
|
Good catch. Didn't realize the example was wrong, too. Now fixed. |
|
ACK fa69c2c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK fa69c2c modulo unset
I don't think treating ""==None is particularly ambiguous, but null is not too bad.
| * if a fee_rate is present, "" is allowed here as a no-op positional placeholder | ||
| * @param[in] fee_rate UniValue real; fee rate in sat/vB; | ||
| * if a fee_rate is present, both conf_target and estimate_mode must either be null, or no-op | ||
| * if present, both conf_target and estimate_mode must either be null, or "unset" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
estimate_mode can't be null for send and sendtoaddress. It will throw Cannot specify both estimate_mode and fee_rate. It does if you add it to client.cpp, but then unset and "unset" throw error: Error parsing JSON: unset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that comment is a bit ambiguous; IIRC null is only for conf_target and unset only for estimate_mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
estimate_mode can't be null for send and sendtoaddress. It will throw Cannot specify both estimate_mode and fee_rate.
This comment is in the server code, where it can be null, not in the client code. You can trivially check with this diff, so I think the comment is correct:
diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py
index ac4a6e4948..17c013d26a 100755
--- a/test/functional/wallet_basic.py
+++ b/test/functional/wallet_basic.py
@@ -235,7 +235,7 @@ class WalletTest(BitcoinTestFramework):
fee_rate_btc_kvb = fee_rate_sat_vb * 1e3 / 1e8
explicit_fee_rate_btc_kvb = Decimal(fee_rate_btc_kvb) / 1000
- txid = self.nodes[2].sendmany(amounts={address: 10}, fee_rate=fee_rate_sat_vb)
+ txid = self.nodes[2].sendmany(amounts={address: 10}, fee_rate=fee_rate_sat_vb, estimate_mode=None)
self.nodes[2].generate(1)
self.sync_all(self.nodes[0:3])
balance = self.nodes[2].getbalance()
@@ -406,7 +406,7 @@ class WalletTest(BitcoinTestFramework):
fee_rate_sat_vb = 2
fee_rate_btc_kvb = fee_rate_sat_vb * 1e3 / 1e8
- txid = self.nodes[2].sendtoaddress(address=address, amount=amount, fee_rate=fee_rate_sat_vb)
+ txid = self.nodes[2].sendtoaddress(address=address, amount=amount, fee_rate=fee_rate_sat_vb, estimate_mode=None)
tx_size = self.get_vsize(self.nodes[2].gettransaction(txid)['hex'])
self.nodes[0].generate(1)
self.sync_all(self.nodes[0:3])
Fair enough, but it wasn't documented in the RPCArg help. I think keeping the already existing |
|
ACK fa69c2c |
|
Backported in #20485 |
…es as None-type fa69c2c wallet: Do not treat default constructed types as None-type (MarcoFalke) fac4e13 refactor: Change pointer to reference because it can not be null (MarcoFalke) Pull request description: Github-Pull: #20410 Rebased-From: fac4e13 Github-Pull: #20410 Rebased-From: fa69c2c Top commit has no ACKs. Tree-SHA512: 05c3fe29677710b57dcc482fd529b0ab79475519f60f9cfde19f956c4e2212d09b042af458ec4f1272c581360ce841b735dca4df144e0798b3ccf16547de9cd0
Equating
0==Noneand""==Noneis confusing, unneeded and undocumented