Browse Source

onchaind: Have onchaind also tell us the scriptPubKey of our outputs

onchaind is in the correct position to tell us about them, so have it pass
them up as well.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
issue-2080
Christian Decker 6 years ago
parent
commit
3bb1c26f02
No known key found for this signature in database GPG Key ID: 1416D83DC4F0E86D
  1. 7
      lightningd/onchain_control.c
  2. 2
      onchaind/onchain_wire.csv
  3. 15
      onchaind/onchaind.c
  4. 2
      onchaind/test/run-grind_feerate.c

7
lightningd/onchain_control.c

@ -272,11 +272,10 @@ static void onchain_add_utxo(struct channel *channel, const u8 *msg)
u->close_info->channel_id = channel->dbid;
u->close_info->peer_id = channel->peer->id;
u->spendheight = NULL;
u->scriptPubkey = NULL;
if (!fromwire_onchain_add_utxo(msg, &u->txid, &u->outnum,
&u->close_info->commitment_point,
&u->amount, &blockheight)) {
if (!fromwire_onchain_add_utxo(
u, msg, &u->txid, &u->outnum, &u->close_info->commitment_point,
&u->amount, &blockheight, &u->scriptPubkey)) {
fatal("onchaind gave invalid add_utxo message: %s", tal_hex(msg, msg));
}
u->blockheight = blockheight>0?&blockheight:NULL;

2
onchaind/onchain_wire.csv

@ -90,6 +90,8 @@ onchain_add_utxo,,prev_out_index,u32
onchain_add_utxo,,per_commit_point,struct pubkey
onchain_add_utxo,,value,struct amount_sat
onchain_add_utxo,,blockheight,u32
onchain_add_utxo,,len,u16
onchain_add_utxo,,scriptpubkey,len*u8
# master -> onchaind: do you have a memleak?
onchain_dev_memleak,5033

Can't render this file because it has a wrong number of fields in line 4.

15
onchaind/onchaind.c

@ -2014,7 +2014,6 @@ static void handle_their_cheat(const struct bitcoin_tx *tx,
i, tx->output[i].amount,
OUTPUT_TO_US, NULL, NULL, NULL);
ignore_output(out);
script[LOCAL] = NULL;
/* Tell the master that it will want to add
* this UTXO to its outputs */
@ -2022,7 +2021,9 @@ static void handle_their_cheat(const struct bitcoin_tx *tx,
tmpctx, txid, i,
remote_per_commitment_point,
tx->output[i].amount,
tx_blockheight));
tx_blockheight,
script[LOCAL]));
script[LOCAL] = NULL;
continue;
}
if (script[REMOTE]
@ -2226,7 +2227,6 @@ static void handle_their_unilateral(const struct bitcoin_tx *tx,
i, tx->output[i].amount,
OUTPUT_TO_US, NULL, NULL, NULL);
ignore_output(out);
script[LOCAL] = NULL;
/* Tell the master that it will want to add
* this UTXO to its outputs */
@ -2234,7 +2234,9 @@ static void handle_their_unilateral(const struct bitcoin_tx *tx,
tmpctx, txid, i,
remote_per_commitment_point,
tx->output[i].amount,
tx_blockheight));
tx_blockheight,
script[LOCAL]));
script[LOCAL] = NULL;
continue;
}
if (script[REMOTE]
@ -2355,7 +2357,6 @@ static void handle_unknown_commitment(const struct bitcoin_tx *tx,
i, tx->output[i].amount,
OUTPUT_TO_US, NULL, NULL, NULL);
ignore_output(out);
local_script = NULL;
/* Tell the master that it will want to add
* this UTXO to its outputs */
@ -2363,7 +2364,9 @@ static void handle_unknown_commitment(const struct bitcoin_tx *tx,
tmpctx, txid, i,
possible_remote_per_commitment_point,
tx->output[i].amount,
tx_blockheight));
tx_blockheight,
local_script));
local_script = NULL;
to_us_output = i;
}
}

2
onchaind/test/run-grind_feerate.c

@ -124,7 +124,7 @@ u8 *towire_hsm_sign_penalty_to_us(const tal_t *ctx UNNEEDED, const struct secret
u8 *towire_hsm_sign_remote_htlc_to_us(const tal_t *ctx UNNEEDED, const struct pubkey *remote_per_commitment_point UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED, struct amount_sat input_amount UNNEEDED)
{ fprintf(stderr, "towire_hsm_sign_remote_htlc_to_us called!\n"); abort(); }
/* Generated stub for towire_onchain_add_utxo */
u8 *towire_onchain_add_utxo(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *prev_out_tx UNNEEDED, u32 prev_out_index UNNEEDED, const struct pubkey *per_commit_point UNNEEDED, struct amount_sat value UNNEEDED, u32 blockheight UNNEEDED)
u8 *towire_onchain_add_utxo(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *prev_out_tx UNNEEDED, u32 prev_out_index UNNEEDED, const struct pubkey *per_commit_point UNNEEDED, struct amount_sat value UNNEEDED, u32 blockheight UNNEEDED, const u8 *scriptpubkey UNNEEDED)
{ fprintf(stderr, "towire_onchain_add_utxo called!\n"); abort(); }
/* Generated stub for towire_onchain_all_irrevocably_resolved */
u8 *towire_onchain_all_irrevocably_resolved(const tal_t *ctx UNNEEDED)

Loading…
Cancel
Save