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:
Rusty Russell
2023-06-29 09:44:09 +09:30
parent 2f0e13e793
commit 75aca3cbb6
6 changed files with 50 additions and 1 deletions

View File

@@ -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 */
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;
}