Browse Source

onchaind: Pass the funding spend height through when adding a UTXO

This is necessary since we have onchaind tell us about the
their_unilateral/to_us output, after it is already in a block.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
5519717144
  1. 5
      lightningd/onchain_control.c
  2. 3
      onchaind/onchain.c
  3. 1
      onchaind/onchain_wire.csv

5
lightningd/onchain_control.c

@ -220,6 +220,7 @@ static void handle_irrevocably_resolved(struct channel *channel, const u8 *msg)
static void onchain_add_utxo(struct channel *channel, const u8 *msg)
{
struct utxo *u = tal(msg, struct utxo);
u32 blockheight;
u->close_info = tal(u, struct unilateral_close_info);
u->is_p2sh = true;
@ -227,14 +228,14 @@ static void onchain_add_utxo(struct channel *channel, const u8 *msg)
u->status = output_state_available;
u->close_info->channel_id = channel->dbid;
u->close_info->peer_id = channel->peer->id;
u->blockheight = NULL;
u->spendheight = NULL;
if (!fromwire_onchain_add_utxo(msg, &u->txid, &u->outnum,
&u->close_info->commitment_point,
&u->amount)) {
&u->amount, &blockheight)) {
fatal("onchaind gave invalid add_utxo message: %s", tal_hex(msg, msg));
}
u->blockheight = blockheight>0?&blockheight:NULL;
outpointfilter_add(channel->peer->ld->wallet->owned_outpoints, &u->txid, u->outnum);
wallet_add_utxo(channel->peer->ld->wallet, u, p2wpkh);

3
onchaind/onchain.c

@ -2039,7 +2039,8 @@ static void handle_their_unilateral(const struct bitcoin_tx *tx,
wire_sync_write(REQ_FD, towire_onchain_add_utxo(
tmpctx, txid, i,
remote_per_commitment_point,
tx->output[i].amount));
tx->output[i].amount,
tx_blockheight));
continue;
}
if (script[REMOTE]

1
onchaind/onchain_wire.csv

@ -87,3 +87,4 @@ onchain_add_utxo,,prev_out_tx,struct bitcoin_txid
onchain_add_utxo,,prev_out_index,u32
onchain_add_utxo,,per_commit_point,struct pubkey
onchain_add_utxo,,value,u64
onchain_add_utxo,,blockheight,u32

Can't render this file because it has a wrong number of fields in line 2.
Loading…
Cancel
Save