-
Notifications
You must be signed in to change notification settings - Fork 37.7k
refactor: consolidate sendmany and sendtoaddress code #18202
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
refactor: consolidate sendmany and sendtoaddress code #18202
Conversation
7061c2c
to
44ec825
Compare
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. |
Rebased and added a helper function |
c23298f
to
a6e1761
Compare
reACK a6e1761 even shorter nice |
a6e1761
to
ed2fc36
Compare
Rebased after #16426 |
ed2fc36
to
443a740
Compare
Rebased again after #18699 |
The only new behavior is some error codes are changed from -4 to -6.
443a740
to
08fc6f6
Compare
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.
Code review ACK 08fc6f6
Nice refactor.
for (unsigned int idx = 0; idx < subtract_fee_outputs.size(); idx++) { | ||
const UniValue& addr = subtract_fee_outputs[idx]; | ||
if (addr.get_str() == address) { | ||
subtract_fee = true; |
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.
subtract_fee = true; | |
subtract_fee = true; | |
break; |
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.
ACK 08fc6f6
Some suggestions below. Feel free to ignore the style nits.
--------------------- | ||
|
||
- To make RPC `sendtoaddress` more consistent with `sendmany` the following error | ||
`sendtoaddress` codes were changed from `-4` to `-6`: |
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.
08fc6f6 suggestion
-- To make RPC `sendtoaddress` more consistent with `sendmany` the following error
- `sendtoaddress` codes were changed from `-4` to `-6`:
+- To make RPC `sendtoaddress` more consistent with `sendmany`, the following
+ `sendtoaddress` error codes are changed from `-4` to `-6`:
if (nValue > curBalance) | ||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds"); | ||
bool subtract_fee = false; | ||
for (unsigned int idx = 0; idx < subtract_fee_outputs.size(); idx++) { |
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.
while retouching this code, could update to the current convention
for (unsigned int idx = 0; idx < subtract_fee_outputs.size(); idx++) { | |
for (unsigned int idx = 0; idx < subtract_fee_outputs.size(); ++idx) { |
std::vector<CRecipient> recipients; | ||
ParseRecipients(address_amounts, subtractFeeFromAmount, recipients); | ||
|
||
return SendMoney(pwallet, coin_control, recipients, mapValue); |
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.
can use move
for mapValue here as well?
return SendMoney(pwallet, coin_control, recipients, mapValue); | |
return SendMoney(pwallet, coin_control, recipients, std::move(mapValue)); |
Thanks, I'll address the above nits if this PR needs touching. |
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.
Code review & functional test run ACK 08fc6f6
Nits can be left for followup
… code 08fc6f6 [rpc] refactor: consolidate sendmany and sendtoaddress code (Sjors Provoost) Pull request description: I consolidated code between these two RPC calls, since `sendtoaddress` is essentially `sendmany` with 1 destination. Unless I overlooked something, the only behaviour change is that some `sendtoaddress` error codes changed from `-4` to `-6`. The release note mentions this. Salvaged from bitcoin#18201. ACKs for top commit: fjahr: Code review ACK 08fc6f6 jonatack: ACK 08fc6f6 meshcollider: Code review & functional test run ACK 08fc6f6 Tree-SHA512: 7b66c52fa0444a4d02fc3f81d9c2a386794d447616026a30111eda35fb46510475eea6506a9ceda00bb4e0230ebb758da5d236b3ac05c954c044fa68a1e3e909
Update the Namecoin-specific wallet code (e.g. sending transactions with name inputs, sendtomany) for the upstream refactor in bitcoin/bitcoin#18202.
Summary: The only new behavior is some error codes are changed from -4 to -6. This is a backport of [[bitcoin/bitcoin#18202 | core#18202]] Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9993
I consolidated code between these two RPC calls, since
sendtoaddress
is essentiallysendmany
with 1 destination.Unless I overlooked something, the only behaviour change is that some
sendtoaddress
error codes changed from-4
to-6
. The release note mentions this.Salvaged from #18201.