Browse Source

bitcoind: work around fundrawtransaction segwit issue.

See https://github.com/sipa/bitcaoin/issues/67

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 9 years ago
parent
commit
66084271c3
  1. 8
      bitcoin/tx.c
  2. 4
      bitcoin/tx.h
  3. 2
      daemon/bitcoind.c

8
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;

4
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,

2
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);

Loading…
Cancel
Save