diff --git a/lightningd/onchain_control.c b/lightningd/onchain_control.c index 143aabb54..b643c89ef 100644 --- a/lightningd/onchain_control.c +++ b/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; diff --git a/onchaind/onchain_wire.csv b/onchaind/onchain_wire.csv index acb460470..cec4f03eb 100644 --- a/onchaind/onchain_wire.csv +++ b/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 diff --git a/onchaind/onchaind.c b/onchaind/onchaind.c index 515879bce..9945227d5 100644 --- a/onchaind/onchaind.c +++ b/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; } } diff --git a/onchaind/test/run-grind_feerate.c b/onchaind/test/run-grind_feerate.c index 555a1728f..974da4269 100644 --- a/onchaind/test/run-grind_feerate.c +++ b/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)