wallet: Track available outputs

We'd like to use the database as the unique source of truth, to
avoid having to synchronize multiple versions.
This commit is contained in:
Christian Decker
2017-05-23 22:08:27 +02:00
committed by Rusty Russell
parent 9882a9fb29
commit ca30c8c0cc

View File

@@ -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++;