diff --git a/bitcoin/tx.c b/bitcoin/tx.c index 506cc475e..9717ac855 100644 --- a/bitcoin/tx.c +++ b/bitcoin/tx.c @@ -195,6 +195,14 @@ u8 *linearize_tx(const tal_t *ctx, const struct bitcoin_tx *tx) return arr; } +u8 *linearize_tx_force_extended(const tal_t *ctx, + const struct bitcoin_tx *tx) +{ + u8 *arr = tal_arr(ctx, u8, 0); + add_tx(tx, add_linearize, &arr, true); + return arr; +} + void bitcoin_txid(const struct bitcoin_tx *tx, struct sha256_double *txid) { struct sha256_ctx ctx = SHA256_INIT; diff --git a/bitcoin/tx.h b/bitcoin/tx.h index b42db2eaf..2051c167a 100644 --- a/bitcoin/tx.h +++ b/bitcoin/tx.h @@ -46,6 +46,10 @@ void sha256_tx_for_sig(struct sha256_ctx *ctx, const struct bitcoin_tx *tx, /* Linear bytes of tx. */ u8 *linearize_tx(const tal_t *ctx, const struct bitcoin_tx *tx); +/* Force linearization in extended form; useful if 0 inputs. */ +u8 *linearize_tx_force_extended(const tal_t *ctx, + const struct bitcoin_tx *tx); + /* Allocate a tx: you just need to fill in inputs and outputs (they're * zeroed with inputs' sequence_number set to FFFFFFFF) */ struct bitcoin_tx *bitcoin_tx(const tal_t *ctx, varint_t input_count, diff --git a/daemon/bitcoind.c b/daemon/bitcoind.c index f47db7633..ea28a3b1e 100644 --- a/daemon/bitcoind.c +++ b/daemon/bitcoind.c @@ -519,7 +519,7 @@ void bitcoind_fund_transaction(struct lightningd_state *dstate, struct peer *peer) { struct funding_process *f = tal(peer, struct funding_process); - u8 *raw = linearize_tx(dstate, tx_no_inputs); + u8 *raw = linearize_tx_force_extended(dstate, tx_no_inputs); char *hex = tal_arr(raw, char, hex_str_size(tal_count(raw))); assert(tx_no_inputs->input_count == 0);