Skip to content

[RPC] Split signrawtransaction into wallet and non-wallet RPC command#10579

Merged
sipa merged 3 commits into
bitcoin:masterfrom
achow101:split-signraw
Feb 20, 2018
Merged

[RPC] Split signrawtransaction into wallet and non-wallet RPC command#10579
sipa merged 3 commits into
bitcoin:masterfrom
achow101:split-signraw

Conversation

@achow101
Copy link
Copy Markdown
Member

@achow101 achow101 commented Jun 12, 2017

This PR is part of #10570. It also builds on top of #10571.

This PR splits signrawtransaction into two commands, signrawtransactionwithkey and signrawtransactionwithwallet. signrawtransactionwithkey requires private keys to be passed in and does not use the wallet for any signing. signrawtransactionwithwallet uses the wallet to sign a raw transaction and does not have any parameters to take private keys.

The signrawtransaction RPC has been marked as deprecated and will call the appropriate RPC command based upon the parameters given. A test was added to check this behavior is still consistent with the original behavior.

All tests that used signrawtransaction have been updated to use one of the two new RPCs. Most uses were changed to signrawtransactionwithwallet. These were changed via a scripted diff.

@sipa
Copy link
Copy Markdown
Member

sipa commented Jun 13, 2017

Incorrect scripted diff.

@achow101 achow101 force-pushed the split-signraw branch 2 times, most recently from 0b7c0c2 to 1283d87 Compare June 13, 2017 02:21
@jonasschnelli
Copy link
Copy Markdown
Contributor

I'm not entirely sure if this is a good long term strategy.
signrawtransactionwithwallet seems okay(ish) but I don't see a reason to pass around a private key (though RPC, TCP into the same process that runs the p2p/validation/node).

Where are the differences betweenbitcoin-tx's sign command and the here proposed signrawtransactionwithkey?
Wouldn't it make more sense to focus on bitcoin-tx for (offline) rawtx signing?

@achow101
Copy link
Copy Markdown
Member Author

@jonasschnelli signrawtransactionwithkey will lookup the UTXOs in order to sign whereas bitcoin-tx's `sign' command requires you to supply them. This is much easier to use.

@achow101 achow101 force-pushed the split-signraw branch 2 times, most recently from a1d577b to a15695a Compare June 19, 2017 18:16
@laanwj laanwj added this to the 0.15.0 milestone Jul 6, 2017
@achow101 achow101 force-pushed the split-signraw branch 3 times, most recently from 7725585 to 05c3cf5 Compare July 8, 2017 00:36
@laanwj
Copy link
Copy Markdown
Member

laanwj commented Jul 18, 2017

This has missed the 0.15 feature freeze, moving to 0.16.

@laanwj laanwj modified the milestones: 0.16.0, 0.15.0 Jul 18, 2017
@jnewbery
Copy link
Copy Markdown
Contributor

needs rebase

@achow101
Copy link
Copy Markdown
Member Author

rebased

Copy link
Copy Markdown
Contributor

@jnewbery jnewbery left a comment

Choose a reason for hiding this comment

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

Some review comments inline. It's a shame that this doesn't remove the server->wallet dependency, but it's a good first step in that direction.

I felt bad about asking you to rebase and then not actually reviewing before it got stale again, so I rebased it myself here: https://github.com/jnewbery/bitcoin/tree/pr10579 . Feel free to grab that branch if it helps.

Comment thread src/rpc/client.cpp Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

supernit: 1 usually comes before 2 :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@jnewbery for me it's more "Sort please" :trollface:

Comment thread src/Makefile.am Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be in the first commit (6fded798a77e8a754fa9455afd3328aee0842274)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

... and sorted.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

following lines aren't sorted either, not sure if it matters to clean this up

Comment thread test/functional/txn_clone.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you make this change before the scripted diff commit (to not break git bisect). You could change the args to be named args while you're doing that.

Comment thread test/functional/signrawtransactions.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no need for assert_equal(thing, True). Just use assert thing

Comment thread test/functional/signrawtransactions.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just use assert not thing

Comment thread src/rpc/rawtransaction.cpp Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggestion: add a comment here to say that signrawtransactionwithwallet doesn't take a privkeys parameter.

Comment thread src/rpc/rawtransaction.cpp Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps hide this RPC behind a deprecated command line argument (similar to #11031)

Comment thread src/rpc/rawtransaction.cpp Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: I know these are moves, but there's so few of them that you might as well add braces to the ifs.

Comment thread src/rpc/rawtransaction.cpp Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: use snake_case for variables in new functions.

Comment thread src/rpc/rawtransaction.cpp Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: new function parameters should be snake_case

Comment thread test/functional/signrawtransactions.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove key asserts since below you assert the value, which fail in case the key is not defined? cc @jnewbery.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right. The line below should raise KeyError in that case.

Comment thread src/rpc/rawtransaction.h Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing comment.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Huh?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

#endif // BITCOIN_RPC_RAWTRANSACTION_H

Comment thread src/rpc/rawtransaction.h Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unknown types below: CMutableTransaction and UniValue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Still not addressed in f5a3e0d4a3b4b359714b7d380d7784b7ca0524c0

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Still missing?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hmm. It must have gotten lost somewhere.

Comment thread src/wallet/rpcwallet.cpp Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sort.

Comment thread src/rpc/rawtransaction.cpp Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove newline.

Comment thread src/rpc/rawtransaction.cpp Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

++idx.

Comment thread src/rpc/rawtransaction.cpp Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Braces.

Comment thread src/rpc/rawtransaction.cpp Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Take the opportunity to kill fGood:

if (!vchSecret.SetString(k.get_str())) {

Comment thread src/rpc/rawtransaction.cpp Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

else {

Comment thread src/rpc/rawtransaction.cpp Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ops, align this and above lines? 😞

@jnewbery
Copy link
Copy Markdown
Contributor

reACK 3808129837f12482fcadd030d4e720ff2498b452. Only changes are:

  • renaming suggested by instagibbs
  • removing stray space character
  • moving LOCK2() down a few lines in signrawtransactionwithwallet()

@instagibbs
Copy link
Copy Markdown
Member

instagibbs commented Feb 16, 2018 via email

Splits signrwatransaction into a wallet version (signrawtransactionwithwallet) and
non-wallet version (signrawtransactionwithkey). signrawtransaction is marked as DEPRECATED
and will call the right signrawtransaction* command as per the parameters in order to
maintain compatibility.

Updated signrawtransactions test to use new RPCs
…let in tests

-BEGIN VERIFY SCRIPT-
sed -i 's/\<signrawtransaction\>/signrawtransactionwithwallet/g' test/functional/*.py
sed -i 's/\<signrawtransaction\>/signrawtransactionwithwallet/g' test/functional/test_framework/*.py
-END VERIFY SCRIPT-
Add a brief test for signrawtransaction to ensure that compatibility is maintained.
@achow101
Copy link
Copy Markdown
Member Author

Rebased again.

@instagibbs
Copy link
Copy Markdown
Member

re-utACK d602348

Copy link
Copy Markdown
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

utACK d602348.

Comment thread src/rpc/rawtransaction.h
#define BITCOIN_RPC_RAWTRANSACTION_H

class CBasicKeyStore;
class CMutableTransaction;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit, gives compiler warning:

In file included from rpc/rawtransaction.cpp:20:
./rpc/rawtransaction.h:9:1: warning: class 'CMutableTransaction' was previously declared as a struct [-Wmismatched-tags]
class CMutableTransaction;
^
./primitives/transaction.h:362:8: note: previous use is here
struct CMutableTransaction
       ^
./rpc/rawtransaction.h:9:1: note: did you mean struct here?
class CMutableTransaction;
^~~~~
struct

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't see this on my machine..

@jnewbery
Copy link
Copy Markdown
Contributor

reACK d602348

@sipa
Copy link
Copy Markdown
Member

sipa commented Feb 20, 2018

utACK d602348

@sipa sipa merged commit d602348 into bitcoin:master Feb 20, 2018
sipa added a commit that referenced this pull request Feb 20, 2018
…et RPC command

d602348 Add test for signrawtransaction (Andrew Chow)
eefff65 scripted-diff: change signrawtransaction to signrawtransactionwithwallet in tests (Andrew Chow)
1e79c05 Split signrawtransaction into wallet and non-wallet (Andrew Chow)

Pull request description:

  This PR is part of #10570. It also builds on top of #10571.

  This PR splits `signrawtransaction` into two commands, `signrawtransactionwithkey` and `signrawtransactionwithwallet`. `signrawtransactionwithkey` requires private keys to be passed in and does not use the wallet for any signing. `signrawtransactionwithwallet` uses the wallet to sign a raw transaction and does not have any parameters to take private keys.

  The `signrawtransaction` RPC has been marked as deprecated and will call the appropriate RPC command based upon the parameters given. A test was added to check this behavior is still consistent with the original behavior.

  All tests that used `signrawtransaction` have been updated to use one of the two new RPCs. Most uses were changed to `signrawtransactionwithwallet`. These were changed via a scripted diff.

Tree-SHA512: d0adf5b4cd7077639c504ec07bee262a3b94658d34db0a5c86a263b6393f7aa62f45129eafe29a7c861aa58440dd19348ee0c8b685e8a62d6f4adae8ec8f8cb3
maflcko pushed a commit that referenced this pull request Feb 21, 2018
eacc5b2 Declare CMutableTransaction a struct in rawtransaction.h (Ben Woosley)

Pull request description:

  Because it's a struct.

  Fix for #10579 - this was called out in code review. #10579 (comment)

Tree-SHA512: 10758a667218481de6f50b5ed874e92eb350c621f7a6355fba7da6ab42b09e1764f827e89491c8663e554fcfd23f124b299f968237c6ad1ff7819e211bd7e521
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Dec 12, 2020
…on-wallet RPC command

d602348 Add test for signrawtransaction (Andrew Chow)
eefff65 scripted-diff: change signrawtransaction to signrawtransactionwithwallet in tests (Andrew Chow)
1e79c05 Split signrawtransaction into wallet and non-wallet (Andrew Chow)

Pull request description:

  This PR is part of bitcoin#10570. It also builds on top of bitcoin#10571.

  This PR splits `signrawtransaction` into two commands, `signrawtransactionwithkey` and `signrawtransactionwithwallet`. `signrawtransactionwithkey` requires private keys to be passed in and does not use the wallet for any signing. `signrawtransactionwithwallet` uses the wallet to sign a raw transaction and does not have any parameters to take private keys.

  The `signrawtransaction` RPC has been marked as deprecated and will call the appropriate RPC command based upon the parameters given. A test was added to check this behavior is still consistent with the original behavior.

  All tests that used `signrawtransaction` have been updated to use one of the two new RPCs. Most uses were changed to `signrawtransactionwithwallet`. These were changed via a scripted diff.

Tree-SHA512: d0adf5b4cd7077639c504ec07bee262a3b94658d34db0a5c86a263b6393f7aa62f45129eafe29a7c861aa58440dd19348ee0c8b685e8a62d6f4adae8ec8f8cb3
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this pull request Dec 12, 2020
Signed-off-by: pasta <pasta@dashboost.org>
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Dec 12, 2020
…action.h

eacc5b2 Declare CMutableTransaction a struct in rawtransaction.h (Ben Woosley)

Pull request description:

  Because it's a struct.

  Fix for bitcoin#10579 - this was called out in code review. bitcoin#10579 (comment)

Tree-SHA512: 10758a667218481de6f50b5ed874e92eb350c621f7a6355fba7da6ab42b09e1764f827e89491c8663e554fcfd23f124b299f968237c6ad1ff7819e211bd7e521
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.

9 participants