wallet: Reserve UTXOs used in build_utxos

This commit is contained in:
Christian Decker
2017-05-31 16:16:59 +02:00
committed by Rusty Russell
parent 19a4e7f542
commit bdb6b1002f
4 changed files with 82 additions and 8 deletions

View File

@@ -179,7 +179,12 @@ static void unreserve_utxo(struct lightningd *ld, const struct utxo *unres)
{
struct tracked_utxo *utxo;
list_for_each(&ld->utxos, utxo, list) {
assert(wallet_update_output_status(ld->wallet, &unres->txid,
unres->outnum, output_state_reserved,
output_state_available));
list_for_each(&ld->utxos, utxo, list)
{
if (unres != &utxo->utxo)
continue;
assert(utxo->reserved);
@@ -225,6 +230,10 @@ const struct utxo **build_utxos(const tal_t *ctx,
utxos[i] = &utxo->utxo;
utxo->reserved = true;
assert(wallet_update_output_status(
ld->wallet, &utxo->utxo.txid, utxo->utxo.outnum,
output_state_available, output_state_reserved));
/* Add this input's weight. */
weight += (32 + 4 + 4) * 4;
if (utxos[i]->is_p2sh)