mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
Length prefix bitcoin tx, to fix layer violation
This commit is contained in:
committed by
Christian Decker
parent
69a47a3e1e
commit
e393791d4b
@@ -700,9 +700,14 @@ struct bitcoin_tx *fromwire_bitcoin_tx(const tal_t *ctx,
|
||||
{
|
||||
struct bitcoin_tx *tx;
|
||||
|
||||
u32 len = fromwire_u32(cursor, max);
|
||||
size_t start = *max;
|
||||
tx = pull_bitcoin_tx(ctx, cursor, max);
|
||||
if (!tx)
|
||||
return fromwire_fail(cursor, max);
|
||||
// Check that we consumed len bytes
|
||||
if (start - *max != len)
|
||||
return fromwire_fail(cursor, max);
|
||||
|
||||
/* pull_bitcoin_tx sets the psbt */
|
||||
tal_free(tx->psbt);
|
||||
@@ -744,6 +749,7 @@ void fromwire_bitcoin_outpoint(const u8 **cursor, size_t *max,
|
||||
void towire_bitcoin_tx(u8 **pptr, const struct bitcoin_tx *tx)
|
||||
{
|
||||
u8 *lin = linearize_tx(tmpctx, tx);
|
||||
towire_u32(pptr, tal_count(lin));
|
||||
towire_u8_array(pptr, lin, tal_count(lin));
|
||||
|
||||
towire_wally_psbt(pptr, tx->psbt);
|
||||
|
||||
Reference in New Issue
Block a user