bitcoin/tx: check PSBT sanity after parsing

We could end up handing a valid tx containing a NULL PSBT around.

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
This commit is contained in:
Antoine Poinsot 2021-05-10 01:37:51 +02:00 committed by Rusty Russell
parent 225fec065a
commit 08d32123d8

View file

@ -595,6 +595,8 @@ struct bitcoin_tx *pull_bitcoin_tx(const tal_t *ctx, const u8 **cursor,
tal_add_destructor(tx, bitcoin_tx_destroy);
tx->chainparams = chainparams;
tx->psbt = new_psbt(tx, tx->wtx);
if (!tx->psbt)
return tal_free(tx);
return tx;
}
@ -710,6 +712,8 @@ struct bitcoin_tx *fromwire_bitcoin_tx(const tal_t *ctx,
/* pull_bitcoin_tx sets the psbt */
tal_free(tx->psbt);
tx->psbt = fromwire_wally_psbt(tx, cursor, max);
if (!tx->psbt)
return fromwire_fail(cursor, max);
return tx;
}