From ca30c8c0cc6f9396189d51be7840bdafeb0783af Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Tue, 23 May 2017 22:08:27 +0200 Subject: [PATCH] wallet: Track available outputs We'd like to use the database as the unique source of truth, to avoid having to synchronize multiple versions. --- lightningd/build_utxos.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lightningd/build_utxos.c b/lightningd/build_utxos.c index cbcb0abb1..50ff442d1 100644 --- a/lightningd/build_utxos.c +++ b/lightningd/build_utxos.c @@ -145,6 +145,11 @@ static void json_addfunds(struct command *cmd, bitcoin_txid(tx, &utxo->utxo.txid); utxo->utxo.outnum = output; utxo->reserved = false; + if (!wallet_add_utxo(ld->wallet, &utxo->utxo, p2sh_wpkh)) { + command_fail(cmd, "Could add outputs to wallet"); + tal_free(utxo); + return; + } list_add_tail(&ld->utxos, &utxo->list); total_satoshi += utxo->utxo.amount; num_utxos++;