mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-26 20:30:59 +01:00
Length prefix bitcoin tx, to fix layer violation
This commit is contained in:
parent
69a47a3e1e
commit
e393791d4b
1 changed files with 6 additions and 0 deletions
|
@ -700,9 +700,14 @@ struct bitcoin_tx *fromwire_bitcoin_tx(const tal_t *ctx,
|
||||||
{
|
{
|
||||||
struct bitcoin_tx *tx;
|
struct bitcoin_tx *tx;
|
||||||
|
|
||||||
|
u32 len = fromwire_u32(cursor, max);
|
||||||
|
size_t start = *max;
|
||||||
tx = pull_bitcoin_tx(ctx, cursor, max);
|
tx = pull_bitcoin_tx(ctx, cursor, max);
|
||||||
if (!tx)
|
if (!tx)
|
||||||
return fromwire_fail(cursor, max);
|
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 */
|
/* pull_bitcoin_tx sets the psbt */
|
||||||
tal_free(tx->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)
|
void towire_bitcoin_tx(u8 **pptr, const struct bitcoin_tx *tx)
|
||||||
{
|
{
|
||||||
u8 *lin = linearize_tx(tmpctx, tx);
|
u8 *lin = linearize_tx(tmpctx, tx);
|
||||||
|
towire_u32(pptr, tal_count(lin));
|
||||||
towire_u8_array(pptr, lin, tal_count(lin));
|
towire_u8_array(pptr, lin, tal_count(lin));
|
||||||
|
|
||||||
towire_wally_psbt(pptr, tx->psbt);
|
towire_wally_psbt(pptr, tx->psbt);
|
||||||
|
|
Loading…
Add table
Reference in a new issue