Skip to content

Conversation

stackman27
Copy link
Contributor

@stackman27 stackman27 commented Jul 12, 2020

Whenever a wallet funds a transaction, the fee reason is reported to the user only if the verbose is set to true. I added an extra parameter to CreateTransaction function in wallet.cpp. Then I implemented the fee reason return logic in SendMoney in rpcwallet.cpp, followed by verbose parameter in sendtoaddress and sendmany functions. I also added a fee reason test case in walletbasic.py.

link to the issue: maflcko#22 (comment)

@stackman27 stackman27 changed the title "Send rpc feereason" send* RPCs in the wallet returns the "fee reason" Jul 12, 2020
@glozow
Copy link
Member

glozow commented Jul 12, 2020

Concept ACK!

Copy link
Member

@achow101 achow101 left a comment

Choose a reason for hiding this comment

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

In order for cli to work, you will need to also add the new arguments to src/rpc/client.cpp.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 12, 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.

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

Concept ACK

@stackman27
Copy link
Contributor Author

stackman27 commented Jul 15, 2020

Added a new commit: added new arguments to src/rpc/client.cpp , changed the case to snake_case, generalized the verbose description and added entry object inside verbose if.

Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

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

utACK

Travis is failing on the linter though, most likely whitespace. You can run it yourself with test/lint/lint-all.sh (you might need to install a few packages). I left a bunch of nits that you can include with your changes, and then please rebase and squash.

@fjahr
Copy link
Contributor

fjahr commented Jul 17, 2020

Concept ACK

Please squash the fixup commits.

@stackman27
Copy link
Contributor Author

stackman27 commented Jul 18, 2020

Update: Fixed verbose information and also the log info in wallet_basic.py, also squashed all the nit commits.

@stackman27 stackman27 requested a review from achow101 July 18, 2020 04:10
@fjahr
Copy link
Contributor

fjahr commented Jul 18, 2020

Update: Fixed verbose information and also the log info in wallet_basic.py, also squashed all the nit commits.

Thank you! But I meant to squash the fix-ups into the original commits. Otherwise, it's harder to review because reviewers can not just go through the commits in order but need to jump back and forth to check if what they see in the first commit is not already changed in a later commit. So, for example fee_reason should be already used in the first commit.

@stackman27 stackman27 force-pushed the send_rpc_feereason branch from 26c306c to 05a8182 Compare July 18, 2020 20:01
@stackman27
Copy link
Contributor Author

Squashed nit commits to [test] send rpcs returns fee reason!

@stackman27 stackman27 requested a review from fjahr July 18, 2020 20:02
@stackman27 stackman27 force-pushed the send_rpc_feereason branch from 15f7c1d to 729845d Compare July 20, 2020 03:37
Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

{
{RPCResult::Type::STR_HEX, "txid", "The transaction id for the send. Only 1 transaction is created regardless of\n"
"the number of addresses."},
{RPCResult::Type::BOOL, "fee reason", "The transaction fee reason."}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{RPCResult::Type::BOOL, "fee reason", "The transaction fee reason."}
{RPCResult::Type::STR, "fee reason", "The transaction fee reason."}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

code adjusted based on the feedback. Removed str from [test] and changed rpc result return to str

@stackman27 stackman27 force-pushed the send_rpc_feereason branch 2 times, most recently from 19d86d2 to a3fe42c Compare September 27, 2020 02:03
@maflcko
Copy link
Member

maflcko commented Sep 27, 2020

ACK a3fe42c

@stackman27
Copy link
Contributor Author

@luke-jr @instagibbs @laanwj @fjahr could you please verify whether I've resolved all the problems that you've highlighted? Thank you

Copy link
Member

@instagibbs instagibbs left a comment

Choose a reason for hiding this comment

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

ACK a3fe42c

txid_feeReason_one = self.nodes[2].sendtoaddress(address = address, amount = 10, verbose = True)
assert_equal(txid_feeReason_one["fee_reason"], "Fallback fee")
txid_feeReason_two = self.nodes[2].sendmany(dummy = '', amounts = {address: 10}, verbose = True)
assert_equal(txid_feeReason_two["fee_reason"], "Fallback fee")
Copy link
Member

Choose a reason for hiding this comment

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

maybe add a case where you explicitly pass in verbose = False to cover that case too 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added verbose = False case in test file

@stackman27 stackman27 force-pushed the send_rpc_feereason branch 4 times, most recently from 6d5e3ad to 6118e9d Compare September 28, 2020 21:55
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.

utACK 69cf5d4

@@ -497,8 +514,9 @@ static RPCHelpMan sendtoaddress()

std::vector<CRecipient> recipients;
ParseRecipients(address_amounts, subtractFeeFromAmount, recipients);
bool verbose = request.params[9].isNull() ? false: request.params[9].get_bool();
Copy link
Contributor

Choose a reason for hiding this comment

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

micro-nit: spacing between false:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for some reason git is ignoring my whitespace changes. Any suggestions on how to fix that?

},
{
RPCResult{"if verbose is not set or set to false",
RPCResult::Type::STR_HEX, "txid", "The transaction id for the send. Only 1 transaction is created regardless of\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

micro-nit: double space between Only 1

@instagibbs
Copy link
Member

ACK 69cf5d4

@meshcollider
Copy link
Contributor

@stackman27 if there are a couple of ACKs then it's better not to fix small nits and leave them in case there's a bigger change that needs to be done. Small spacing nits, etc. won't stop a merge 😄

@stackman27
Copy link
Contributor Author

@stackman27 if there are a couple of ACKs then it's better not to fix small nits and leave them in case there's a bigger change that needs to be done. Small spacing nits, etc. won't stop a merge 😄

Okay for sure! Thank you

@maflcko
Copy link
Member

maflcko commented Sep 30, 2020

Mind force pushing the previous reviewed version?

git push your_remote 69cf5d4:send_rpc_feereason -f

?

@stackman27
Copy link
Contributor Author

Mind force pushing the previous reviewed version?

git push your_remote 69cf5d4:send_rpc_feereason -f

?

Yes just pushed!

@maflcko maflcko merged commit 1769828 into bitcoin:master Sep 30, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 30, 2020
69cf5d4 [test] Make sure send rpc returns fee reason (Sishir Giri)
d5863c0 [send] Make send RPCs return fee reason (Sishir Giri)

Pull request description:

  Whenever a wallet funds a transaction, the fee reason is reported to the user only if the verbose is set to true. I added an extra parameter to `CreateTransaction` function in wallet.cpp. Then I implemented the fee reason return logic in `SendMoney`  in rpcwallet.cpp, followed by verbose parameter in `sendtoaddress` and `sendmany` functions. I also added a fee reason test case in walletbasic.py.

  link to the issue: maflcko#22 (comment)

ACKs for top commit:
  instagibbs:
    ACK bitcoin@69cf5d4
  meshcollider:
    utACK 69cf5d4

Tree-SHA512: 2e3af32dcfbd5511ba95f8bc8edca7acfe709a8430ff03e43172e5d0af3dfa4b2f57906978e7f272d878043b9ed8c6004674cf47d7496b005d5f612e9a58aa0e
@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.

10 participants