mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-26 20:30:59 +01:00
withdraw: fix incorrect error when we have an empty wallet.
This also highlights the danger of searching the logs: that error appeared previously in the logs, so we didn't notice that the actual withdraw call gave a different error. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
f583e6bc58
commit
71a40faae7
3 changed files with 6 additions and 3 deletions
|
@ -46,6 +46,8 @@ changes.
|
|||
- JSON RPC: `getroute` `fuzzpercent` and `pay` `maxfeepercent` can now be > 100.
|
||||
- JSON RPC: `riskfactor` in `pay` and `getroute` no longer always treated as 1.
|
||||
- JSON-RPC: `listpeers` was always reporting 0 for all stats.
|
||||
- JSON RPC: `withdraw all` says `Cannot afford transaction` if you have
|
||||
absolutely no funds, rather than `Output 0 satoshis would be dust`.
|
||||
- Protocol: don't send gossip about closed channels.
|
||||
- Protocol: fix occasional deadlock when both peers flood with gossip.
|
||||
- Protocol: fix occasional long delay on sending `reply_short_channel_ids_end`.
|
||||
|
|
|
@ -14,7 +14,7 @@ void wtx_init(struct command *cmd, struct wallet_tx * wtx)
|
|||
|
||||
static bool check_amount(const struct wallet_tx *tx, u64 amount)
|
||||
{
|
||||
if (!tx->utxos) {
|
||||
if (tal_count(tx->utxos) == 0) {
|
||||
command_fail(tx->cmd, FUND_CANNOT_AFFORD,
|
||||
"Cannot afford transaction");
|
||||
return false;
|
||||
|
|
|
@ -370,6 +370,8 @@ def test_withdraw(node_factory, bitcoind):
|
|||
l1.rpc.withdraw(waddr, 'not an amount')
|
||||
with pytest.raises(RpcError):
|
||||
l1.rpc.withdraw(waddr, -amount)
|
||||
with pytest.raises(RpcError, match=r'Cannot afford transaction'):
|
||||
l1.rpc.withdraw(waddr, amount * 100)
|
||||
|
||||
out = l1.rpc.withdraw(waddr, 2 * amount)
|
||||
|
||||
|
@ -462,9 +464,8 @@ def test_withdraw(node_factory, bitcoind):
|
|||
assert l1.db_query('SELECT COUNT(*) as c FROM outputs WHERE status=0')[0]['c'] == 0
|
||||
|
||||
# This should fail, can't even afford fee.
|
||||
with pytest.raises(RpcError):
|
||||
with pytest.raises(RpcError, match=r'Cannot afford transaction'):
|
||||
l1.rpc.withdraw(waddr, 'all')
|
||||
l1.daemon.wait_for_log('Cannot afford transaction')
|
||||
|
||||
|
||||
def test_addfunds_from_block(node_factory, bitcoind):
|
||||
|
|
Loading…
Add table
Reference in a new issue