wallet: Store outputs from onchaind in the DB

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker
2017-12-20 23:05:32 +01:00
parent 0bb264e1a2
commit 37c2873c88
2 changed files with 19 additions and 2 deletions

View File

@@ -1281,7 +1281,23 @@ static void handle_irrevocably_resolved(struct peer *peer, const u8 *msg)
*/
static void onchain_add_utxo(struct peer *peer, const u8 *msg)
{
/* FIXME(cdecker) Implement */
struct utxo *u = tal(msg, struct utxo);
u->close_info = tal(u, struct unilateral_close_info);
u->is_p2sh = true;
u->keyindex = 0;
u->status = output_state_available;
u->close_info->channel_id = peer->channel->id;
u->close_info->peer_id = peer->id;
if (!fromwire_onchain_add_utxo(msg, NULL, &u->txid, &u->outnum,
&u->close_info->commitment_point,
&u->amount)) {
fatal("onchaind gave invalid add_utxo message: %s", tal_hex(msg, msg));
}
wallet_add_utxo(peer->ld->wallet, u, p2wpkh);
}
static unsigned int onchain_msg(struct subd *sd, const u8 *msg, const int *fds)