Skip to content

Commit 6b8d86d

Browse files
committed
Require a public key to be retrieved when signing a P2PKH input
If we do not have the public key for a P2PKH input, we should not continue to attempt to sign for it.
1 parent 11e1ac3 commit 6b8d86d

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
@@ -269,6 +269,10 @@ def run_test(self):
269269

270270
self.test_utxo_conversion()
271271

272+
# Test that psbts with p2pkh outputs are created properly
273+
p2pkh = self.nodes[0].getnewaddress(address_type='legacy')
274+
psbt = self.nodes[1].walletcreatefundedpsbt([], [{p2pkh : 1}], 0, {"includeWatching" : True}, True)
275+
self.nodes[0].decodepsbt(psbt['psbt'])
272276

273277
if __name__ == '__main__':
274278
PSBTTest().main()

0 commit comments

Comments
 (0)