Skip to content

Commit 16e3b17

Browse files
committed
Merge #14689: Require a public key to be retrieved when signing a P2PKH input
6b8d86d 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
2 parents b30c62d + 6b8d86d commit 16e3b17

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/script/sign.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static bool SignStep(const SigningProvider& provider, const BaseSignatureCreator
123123
case TX_PUBKEYHASH: {
124124
CKeyID keyID = CKeyID(uint160(vSolutions[0]));
125125
CPubKey pubkey;
126-
GetPubKey(provider, sigdata, keyID, pubkey);
126+
if (!GetPubKey(provider, sigdata, keyID, pubkey)) return false;
127127
if (!CreateSig(creator, sigdata, provider, sig, pubkey, scriptPubKey, sigversion)) return false;
128128
ret.push_back(std::move(sig));
129129
ret.push_back(ToByteVector(pubkey));

test/functional/rpc_psbt.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ def run_test(self):
276276

277277
self.test_utxo_conversion()
278278

279+
# Test that psbts with p2pkh outputs are created properly
280+
p2pkh = self.nodes[0].getnewaddress(address_type='legacy')
281+
psbt = self.nodes[1].walletcreatefundedpsbt([], [{p2pkh : 1}], 0, {"includeWatching" : True}, True)
282+
self.nodes[0].decodepsbt(psbt['psbt'])
279283

280284
if __name__ == '__main__':
281285
PSBTTest().main()

0 commit comments

Comments
 (0)