diff --git a/src/script/sign.cpp b/src/script/sign.cpp --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -132,7 +132,9 @@ case TX_PUBKEYHASH: { CKeyID keyID = CKeyID(uint160(vSolutions[0])); CPubKey pubkey; - provider.GetPubKey(keyID, pubkey); + if (!provider.GetPubKey(keyID, pubkey)) { + return false; + } if (!CreateSig(creator, sigdata, provider, sig, pubkey, scriptPubKey)) { return false; diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -224,6 +224,12 @@ self.nodes[0].decodepsbt, ";definitely not base64;") + # Test that psbts with p2pkh outputs are created properly + p2pkh = self.nodes[0].getnewaddress() + psbt = self.nodes[1].walletcreatefundedpsbt( + [], [{p2pkh: 1}], 0, {"includeWatching": True}, True) + self.nodes[0].decodepsbt(psbt['psbt']) + if __name__ == '__main__': PSBTTest().main()