Skip to content

Commit

Permalink
wallet: allow to withdraw with unconfirmed utxos
Browse files Browse the repository at this point in the history
Changelog-Fixed: Passing 0 as minconf to withdraw allows you to use unconfirmed transaction outputs, even if explicitly passed as the `utxos` parameter
  • Loading branch information
darosior committed Mar 16, 2020
1 parent 2b2ee87 commit b5e2b2d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion common/wallet_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ struct command_result *wtx_from_utxos(struct wallet_tx *tx,
/* + segwit marker + flag */
weight = 4 * (4 + 1 + 1 + 4) + 4 * (8 + 1 + out_len) + 1 + 1;
for (size_t i = 0; i < tal_count(utxos); i++) {
if (!utxos[i]->blockheight || *utxos[i]->blockheight > maxheight) {
if (maxheight > 0 &&
(!utxos[i]->blockheight || *utxos[i]->blockheight > maxheight)) {
tal_arr_remove(&utxos, i);
continue;
}
Expand Down
8 changes: 8 additions & 0 deletions tests/test_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@ def test_withdraw(node_factory, bitcoind):
for utxo in utxos:
assert utxo in vins

# Try passing unconfirmed utxos
unconfirmed_utxos = [l1.rpc.withdraw(l1.rpc.newaddr()["bech32"], 10**5)
for _ in range(5)]
uutxos = [u["txid"] + ":0" for u in unconfirmed_utxos]
l1.rpc.withdraw(waddr, "all", minconf=0, feerate="3000perkb",
utxos=uutxos)



def test_minconf_withdraw(node_factory, bitcoind):
"""Issue 2518: ensure that ridiculous confirmation levels don't overflow
Expand Down

0 comments on commit b5e2b2d

Please sign in to comment.