mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
config: add min-emergency-msat option.
For anchors, we need some sats sitting around in case we need to CPFP a close. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Config: `min-emergency-msat` setting for (currently experimental!) anchor channels, to keep funds in reserve for forced closes.
This commit is contained in:
parent
2f0e13e793
commit
75aca3cbb6
6 changed files with 50 additions and 1 deletions
|
@ -349,6 +349,7 @@ On success, an object is returned, containing:
|
||||||
- **announce-addr-dns** (boolean, optional): Whether we put DNS entries into node\_announcement **deprecated, removal in v24.05** *(added v22.11.1)*
|
- **announce-addr-dns** (boolean, optional): Whether we put DNS entries into node\_announcement **deprecated, removal in v24.05** *(added v22.11.1)*
|
||||||
- **require-confirmed-inputs** (boolean, optional): Request peers to only send confirmed inputs (dual-fund only) **deprecated, removal in v24.05**
|
- **require-confirmed-inputs** (boolean, optional): Request peers to only send confirmed inputs (dual-fund only) **deprecated, removal in v24.05**
|
||||||
- **commit-fee** (u64, optional): The percentage of the 6-block fee estimate to use for commitment transactions **deprecated, removal in v24.05** *(added v23.05)*
|
- **commit-fee** (u64, optional): The percentage of the 6-block fee estimate to use for commitment transactions **deprecated, removal in v24.05** *(added v23.05)*
|
||||||
|
- **min-emergency-msat** (msat, optional): field from config or cmdline, or default *(added v23.08)*
|
||||||
|
|
||||||
[comment]: # (GENERATE-FROM-SCHEMA-END)
|
[comment]: # (GENERATE-FROM-SCHEMA-END)
|
||||||
|
|
||||||
|
@ -466,4 +467,4 @@ RESOURCES
|
||||||
|
|
||||||
Main web site: <https://github.com/ElementsProject/lightning>
|
Main web site: <https://github.com/ElementsProject/lightning>
|
||||||
|
|
||||||
[comment]: # ( SHA256STAMP:d24d8d540253bbe3cf9113b265fd3128e351d4615c28f6054730d1b03b363155)
|
[comment]: # ( SHA256STAMP:a40882cad0d889aa736a2932250102be43ae7e62b3d2429b26e0961e4c315f7b)
|
||||||
|
|
|
@ -440,6 +440,11 @@ have to do that.
|
||||||
This option specifies that these (comma-separated) types are to be
|
This option specifies that these (comma-separated) types are to be
|
||||||
accepted, and ignored.
|
accepted, and ignored.
|
||||||
|
|
||||||
|
* **min-emergency-msat**=*msat*
|
||||||
|
|
||||||
|
This is the amount of funds to keep in the wallet to close anchor channels (which don't carry their own transaction fees). It defaults to 25000sat, and is only maintained if there are any anchor channels (or, when opening an anchor channel). This amount may be insufficient for multiple closes at once, however.
|
||||||
|
|
||||||
|
|
||||||
### Cleanup control options:
|
### Cleanup control options:
|
||||||
|
|
||||||
* **autoclean-cycle**=*SECONDS* [plugin `autoclean`, *dynamic*]
|
* **autoclean-cycle**=*SECONDS* [plugin `autoclean`, *dynamic*]
|
||||||
|
|
|
@ -1712,6 +1712,11 @@
|
||||||
"type": "u64",
|
"type": "u64",
|
||||||
"added": "v23.05",
|
"added": "v23.05",
|
||||||
"description": "The percentage of the 6-block fee estimate to use for commitment transactions"
|
"description": "The percentage of the 6-block fee estimate to use for commitment transactions"
|
||||||
|
},
|
||||||
|
"min-emergency-msat": {
|
||||||
|
"type": "msat",
|
||||||
|
"added": "v23.08",
|
||||||
|
"description": "field from config or cmdline, or default"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,6 +322,19 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
||||||
* case this is a pointer to an enum feerate-indexed array of values */
|
* case this is a pointer to an enum feerate-indexed array of values */
|
||||||
ld->force_feerates = NULL;
|
ld->force_feerates = NULL;
|
||||||
|
|
||||||
|
/*~ We need some funds to help CPFP spend unilateral closes. How
|
||||||
|
* much? But let's assume we want to boost the commitment tx (1112
|
||||||
|
* Sipa).
|
||||||
|
*
|
||||||
|
* Anchor witness script is 40 bytes, sig is 72, input bytes is 32 + 4
|
||||||
|
* + 1 + 1 + 4, core is 10 bytes, P2WKH output is 8 + 1 + 1 + 1 + 32
|
||||||
|
* bytes. Weight (40 + 42 + 10 + 43)*4 + 40 + 72 = 652.
|
||||||
|
*
|
||||||
|
* So every 441 sats we can increase feerate by 1 sat / vbyte. Set
|
||||||
|
* the default minimum at 25,000 sats.
|
||||||
|
*/
|
||||||
|
ld->emergency_sat = AMOUNT_SAT(25000);
|
||||||
|
|
||||||
return ld;
|
return ld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -365,6 +365,9 @@ struct lightningd {
|
||||||
|
|
||||||
/* --experimental-upgrade-protocol */
|
/* --experimental-upgrade-protocol */
|
||||||
bool experimental_upgrade_protocol;
|
bool experimental_upgrade_protocol;
|
||||||
|
|
||||||
|
/* For anchors: how much do we keep for spending close txs? */
|
||||||
|
struct amount_sat emergency_sat;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Turning this on allows a tal allocation to return NULL, rather than aborting.
|
/* Turning this on allows a tal allocation to return NULL, rather than aborting.
|
||||||
|
|
|
@ -1116,6 +1116,25 @@ static char *opt_set_msat(const char *arg, struct amount_msat *amt)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *opt_set_sat(const char *arg, struct amount_sat *sat)
|
||||||
|
{
|
||||||
|
struct amount_msat msat;
|
||||||
|
if (!parse_amount_msat(&msat, arg, strlen(arg)))
|
||||||
|
return tal_fmt(NULL, "Unable to parse millisatoshi '%s'", arg);
|
||||||
|
if (!amount_msat_to_sat(sat, msat))
|
||||||
|
return tal_fmt(NULL, "'%s' is not a whole number of sats", arg);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool opt_show_sat(char *buf, size_t len, const struct amount_sat *sat)
|
||||||
|
{
|
||||||
|
struct amount_msat msat;
|
||||||
|
if (!amount_sat_to_msat(&msat, *sat))
|
||||||
|
abort();
|
||||||
|
return opt_show_u64(buf, len,
|
||||||
|
&msat.millisatoshis); /* Raw: show sats number */
|
||||||
|
}
|
||||||
|
|
||||||
static char *opt_set_wumbo(struct lightningd *ld)
|
static char *opt_set_wumbo(struct lightningd *ld)
|
||||||
{
|
{
|
||||||
feature_set_or(ld->our_features,
|
feature_set_or(ld->our_features,
|
||||||
|
@ -1427,6 +1446,9 @@ static void register_opts(struct lightningd *ld)
|
||||||
clnopt_witharg("--commit-fee", OPT_SHOWINT,
|
clnopt_witharg("--commit-fee", OPT_SHOWINT,
|
||||||
opt_set_u64, opt_show_u64, &ld->config.commit_fee_percent,
|
opt_set_u64, opt_show_u64, &ld->config.commit_fee_percent,
|
||||||
"Percentage of fee to request for their commitment");
|
"Percentage of fee to request for their commitment");
|
||||||
|
clnopt_witharg("--min-emergency-msat", OPT_SHOWMSATS,
|
||||||
|
opt_set_sat, opt_show_sat, &ld->emergency_sat,
|
||||||
|
"Amount to leave in wallet for spending anchor closes");
|
||||||
clnopt_witharg("--subdaemon",
|
clnopt_witharg("--subdaemon",
|
||||||
OPT_MULTI,
|
OPT_MULTI,
|
||||||
opt_subdaemon, NULL,
|
opt_subdaemon, NULL,
|
||||||
|
|
Loading…
Add table
Reference in a new issue