diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index f1c4f55fd..656331a9a 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -1276,6 +1276,14 @@ static void handle_irrevocably_resolved(struct peer *peer, const u8 *msg) free_peer(peer, "onchaind complete, forgetting peer"); } +/** + * onchain_add_utxo -- onchaind is telling us about a UTXO we own + */ +static void onchain_add_utxo(struct peer *peer, const u8 *msg) +{ + /* FIXME(cdecker) Implement */ +} + static unsigned int onchain_msg(struct subd *sd, const u8 *msg, const int *fds) { enum onchain_wire_type t = fromwire_peektype(msg); @@ -1309,6 +1317,10 @@ static unsigned int onchain_msg(struct subd *sd, const u8 *msg, const int *fds) handle_irrevocably_resolved(sd->peer, msg); break; + case WIRE_ONCHAIN_ADD_UTXO: + onchain_add_utxo(sd->peer, msg); + break; + /* We send these, not receive them */ case WIRE_ONCHAIN_INIT: case WIRE_ONCHAIN_SPENT: diff --git a/onchaind/onchain.c b/onchaind/onchain.c index 36ffd81ab..24277ff73 100644 --- a/onchaind/onchain.c +++ b/onchaind/onchain.c @@ -1887,6 +1887,13 @@ static void handle_their_unilateral(const struct bitcoin_tx *tx, 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 */ + wire_sync_write(REQ_FD, towire_onchain_add_utxo( + tmpctx, txid, i, + remote_per_commitment_point, + tx->output[i].amount)); continue; } if (script[REMOTE] diff --git a/onchaind/onchain_wire.csv b/onchaind/onchain_wire.csv index 16a392a9d..d30ef3fd7 100644 --- a/onchaind/onchain_wire.csv +++ b/onchaind/onchain_wire.csv @@ -82,3 +82,10 @@ onchain_htlc_timeout,,htlc,struct htlc_stub # onchaind->master: this peer can be forgotten onchain_all_irrevocably_resolved,5011 + +# onchaind->master: hey, I identified a UTXO you'll want to track +onchain_add_utxo,5012 +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 \ No newline at end of file