diff --git a/common/wallet_tx.c b/common/wallet_tx.c index 22197d37e549..da9a1a171523 100644 --- a/common/wallet_tx.c +++ b/common/wallet_tx.c @@ -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; } diff --git a/tests/test_wallet.py b/tests/test_wallet.py index 55b6fa7d3912..59555e318216 100644 --- a/tests/test_wallet.py +++ b/tests/test_wallet.py @@ -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