Skip to content

Conversation

Sjors
Copy link
Member

@Sjors Sjors commented Feb 24, 2020

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 #18201.

@DrahtBot
Copy link
Contributor

DrahtBot commented Feb 24, 2020

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

Conflicts

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.

@Sjors
Copy link
Member Author

Sjors commented Mar 27, 2020

Rebased and added a helper function ParseRecipients() so that SendMoney is now a lot shorter.

@instagibbs
Copy link
Member

reACK a6e1761

even shorter nice

@Sjors Sjors requested a review from sipa April 26, 2020 11:59
@Sjors Sjors force-pushed the 2020/02/refactor_sendmany_sendtoaddress branch from a6e1761 to ed2fc36 Compare May 4, 2020 10:51
@Sjors
Copy link
Member Author

Sjors commented May 4, 2020

Rebased after #16426

@Sjors Sjors force-pushed the 2020/02/refactor_sendmany_sendtoaddress branch from ed2fc36 to 443a740 Compare May 4, 2020 18:37
@Sjors
Copy link
Member Author

Sjors commented May 4, 2020

Rebased again after #18699

The only new behavior is some error codes are changed from -4 to -6.
@Sjors Sjors force-pushed the 2020/02/refactor_sendmany_sendtoaddress branch from 443a740 to 08fc6f6 Compare June 19, 2020 09:29
Copy link
Contributor

@fjahr fjahr left a 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;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
subtract_fee = true;
subtract_fee = true;
break;

Copy link
Member

@jonatack jonatack left a 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`:
Copy link
Member

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++) {
Copy link
Member

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

Suggested change
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);
Copy link
Member

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?

Suggested change
return SendMoney(pwallet, coin_control, recipients, mapValue);
return SendMoney(pwallet, coin_control, recipients, std::move(mapValue));

@Sjors
Copy link
Member Author

Sjors commented Jun 23, 2020

Thanks, I'll address the above nits if this PR needs touching.

Copy link
Contributor

@meshcollider meshcollider left a 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

@meshcollider meshcollider merged commit 4db44ac into bitcoin:master Jul 12, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 12, 2020
… 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
domob1812 added a commit to domob1812/namecoin-core that referenced this pull request Jul 13, 2020
Update the Namecoin-specific wallet code (e.g. sending transactions
with name inputs, sendtomany) for the upstream refactor in
bitcoin/bitcoin#18202.
@Sjors Sjors deleted the 2020/02/refactor_sendmany_sendtoaddress branch July 14, 2020 15:36
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Aug 31, 2021
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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
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.