mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-02 18:35:00 +01:00
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.
This commit is contained in:
parent
7f45e55d84
commit
f0f47ce153
1 changed files with 7 additions and 0 deletions
|
@ -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",
|
||||
|
|
Loading…
Add table
Reference in a new issue