From f0f47ce1539d3bf958300cfcf26c8d96f8c1cfd6 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Tue, 29 Oct 2019 14:50:52 -0500 Subject: [PATCH] warnings: if behind blockchain, don't show cannot afford If you're replaying or syncing with the blockchain, show that error instead of 'cannot afford', in the case of not having enough utxos to pay for a transaction. This is the 'more correct' error to show, as there's a chance that the funds you're expecting to spend are in the portion of the blockchain that hasn't been synced yet. --- common/wallet_tx.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/wallet_tx.c b/common/wallet_tx.c index 90c7bc2e7..f6cdf37fe 100644 --- a/common/wallet_tx.c +++ b/common/wallet_tx.c @@ -107,9 +107,16 @@ static struct command_result *check_amount(const struct wallet_tx *wtx, struct amount_sat amount) { if (tal_count(wtx->utxos) == 0) { + /* Since it's possible the lack of utxos is because we haven't finished + * syncing yet, report a sync timing error first */ + if (!topology_synced(wtx->cmd->ld->topology)) + return command_fail(wtx->cmd, FUNDING_STILL_SYNCING_BITCOIN, + "Still syncing with bitcoin network"); + return command_fail(wtx->cmd, FUND_CANNOT_AFFORD, "Cannot afford transaction"); } + if (amount_sat_less(amount, get_chainparams(wtx->cmd->ld)->dust_limit)) { return command_fail(wtx->cmd, FUND_OUTPUT_IS_DUST, "Output %s would be dust",