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.
This commit is contained in:
Andrew Chow 2018-11-08 10:08:46 -05:00
parent 11e1ac3ae0
commit 6b8d86ddb8
2 changed files with 5 additions and 1 deletions

View file

@ -123,7 +123,7 @@ static bool SignStep(const SigningProvider& provider, const BaseSignatureCreator
case TX_PUBKEYHASH: { case TX_PUBKEYHASH: {
CKeyID keyID = CKeyID(uint160(vSolutions[0])); CKeyID keyID = CKeyID(uint160(vSolutions[0]));
CPubKey pubkey; 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; if (!CreateSig(creator, sigdata, provider, sig, pubkey, scriptPubKey, sigversion)) return false;
ret.push_back(std::move(sig)); ret.push_back(std::move(sig));
ret.push_back(ToByteVector(pubkey)); ret.push_back(ToByteVector(pubkey));

View file

@ -269,6 +269,10 @@ class PSBTTest(BitcoinTestFramework):
self.test_utxo_conversion() 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__': if __name__ == '__main__':
PSBTTest().main() PSBTTest().main()