mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Merge #17264: rpc: set default bip32derivs to true for psbt methods
5bad7921d0b33b62c0a59a478c2e8c869fc5e3b5 [test] PSBT RPC: check that bip32_derivs are present by default (Sjors Provoost)
29a21c90610aed88b796a7a5900e42e9048b990e [rpc] set default bip32derivs to true for psbt methods (Sjors Provoost)
Pull request description:
In https://github.com/bitcoin/bitcoin/pull/13557#pullrequestreview-135905054 I recommended not including bip32 deriviation by default in PSBTs:
> _Bit of a privacy issue_: let's say person A and B are about to spend from a multisig address, sending everything to person A. Person A gives their address to person B, their wallet wallet creates a PSBT, but doesn't sign it. Wallet A then calls `walletprocesspsbt` which signs it and _spontaneously adds the master_fingerprint and bip32 path_. Same issue with `walletcreatefundedpsbt`.
>
> Adding `bip32_derivs` should probably be opt-in.
In practice I find this default quite annoying because I forget it and end up with a confused hardware wallet.
More importantly, in the multisig example I provided, it's actually essential for the other side to know the derivation details (in addition to an xpub). This allows them to check that change is going to an address you can still co-sign for (because the spending policy is unchanged except for an index).
ACKs for top commit:
instagibbs:
utACK 5bad7921d0
jonatack:
ACK 5bad7921d0 code review, built, ran tests, inspected/messed around with/pprinted values from the new tests. Thanks for adding the tests.
meshcollider:
utACK 5bad7921d0b33b62c0a59a478c2e8c869fc5e3b5
Tree-SHA512: 22ad71dda96856060a96758c4ae7aafa22d5e9efba30e0c8287c711e7579849bd72593cbc0f41a2e9e8821315d78bda04e848dbb006283b841b2795e2faebcfd
This commit is contained in:
parent
02aac6b0f8
commit
9fc7ffaac9
4
doc/release-notes-17264.md
Normal file
4
doc/release-notes-17264.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Updated RPCs
|
||||||
|
------------
|
||||||
|
|
||||||
|
- `walletprocesspsbt` and `walletcreatefundedpsbt` now include BIP 32 derivation paths by default for public keys if we know them. This can be disabled by setting `bip32derivs` to `false`.
|
@ -27,6 +27,6 @@
|
|||||||
bool& complete,
|
bool& complete,
|
||||||
int sighash_type = 1 /* SIGHASH_ALL */,
|
int sighash_type = 1 /* SIGHASH_ALL */,
|
||||||
bool sign = true,
|
bool sign = true,
|
||||||
bool bip32derivs = false);
|
bool bip32derivs = true);
|
||||||
|
|
||||||
#endif // BITCOIN_WALLET_PSBTWALLET_H
|
#endif // BITCOIN_WALLET_PSBTWALLET_H
|
||||||
|
@ -3866,7 +3866,7 @@ UniValue walletprocesspsbt(const JSONRPCRequest& request)
|
|||||||
" \"ALL|ANYONECANPAY\"\n"
|
" \"ALL|ANYONECANPAY\"\n"
|
||||||
" \"NONE|ANYONECANPAY\"\n"
|
" \"NONE|ANYONECANPAY\"\n"
|
||||||
" \"SINGLE|ANYONECANPAY\""},
|
" \"SINGLE|ANYONECANPAY\""},
|
||||||
{"bip32derivs", RPCArg::Type::BOOL, /* default */ "false", "If true, includes the BIP 32 derivation paths for public keys if we know them"},
|
{"bip32derivs", RPCArg::Type::BOOL, /* default */ "true", "Include BIP 32 derivation paths for public keys if we know them"},
|
||||||
},
|
},
|
||||||
RPCResult{
|
RPCResult{
|
||||||
RPCResult::Type::OBJ, "", "",
|
RPCResult::Type::OBJ, "", "",
|
||||||
@ -3902,7 +3902,7 @@ UniValue walletprocesspsbt(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
// Fill transaction with our data and also sign
|
// Fill transaction with our data and also sign
|
||||||
bool sign = request.params[1].isNull() ? true : request.params[1].get_bool();
|
bool sign = request.params[1].isNull() ? true : request.params[1].get_bool();
|
||||||
bool bip32derivs = request.params[3].isNull() ? false : request.params[3].get_bool();
|
bool bip32derivs = request.params[3].isNull() ? true : request.params[3].get_bool();
|
||||||
bool complete = true;
|
bool complete = true;
|
||||||
const TransactionError err = FillPSBT(pwallet, psbtx, complete, nHashType, sign, bip32derivs);
|
const TransactionError err = FillPSBT(pwallet, psbtx, complete, nHashType, sign, bip32derivs);
|
||||||
if (err != TransactionError::OK) {
|
if (err != TransactionError::OK) {
|
||||||
@ -3975,7 +3975,7 @@ UniValue walletcreatefundedpsbt(const JSONRPCRequest& request)
|
|||||||
" \"CONSERVATIVE\""},
|
" \"CONSERVATIVE\""},
|
||||||
},
|
},
|
||||||
"options"},
|
"options"},
|
||||||
{"bip32derivs", RPCArg::Type::BOOL, /* default */ "false", "If true, includes the BIP 32 derivation paths for public keys if we know them"},
|
{"bip32derivs", RPCArg::Type::BOOL, /* default */ "true", "Include BIP 32 derivation paths for public keys if we know them"},
|
||||||
},
|
},
|
||||||
RPCResult{
|
RPCResult{
|
||||||
RPCResult::Type::OBJ, "", "",
|
RPCResult::Type::OBJ, "", "",
|
||||||
@ -4013,7 +4013,7 @@ UniValue walletcreatefundedpsbt(const JSONRPCRequest& request)
|
|||||||
PartiallySignedTransaction psbtx{rawTx};
|
PartiallySignedTransaction psbtx{rawTx};
|
||||||
|
|
||||||
// Fill transaction with out data but don't sign
|
// Fill transaction with out data but don't sign
|
||||||
bool bip32derivs = request.params[4].isNull() ? false : request.params[4].get_bool();
|
bool bip32derivs = request.params[4].isNull() ? true : request.params[4].get_bool();
|
||||||
bool complete = true;
|
bool complete = true;
|
||||||
const TransactionError err = FillPSBT(pwallet, psbtx, complete, 1, false, bip32derivs);
|
const TransactionError err = FillPSBT(pwallet, psbtx, complete, 1, false, bip32derivs);
|
||||||
if (err != TransactionError::OK) {
|
if (err != TransactionError::OK) {
|
||||||
|
@ -133,12 +133,20 @@ class PSBTTest(BitcoinTestFramework):
|
|||||||
psbt_orig = self.nodes[0].createpsbt([{"txid":txid1, "vout":vout1}, {"txid":txid2, "vout":vout2}], {self.nodes[0].getnewaddress():25.999})
|
psbt_orig = self.nodes[0].createpsbt([{"txid":txid1, "vout":vout1}, {"txid":txid2, "vout":vout2}], {self.nodes[0].getnewaddress():25.999})
|
||||||
|
|
||||||
# Update psbts, should only have data for one input and not the other
|
# Update psbts, should only have data for one input and not the other
|
||||||
psbt1 = self.nodes[1].walletprocesspsbt(psbt_orig)['psbt']
|
psbt1 = self.nodes[1].walletprocesspsbt(psbt_orig, False, "ALL")['psbt']
|
||||||
psbt1_decoded = self.nodes[0].decodepsbt(psbt1)
|
psbt1_decoded = self.nodes[0].decodepsbt(psbt1)
|
||||||
assert psbt1_decoded['inputs'][0] and not psbt1_decoded['inputs'][1]
|
assert psbt1_decoded['inputs'][0] and not psbt1_decoded['inputs'][1]
|
||||||
psbt2 = self.nodes[2].walletprocesspsbt(psbt_orig)['psbt']
|
# Check that BIP32 path was added
|
||||||
|
assert "bip32_derivs" in psbt1_decoded['inputs'][0]
|
||||||
|
psbt2 = self.nodes[2].walletprocesspsbt(psbt_orig, False, "ALL", False)['psbt']
|
||||||
psbt2_decoded = self.nodes[0].decodepsbt(psbt2)
|
psbt2_decoded = self.nodes[0].decodepsbt(psbt2)
|
||||||
assert not psbt2_decoded['inputs'][0] and psbt2_decoded['inputs'][1]
|
assert not psbt2_decoded['inputs'][0] and psbt2_decoded['inputs'][1]
|
||||||
|
# Check that BIP32 paths were not added
|
||||||
|
assert "bip32_derivs" not in psbt2_decoded['inputs'][1]
|
||||||
|
|
||||||
|
# Sign PSBTs (workaround issue #18039)
|
||||||
|
psbt1 = self.nodes[1].walletprocesspsbt(psbt_orig)['psbt']
|
||||||
|
psbt2 = self.nodes[2].walletprocesspsbt(psbt_orig)['psbt']
|
||||||
|
|
||||||
# Combine, finalize, and send the psbts
|
# Combine, finalize, and send the psbts
|
||||||
combined = self.nodes[0].combinepsbt([psbt1, psbt2])
|
combined = self.nodes[0].combinepsbt([psbt1, psbt2])
|
||||||
|
Loading…
Reference in New Issue
Block a user