mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 22:45:27 +01:00
reservation: return FUNDING_STILL_SYNCING_BITCOIN if we might be missing funds.
This is useful, and also makes us pass the testsuite. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
74c6307c54
commit
3f57249f08
1 changed files with 18 additions and 10 deletions
|
@ -310,17 +310,20 @@ static struct command_result *json_fundpsbt(struct command *cmd,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If they said "all", we expect to run out of utxos. */
|
/* If they said "all", we expect to run out of utxos. */
|
||||||
if (all) {
|
if (all && tal_count(utxos))
|
||||||
/* If we have none at all though, fail */
|
|
||||||
if (!tal_count(utxos))
|
|
||||||
return command_fail(cmd, FUND_CANNOT_AFFORD,
|
|
||||||
"No available UTXOs");
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
/* 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(cmd->ld->topology))
|
||||||
|
return command_fail(cmd,
|
||||||
|
FUNDING_STILL_SYNCING_BITCOIN,
|
||||||
|
"Cannot afford: still syncing with bitcoin network...");
|
||||||
|
|
||||||
return command_fail(cmd, FUND_CANNOT_AFFORD,
|
return command_fail(cmd, FUND_CANNOT_AFFORD,
|
||||||
"Could not afford %s using all %zu available UTXOs: %s short",
|
"Could not afford %s using all %zu available UTXOs: %s short",
|
||||||
type_to_string(tmpctx,
|
all ? "all"
|
||||||
|
: type_to_string(tmpctx,
|
||||||
struct amount_sat,
|
struct amount_sat,
|
||||||
amount),
|
amount),
|
||||||
tal_count(utxos),
|
tal_count(utxos),
|
||||||
|
@ -334,12 +337,17 @@ static struct command_result *json_fundpsbt(struct command *cmd,
|
||||||
/* Anything above 0 is "excess" */
|
/* Anything above 0 is "excess" */
|
||||||
if (!inputs_sufficient(input, AMOUNT_SAT(0),
|
if (!inputs_sufficient(input, AMOUNT_SAT(0),
|
||||||
*feerate_per_kw, *weight,
|
*feerate_per_kw, *weight,
|
||||||
&diff))
|
&diff)) {
|
||||||
|
if (!topology_synced(cmd->ld->topology))
|
||||||
|
return command_fail(cmd,
|
||||||
|
FUNDING_STILL_SYNCING_BITCOIN,
|
||||||
|
"Cannot afford: still syncing with bitcoin network...");
|
||||||
return command_fail(cmd, FUND_CANNOT_AFFORD,
|
return command_fail(cmd, FUND_CANNOT_AFFORD,
|
||||||
"All %zu inputs could not afford"
|
"All %zu inputs could not afford"
|
||||||
" fees",
|
" fees",
|
||||||
tal_count(utxos));
|
tal_count(utxos));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return finish_psbt(cmd, utxos, *feerate_per_kw, *weight, diff, *reserve,
|
return finish_psbt(cmd, utxos, *feerate_per_kw, *weight, diff, *reserve,
|
||||||
locktime);
|
locktime);
|
||||||
|
|
Loading…
Add table
Reference in a new issue