diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2018-11-09 20:05:55 -0800 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2018-11-09 20:14:28 -0800 |
commit | 16e3b175781caacee403a2dc40cd6c70448e12ef (patch) | |
tree | f40daf66cd0ade0d0a25775b7f6bf799af1ad97e | |
parent | b30c62d4b954df05bf404cfbeb5b728282201496 (diff) | |
parent | 6b8d86ddb803d50d8608d95f7e8f791511dec8b9 (diff) | |
download | bitcoin-16e3b175781caacee403a2dc40cd6c70448e12ef.tar.xz |
Merge #14689: Require a public key to be retrieved when signing a P2PKH input
6b8d86ddb8 Require a public key to be retrieved when signing a P2PKH input (Andrew Chow)
Pull request description:
If we do not have the public key for a P2PKH input, we should not continue to attempt to sign for it.
This fixes a problem where a PSBT with a P2PKH output would include invalid BIP 32 derivation paths that are missing the public key.
Tree-SHA512: 850d5e74c06833da937d5bf0348bd134180be7167b6f9b9cecbf09f75e3543fbad60d0abbc0b9afdfa51ce165aa36168849f24a7c5abf1e75f37ce8f9a13d127
-rw-r--r-- | src/script/sign.cpp | 2 | ||||
-rwxr-xr-x | test/functional/rpc_psbt.py | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 69ee08ffd7..2795dc96d3 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -123,7 +123,7 @@ static bool SignStep(const SigningProvider& provider, const BaseSignatureCreator case TX_PUBKEYHASH: { CKeyID keyID = CKeyID(uint160(vSolutions[0])); CPubKey pubkey; - GetPubKey(provider, sigdata, keyID, pubkey); + if (!GetPubKey(provider, sigdata, keyID, pubkey)) return false; if (!CreateSig(creator, sigdata, provider, sig, pubkey, scriptPubKey, sigversion)) return false; ret.push_back(std::move(sig)); ret.push_back(ToByteVector(pubkey)); diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py index 86b043176c..ba3818bf24 100755 --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -276,6 +276,10 @@ class PSBTTest(BitcoinTestFramework): self.test_utxo_conversion() + # Test that psbts with p2pkh outputs are created properly + p2pkh = self.nodes[0].getnewaddress(address_type='legacy') + psbt = self.nodes[1].walletcreatefundedpsbt([], [{p2pkh : 1}], 0, {"includeWatching" : True}, True) + self.nodes[0].decodepsbt(psbt['psbt']) if __name__ == '__main__': PSBTTest().main() |