pset: make sure combinepsbt doesn't crash when explicit values are missing

I accidentally dropped this check (and its test) in the previous
commits. Restore both.
This commit is contained in:
Andrew Poelstra 2021-10-01 20:10:27 +00:00
parent 187c8094bb
commit fec0b59112
2 changed files with 3 additions and 0 deletions

View file

@ -138,6 +138,7 @@ CMutableTransaction PartiallySignedTransaction::GetUnsignedTx(bool force_unblind
txout.scriptPubKey = *output.script;
bool exp_value = output.m_value_commitment.IsNull() || force_unblinded;
exp_value = exp_value && output.amount != nullopt;
if (!output.m_value_commitment.IsNull() && output.amount != nullopt) {
exp_value = exp_value && !output.m_blind_value_proof.empty();
exp_value = exp_value && !output.m_asset_commitment.IsNull();
@ -151,6 +152,7 @@ CMutableTransaction PartiallySignedTransaction::GetUnsignedTx(bool force_unblind
}
bool exp_asset = output.m_asset_commitment.IsNull() || force_unblinded;
exp_asset = exp_asset && !output.m_asset.IsNull();
if (!output.m_asset_commitment.IsNull() && !output.m_asset.IsNull()) {
exp_asset = exp_asset && !output.m_blind_asset_proof.empty();
exp_asset = exp_asset && !output.m_asset.IsNull();

View file

@ -805,6 +805,7 @@ class PSBTTest(BitcoinTestFramework):
assert_raises_rpc_error(-8, "PSBTs not compatible (different transactions)", self.nodes[0].combinepsbt, [BAD_VALUE_PROOF, BAD_ASSET_PROOF])
for bad_pset in [ NO_VALUE_PROOF, BAD_VALUE_PROOF, NO_ASSET_PROOF, BAD_ASSET_PROOF ]:
assert_raises_rpc_error(-8, "PSBTs not compatible (different transactions)", self.nodes[0].combinepsbt, [UNBLINDED, bad_pset])
assert_raises_rpc_error(-8, "PSBTs not compatible (different transactions)", self.nodes[0].combinepsbt, [ONLY_BLIND, bad_pset])
assert_raises_rpc_error(-8, "PSBTs not compatible (different transactions)", self.nodes[0].combinepsbt, [BLINDED, bad_pset])
def run_test(self):