fromwire_bitcoin_tx: avoid creating a PSBT wrapper just to throw it away again

Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
This commit is contained in:
Jon Griffiths 2024-01-09 20:42:03 +13:00 committed by Christian Decker
parent 1b37515528
commit cdb5de0bce

View File

@ -794,15 +794,13 @@ struct bitcoin_tx *fromwire_bitcoin_tx(const tal_t *ctx,
u32 len = fromwire_u32(cursor, max); u32 len = fromwire_u32(cursor, max);
size_t start = *max; size_t start = *max;
tx = pull_bitcoin_tx(ctx, cursor, max); tx = pull_bitcoin_tx_only(ctx, cursor, max);
if (!tx) if (!tx)
return fromwire_fail(cursor, max); return fromwire_fail(cursor, max);
// Check that we consumed len bytes // Check that we consumed len bytes
if (start - *max != len) if (start - *max != len)
return fromwire_fail(cursor, max); return fromwire_fail(cursor, max);
/* pull_bitcoin_tx sets the psbt */
tal_free(tx->psbt);
tx->psbt = fromwire_wally_psbt(tx, cursor, max); tx->psbt = fromwire_wally_psbt(tx, cursor, max);
if (!tx->psbt) if (!tx->psbt)
return fromwire_fail(cursor, max); return fromwire_fail(cursor, max);