mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 23:54:22 +01:00
lightningd: use lowball feerate for commit_tx on anchor channels.
Since we can CPFP, we don't have to track the feerate as closely. But it still needs to get in the mempool, so we use 10 sat/byte, or the 100 block estimate if that is higher. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: JSON-RPC: `feerates` has new fields `unilateral_anchor_close` to show the feerate used for anchor channels (currently experimental), and `unilateral_close_nonanchor_satoshis`. Changelog-Changed: JSON-RPC: `feerates` `unilateral_close_satoshis` now assumes anchor channels if enabled (currently experimental).
This commit is contained in:
15
.msggen.json
15
.msggen.json
@@ -587,6 +587,7 @@
|
||||
"Feerates.onchain_fee_estimates.htlc_timeout_satoshis": 4,
|
||||
"Feerates.onchain_fee_estimates.mutual_close_satoshis": 2,
|
||||
"Feerates.onchain_fee_estimates.opening_channel_satoshis": 1,
|
||||
"Feerates.onchain_fee_estimates.unilateral_close_nonanchor_satoshis": 6,
|
||||
"Feerates.onchain_fee_estimates.unilateral_close_satoshis": 3
|
||||
},
|
||||
"FeeratesPerkb": {
|
||||
@@ -599,6 +600,7 @@
|
||||
"Feerates.perkb.mutual_close": 4,
|
||||
"Feerates.perkb.opening": 3,
|
||||
"Feerates.perkb.penalty": 8,
|
||||
"Feerates.perkb.unilateral_anchor_close": 11,
|
||||
"Feerates.perkb.unilateral_close": 5
|
||||
},
|
||||
"FeeratesPerkbEstimates": {
|
||||
@@ -616,6 +618,7 @@
|
||||
"Feerates.perkw.mutual_close": 4,
|
||||
"Feerates.perkw.opening": 3,
|
||||
"Feerates.perkw.penalty": 8,
|
||||
"Feerates.perkw.unilateral_anchor_close": 11,
|
||||
"Feerates.perkw.unilateral_close": 5
|
||||
},
|
||||
"FeeratesPerkwEstimates": {
|
||||
@@ -2533,6 +2536,10 @@
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
},
|
||||
"Feerates.onchain_fee_estimates.unilateral_close_nonanchor_satoshis": {
|
||||
"added": "v23.08",
|
||||
"deprecated": false
|
||||
},
|
||||
"Feerates.onchain_fee_estimates.unilateral_close_satoshis": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
@@ -2589,6 +2596,10 @@
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
},
|
||||
"Feerates.perkb.unilateral_anchor_close": {
|
||||
"added": "v23.08",
|
||||
"deprecated": false
|
||||
},
|
||||
"Feerates.perkb.unilateral_close": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
@@ -2645,6 +2656,10 @@
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
},
|
||||
"Feerates.perkw.unilateral_anchor_close": {
|
||||
"added": "v23.08",
|
||||
"deprecated": false
|
||||
},
|
||||
"Feerates.perkw.unilateral_close": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
|
||||
3
cln-grpc/proto/node.proto
generated
3
cln-grpc/proto/node.proto
generated
@@ -1435,6 +1435,7 @@ message FeeratesPerkb {
|
||||
optional uint32 opening = 3;
|
||||
optional uint32 mutual_close = 4;
|
||||
optional uint32 unilateral_close = 5;
|
||||
optional uint32 unilateral_anchor_close = 11;
|
||||
optional uint32 delayed_to_us = 6;
|
||||
optional uint32 htlc_resolution = 7;
|
||||
optional uint32 penalty = 8;
|
||||
@@ -1454,6 +1455,7 @@ message FeeratesPerkw {
|
||||
optional uint32 opening = 3;
|
||||
optional uint32 mutual_close = 4;
|
||||
optional uint32 unilateral_close = 5;
|
||||
optional uint32 unilateral_anchor_close = 11;
|
||||
optional uint32 delayed_to_us = 6;
|
||||
optional uint32 htlc_resolution = 7;
|
||||
optional uint32 penalty = 8;
|
||||
@@ -1469,6 +1471,7 @@ message FeeratesOnchain_fee_estimates {
|
||||
uint64 opening_channel_satoshis = 1;
|
||||
uint64 mutual_close_satoshis = 2;
|
||||
uint64 unilateral_close_satoshis = 3;
|
||||
optional uint64 unilateral_close_nonanchor_satoshis = 6;
|
||||
uint64 htlc_timeout_satoshis = 4;
|
||||
uint64 htlc_success_satoshis = 5;
|
||||
}
|
||||
|
||||
3
cln-grpc/src/convert.rs
generated
3
cln-grpc/src/convert.rs
generated
@@ -1327,6 +1327,7 @@ impl From<responses::FeeratesPerkb> for pb::FeeratesPerkb {
|
||||
opening: c.opening, // Rule #2 for type u32?
|
||||
mutual_close: c.mutual_close, // Rule #2 for type u32?
|
||||
unilateral_close: c.unilateral_close, // Rule #2 for type u32?
|
||||
unilateral_anchor_close: c.unilateral_anchor_close, // Rule #2 for type u32?
|
||||
#[allow(deprecated)]
|
||||
delayed_to_us: c.delayed_to_us, // Rule #2 for type u32?
|
||||
#[allow(deprecated)]
|
||||
@@ -1359,6 +1360,7 @@ impl From<responses::FeeratesPerkw> for pb::FeeratesPerkw {
|
||||
opening: c.opening, // Rule #2 for type u32?
|
||||
mutual_close: c.mutual_close, // Rule #2 for type u32?
|
||||
unilateral_close: c.unilateral_close, // Rule #2 for type u32?
|
||||
unilateral_anchor_close: c.unilateral_anchor_close, // Rule #2 for type u32?
|
||||
#[allow(deprecated)]
|
||||
delayed_to_us: c.delayed_to_us, // Rule #2 for type u32?
|
||||
#[allow(deprecated)]
|
||||
@@ -1375,6 +1377,7 @@ impl From<responses::FeeratesOnchain_fee_estimates> for pb::FeeratesOnchainFeeEs
|
||||
opening_channel_satoshis: c.opening_channel_satoshis, // Rule #2 for type u64
|
||||
mutual_close_satoshis: c.mutual_close_satoshis, // Rule #2 for type u64
|
||||
unilateral_close_satoshis: c.unilateral_close_satoshis, // Rule #2 for type u64
|
||||
unilateral_close_nonanchor_satoshis: c.unilateral_close_nonanchor_satoshis, // Rule #2 for type u64?
|
||||
htlc_timeout_satoshis: c.htlc_timeout_satoshis, // Rule #2 for type u64
|
||||
htlc_success_satoshis: c.htlc_success_satoshis, // Rule #2 for type u64
|
||||
}
|
||||
|
||||
6
cln-rpc/src/model.rs
generated
6
cln-rpc/src/model.rs
generated
@@ -3875,6 +3875,8 @@ pub mod responses {
|
||||
pub mutual_close: Option<u32>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub unilateral_close: Option<u32>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub unilateral_anchor_close: Option<u32>,
|
||||
#[deprecated]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub delayed_to_us: Option<u32>,
|
||||
@@ -3909,6 +3911,8 @@ pub mod responses {
|
||||
pub mutual_close: Option<u32>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub unilateral_close: Option<u32>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub unilateral_anchor_close: Option<u32>,
|
||||
#[deprecated]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub delayed_to_us: Option<u32>,
|
||||
@@ -3924,6 +3928,8 @@ pub mod responses {
|
||||
pub opening_channel_satoshis: u64,
|
||||
pub mutual_close_satoshis: u64,
|
||||
pub unilateral_close_satoshis: u64,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub unilateral_close_nonanchor_satoshis: Option<u64>,
|
||||
pub htlc_timeout_satoshis: u64,
|
||||
pub htlc_success_satoshis: u64,
|
||||
}
|
||||
|
||||
@@ -1157,6 +1157,7 @@ def feerates_perkb2py(m):
|
||||
"opening": m.opening, # PrimitiveField in generate_composite
|
||||
"mutual_close": m.mutual_close, # PrimitiveField in generate_composite
|
||||
"unilateral_close": m.unilateral_close, # PrimitiveField in generate_composite
|
||||
"unilateral_anchor_close": m.unilateral_anchor_close, # PrimitiveField in generate_composite
|
||||
"delayed_to_us": m.delayed_to_us, # PrimitiveField in generate_composite
|
||||
"htlc_resolution": m.htlc_resolution, # PrimitiveField in generate_composite
|
||||
"penalty": m.penalty, # PrimitiveField in generate_composite
|
||||
@@ -1180,6 +1181,7 @@ def feerates_perkw2py(m):
|
||||
"opening": m.opening, # PrimitiveField in generate_composite
|
||||
"mutual_close": m.mutual_close, # PrimitiveField in generate_composite
|
||||
"unilateral_close": m.unilateral_close, # PrimitiveField in generate_composite
|
||||
"unilateral_anchor_close": m.unilateral_anchor_close, # PrimitiveField in generate_composite
|
||||
"delayed_to_us": m.delayed_to_us, # PrimitiveField in generate_composite
|
||||
"htlc_resolution": m.htlc_resolution, # PrimitiveField in generate_composite
|
||||
"penalty": m.penalty, # PrimitiveField in generate_composite
|
||||
@@ -1191,6 +1193,7 @@ def feerates_onchain_fee_estimates2py(m):
|
||||
"opening_channel_satoshis": m.opening_channel_satoshis, # PrimitiveField in generate_composite
|
||||
"mutual_close_satoshis": m.mutual_close_satoshis, # PrimitiveField in generate_composite
|
||||
"unilateral_close_satoshis": m.unilateral_close_satoshis, # PrimitiveField in generate_composite
|
||||
"unilateral_close_nonanchor_satoshis": m.unilateral_close_nonanchor_satoshis, # PrimitiveField in generate_composite
|
||||
"htlc_timeout_satoshis": m.htlc_timeout_satoshis, # PrimitiveField in generate_composite
|
||||
"htlc_success_satoshis": m.htlc_success_satoshis, # PrimitiveField in generate_composite
|
||||
})
|
||||
|
||||
160
contrib/pyln-testing/pyln/testing/node_pb2.py
generated
160
contrib/pyln-testing/pyln/testing/node_pb2.py
generated
File diff suppressed because one or more lines are too long
@@ -61,6 +61,7 @@ On success, an object is returned, containing:
|
||||
- **opening** (u32, optional): Default feerate for lightning-fundchannel(7) and lightning-withdraw(7)
|
||||
- **mutual\_close** (u32, optional): Feerate to aim for in cooperative shutdown. Note that since mutual close is a **negotiation**, the actual feerate used in mutual close will be somewhere between this and the corresponding mutual close feerate of the peer.
|
||||
- **unilateral\_close** (u32, optional): Feerate for commitment\_transaction in a live channel which we originally funded
|
||||
- **unilateral\_anchor\_close** (u32, optional): Feerate for commitment\_transaction in a live channel which we originally funded (if anchor\_outputs was negotiated) *(added v23.08)*
|
||||
- **delayed\_to\_us** (u32, optional): Feerate for returning unilateral close funds to our wallet **deprecated, removal in v24.02**
|
||||
- **htlc\_resolution** (u32, optional): Feerate for returning unilateral close HTLC outputs to our wallet **deprecated, removal in v24.02**
|
||||
- **penalty** (u32, optional): Feerate to use when creating penalty tx for watchtowers
|
||||
@@ -74,16 +75,18 @@ On success, an object is returned, containing:
|
||||
- **smoothed\_feerate** (u32): The feerate, smoothed over time (useful for coordinating with other nodes) *(added v23.05)*
|
||||
- **opening** (u32, optional): Default feerate for lightning-fundchannel(7) and lightning-withdraw(7)
|
||||
- **mutual\_close** (u32, optional): Feerate to aim for in cooperative shutdown. Note that since mutual close is a **negotiation**, the actual feerate used in mutual close will be somewhere between this and the corresponding mutual close feerate of the peer.
|
||||
- **unilateral\_close** (u32, optional): Feerate for commitment\_transaction in a live channel which we originally funded
|
||||
- **unilateral\_close** (u32, optional): Feerate for commitment\_transaction in a live channel which we originally funded (if anchor\_outputs was not negotiated)
|
||||
- **unilateral\_anchor\_close** (u32, optional): Feerate for commitment\_transaction in a live channel which we originally funded (if anchor\_outputs was negotiated) *(added v23.08)*
|
||||
- **delayed\_to\_us** (u32, optional): Feerate for returning unilateral close funds to our wallet **deprecated, removal in v24.02**
|
||||
- **htlc\_resolution** (u32, optional): Feerate for returning unilateral close HTLC outputs to our wallet **deprecated, removal in v24.02**
|
||||
- **penalty** (u32, optional): Feerate to use when creating penalty tx for watchtowers
|
||||
- **onchain\_fee\_estimates** (object, optional):
|
||||
- **opening\_channel\_satoshis** (u64): Estimated cost of typical channel open
|
||||
- **mutual\_close\_satoshis** (u64): Estimated cost of typical channel close
|
||||
- **unilateral\_close\_satoshis** (u64): Estimated cost of typical (non-anchor) unilateral close (without HTLCs)
|
||||
- **unilateral\_close\_satoshis** (u64): Estimated cost of typical unilateral close (without HTLCs). If anchors are supported, this assumes a channel with anchors.
|
||||
- **htlc\_timeout\_satoshis** (u64): Estimated cost of typical HTLC timeout transaction (non-anchors)
|
||||
- **htlc\_success\_satoshis** (u64): Estimated cost of typical HTLC fulfillment transaction (non-anchors)
|
||||
- **unilateral\_close\_nonanchor\_satoshis** (u64, optional): Estimated cost of non-anchor typical unilateral close (without HTLCs). *(added v23.08)*
|
||||
|
||||
The following warnings may also be returned:
|
||||
|
||||
@@ -141,4 +144,4 @@ RESOURCES
|
||||
|
||||
Main web site: <https://github.com/ElementsProject/lightning>
|
||||
|
||||
[comment]: # ( SHA256STAMP:195f8f4cc16197a62269ca1cda77e9d8788ff0c0c49a9d9d45067f6a578c22fd)
|
||||
[comment]: # ( SHA256STAMP:0c0d2c56d2a568e9330e14a053d27e5d2e84ef1f400cd1a6195a850ca8cc7ad6)
|
||||
|
||||
@@ -75,6 +75,11 @@
|
||||
"type": "u32",
|
||||
"description": "Feerate for commitment_transaction in a live channel which we originally funded"
|
||||
},
|
||||
"unilateral_anchor_close": {
|
||||
"type": "u32",
|
||||
"added": "v23.08",
|
||||
"description": "Feerate for commitment_transaction in a live channel which we originally funded (if anchor_outputs was negotiated)"
|
||||
},
|
||||
"delayed_to_us": {
|
||||
"type": "u32",
|
||||
"deprecated": "v23.05",
|
||||
@@ -156,7 +161,12 @@
|
||||
},
|
||||
"unilateral_close": {
|
||||
"type": "u32",
|
||||
"description": "Feerate for commitment_transaction in a live channel which we originally funded"
|
||||
"description": "Feerate for commitment_transaction in a live channel which we originally funded (if anchor_outputs was not negotiated)"
|
||||
},
|
||||
"unilateral_anchor_close": {
|
||||
"type": "u32",
|
||||
"added": "v23.08",
|
||||
"description": "Feerate for commitment_transaction in a live channel which we originally funded (if anchor_outputs was negotiated)"
|
||||
},
|
||||
"delayed_to_us": {
|
||||
"type": "u32",
|
||||
@@ -195,7 +205,12 @@
|
||||
},
|
||||
"unilateral_close_satoshis": {
|
||||
"type": "u64",
|
||||
"description": "Estimated cost of typical (non-anchor) unilateral close (without HTLCs)"
|
||||
"description": "Estimated cost of typical unilateral close (without HTLCs). If anchors are supported, this assumes a channel with anchors."
|
||||
},
|
||||
"unilateral_close_nonanchor_satoshis": {
|
||||
"added": "v23.08",
|
||||
"type": "u64",
|
||||
"description": "Estimated cost of non-anchor typical unilateral close (without HTLCs)."
|
||||
},
|
||||
"htlc_timeout_satoshis": {
|
||||
"type": "u64",
|
||||
|
||||
@@ -618,10 +618,22 @@ u32 mutual_close_feerate(struct chain_topology *topo)
|
||||
conversions[FEERATE_MUTUAL_CLOSE].blockcount);
|
||||
}
|
||||
|
||||
u32 unilateral_feerate(struct chain_topology *topo)
|
||||
u32 unilateral_feerate(struct chain_topology *topo, bool option_anchors)
|
||||
{
|
||||
if (topo->ld->force_feerates)
|
||||
return topo->ld->force_feerates[FEERATE_UNILATERAL_CLOSE];
|
||||
|
||||
if (option_anchors) {
|
||||
/* We can lowball fee, since we can CPFP with anchors */
|
||||
u32 feerate = feerate_for_deadline(topo, 100);
|
||||
if (!feerate)
|
||||
return 0; /* Don't know */
|
||||
/* We still need to get into the mempool, so use 5 sat/byte */
|
||||
if (feerate < 1250)
|
||||
return 1250;
|
||||
return feerate;
|
||||
}
|
||||
|
||||
return smoothed_feerate_for_deadline(topo,
|
||||
conversions[FEERATE_UNILATERAL_CLOSE].blockcount)
|
||||
* topo->ld->config.commit_fee_percent / 100;
|
||||
@@ -687,10 +699,14 @@ static struct command_result *json_feerates(struct command *cmd,
|
||||
if (rate)
|
||||
json_add_num(response, "mutual_close",
|
||||
feerate_to_style(rate, *style));
|
||||
rate = unilateral_feerate(topo);
|
||||
rate = unilateral_feerate(topo, false);
|
||||
if (rate)
|
||||
json_add_num(response, "unilateral_close",
|
||||
feerate_to_style(rate, *style));
|
||||
rate = unilateral_feerate(topo, true);
|
||||
if (rate)
|
||||
json_add_num(response, "unilateral_anchor_close",
|
||||
feerate_to_style(rate, *style));
|
||||
rate = penalty_feerate(topo);
|
||||
if (rate)
|
||||
json_add_num(response, "penalty",
|
||||
@@ -731,6 +747,11 @@ static struct command_result *json_feerates(struct command *cmd,
|
||||
json_object_end(response);
|
||||
|
||||
if (!missing) {
|
||||
/* It actually is negotiated per-channel... */
|
||||
bool anchor_outputs
|
||||
= feature_offered(cmd->ld->our_features->bits[INIT_FEATURE],
|
||||
OPT_ANCHOR_OUTPUTS);
|
||||
|
||||
json_object_start(response, "onchain_fee_estimates");
|
||||
/* eg 020000000001016f51de645a47baa49a636b8ec974c28bdff0ac9151c0f4eda2dbe3b41dbe711d000000001716001401fad90abcd66697e2592164722de4a95ebee165ffffffff0240420f00000000002200205b8cd3b914cf67cdd8fa6273c930353dd36476734fbd962102c2df53b90880cdb73f890000000000160014c2ccab171c2a5be9dab52ec41b825863024c54660248304502210088f65e054dbc2d8f679de3e40150069854863efa4a45103b2bb63d060322f94702200d3ae8923924a458cffb0b7360179790830027bb6b29715ba03e12fc22365de1012103d745445c9362665f22e0d96e9e766f273f3260dea39c8a76bfa05dd2684ddccf00000000 == weight 702 */
|
||||
json_add_num(response, "opening_channel_satoshis",
|
||||
@@ -739,8 +760,16 @@ static struct command_result *json_feerates(struct command *cmd,
|
||||
json_add_u64(response, "mutual_close_satoshis",
|
||||
mutual_close_feerate(cmd->ld->topology) * 673 / 1000);
|
||||
/* eg. 02000000000101c4fecaae1ea940c15ec502de732c4c386d51f981317605bbe5ad2c59165690ab00000000009db0e280010a2d0f00000000002200208d290003cedb0dd00cd5004c2d565d55fc70227bf5711186f4fa9392f8f32b4a0400483045022100952fcf8c730c91cf66bcb742cd52f046c0db3694dc461e7599be330a22466d790220740738a6f9d9e1ae5c86452fa07b0d8dddc90f8bee4ded24a88fe4b7400089eb01483045022100db3002a93390fc15c193da57d6ce1020e82705e760a3aa935ebe864bd66dd8e8022062ee9c6aa7b88ff4580e2671900a339754116371d8f40eba15b798136a76cd150147522102324266de8403b3ab157a09f1f784d587af61831c998c151bcc21bb74c2b2314b2102e3bd38009866c9da8ec4aa99cc4ea9c6c0dd46df15c61ef0ce1f271291714e5752ae9a3ed620 == weight 598 */
|
||||
/* Or, with anchors:
|
||||
* 02000000000101dc824e8e880f90f397a74f89022b4d58f8c36ebc4fffc238bd525bd11f5002a501000000009db0e280044a010000000000002200200e1a08b3da3bea6a7a77315f95afcd589fe799af46cf9bfb89523172814050e44a01000000000000220020be7935a77ca9ab70a4b8b1906825637767fed3c00824aa90c988983587d6848878e001000000000022002009fa3082e61ca0bd627915b53b0cb8afa467248fa4dc95141f78b96e9c98a8ed245a0d000000000022002091fb9e7843a03e66b4b1173482a0eb394f03a35aae4c28e8b4b1f575696bd793040047304402205c2ea9cf6f670e2f454c054f9aaca2d248763e258e44c71675c06135fd8f36cb02201b564f0e1b3f1ea19342f26e978a4981675da23042b4d392737636738c3514da0147304402205fcd2af5b724cbbf71dfa07bd14e8018ce22c08a019976dc03d0f545f848d0a702203652200350cadb464a70a09829d09227ed3da8c6b8ef5e3a59b5eefd056deaae0147522102324266de8403b3ab157a09f1f784d587af61831c998c151bcc21bb74c2b2314b2102e3bd38009866c9da8ec4aa99cc4ea9c6c0dd46df15c61ef0ce1f271291714e5752ae9b3ed620 1112 */
|
||||
if (anchor_outputs)
|
||||
json_add_u64(response, "unilateral_close_satoshis",
|
||||
unilateral_feerate(cmd->ld->topology) * 598 / 1000);
|
||||
unilateral_feerate(cmd->ld->topology, true) * 1112 / 1000);
|
||||
else
|
||||
json_add_u64(response, "unilateral_close_satoshis",
|
||||
unilateral_feerate(cmd->ld->topology, false) * 598 / 1000);
|
||||
json_add_u64(response, "unilateral_close_nonanchor_satoshis",
|
||||
unilateral_feerate(cmd->ld->topology, false) * 598 / 1000);
|
||||
|
||||
json_add_u64(response, "htlc_timeout_satoshis",
|
||||
htlc_timeout_fee(htlc_resolution_feerate(cmd->ld->topology),
|
||||
|
||||
@@ -194,7 +194,7 @@ u32 feerate_max(struct lightningd *ld, bool *unknown);
|
||||
/* These return 0 if unknown */
|
||||
u32 opening_feerate(struct chain_topology *topo);
|
||||
u32 mutual_close_feerate(struct chain_topology *topo);
|
||||
u32 unilateral_feerate(struct chain_topology *topo);
|
||||
u32 unilateral_feerate(struct chain_topology *topo, bool option_anchors);
|
||||
/* For onchain resolution. */
|
||||
u32 delayed_to_us_feerate(struct chain_topology *topo);
|
||||
u32 htlc_resolution_feerate(struct chain_topology *topo);
|
||||
|
||||
@@ -27,7 +27,9 @@
|
||||
static void update_feerates(struct lightningd *ld, struct channel *channel)
|
||||
{
|
||||
u8 *msg;
|
||||
u32 feerate = unilateral_feerate(ld->topology);
|
||||
u32 feerate = unilateral_feerate(ld->topology,
|
||||
channel_has(channel,
|
||||
OPT_ANCHOR_OUTPUTS));
|
||||
|
||||
/* Nothing to do if we don't know feerate. */
|
||||
if (!feerate)
|
||||
|
||||
@@ -418,7 +418,7 @@ void peer_start_closingd(struct channel *channel, struct peer_fd *peer_fd)
|
||||
if (option_anchor_outputs) {
|
||||
max_feerate = tal(tmpctx, u32);
|
||||
/* Aim for reasonable max, but use final if we don't know. */
|
||||
*max_feerate = unilateral_feerate(ld->topology);
|
||||
*max_feerate = unilateral_feerate(ld->topology, false);
|
||||
if (!*max_feerate)
|
||||
*max_feerate = final_commit_feerate;
|
||||
/* No other limit on fees */
|
||||
|
||||
@@ -68,7 +68,11 @@ static struct command_result *param_feerate_unchecked(struct command *cmd,
|
||||
return NULL;
|
||||
}
|
||||
if (json_tok_streq(buffer, tok, "unilateral_close")) {
|
||||
**feerate = unilateral_feerate(cmd->ld->topology);
|
||||
**feerate = unilateral_feerate(cmd->ld->topology, false);
|
||||
return NULL;
|
||||
}
|
||||
if (json_tok_streq(buffer, tok, "unilateral_anchor_close")) {
|
||||
**feerate = unilateral_feerate(cmd->ld->topology, true);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id U
|
||||
void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED)
|
||||
{ fprintf(stderr, "towire_node_id called!\n"); abort(); }
|
||||
/* Generated stub for unilateral_feerate */
|
||||
u32 unilateral_feerate(struct chain_topology *topo UNNEEDED)
|
||||
u32 unilateral_feerate(struct chain_topology *topo UNNEEDED, bool option_anchors UNNEEDED)
|
||||
{ fprintf(stderr, "unilateral_feerate called!\n"); abort(); }
|
||||
/* AUTOGENERATED MOCKS END */
|
||||
|
||||
|
||||
@@ -1628,10 +1628,14 @@ def test_feerates(node_factory):
|
||||
'feerate': 5000,
|
||||
'smoothed_feerate': 5000}]
|
||||
|
||||
assert len(feerates['onchain_fee_estimates']) == 5
|
||||
assert len(feerates['onchain_fee_estimates']) == 6
|
||||
assert feerates['onchain_fee_estimates']['opening_channel_satoshis'] == feerates['perkw']['opening'] * 702 // 1000
|
||||
assert feerates['onchain_fee_estimates']['mutual_close_satoshis'] == feerates['perkw']['mutual_close'] * 673 // 1000
|
||||
if anchor_expected():
|
||||
assert feerates['onchain_fee_estimates']['unilateral_close_satoshis'] == feerates['perkw']['unilateral_anchor_close'] * 1112 // 1000
|
||||
else:
|
||||
assert feerates['onchain_fee_estimates']['unilateral_close_satoshis'] == feerates['perkw']['unilateral_close'] * 598 // 1000
|
||||
assert feerates['onchain_fee_estimates']['unilateral_close_nonanchor_satoshis'] == feerates['perkw']['unilateral_close'] * 598 // 1000
|
||||
# htlc resolution currently uses 6 block estimate
|
||||
htlc_feerate = [f['feerate'] for f in feerates['perkw']['estimates'] if f['blockcount'] == 6][0]
|
||||
htlc_timeout_cost = feerates["onchain_fee_estimates"]["htlc_timeout_satoshis"]
|
||||
@@ -1959,6 +1963,7 @@ def test_bitcoind_feerate_floor(node_factory, bitcoind):
|
||||
"opening": 30000,
|
||||
"mutual_close": 15000,
|
||||
"unilateral_close": 44000,
|
||||
'unilateral_anchor_close': 15000,
|
||||
"penalty": 30000,
|
||||
"min_acceptable": 7500,
|
||||
"max_acceptable": 600000,
|
||||
@@ -1979,7 +1984,8 @@ def test_bitcoind_feerate_floor(node_factory, bitcoind):
|
||||
"onchain_fee_estimates": {
|
||||
"opening_channel_satoshis": 5265,
|
||||
"mutual_close_satoshis": 2523,
|
||||
"unilateral_close_satoshis": 6578,
|
||||
"unilateral_close_satoshis": 4170 if anchors else 6578,
|
||||
"unilateral_close_nonanchor_satoshis": 6578,
|
||||
"htlc_timeout_satoshis": 7326 if anchors else 7293,
|
||||
"htlc_success_satoshis": 7766 if anchors else 7733,
|
||||
}
|
||||
@@ -1996,6 +2002,9 @@ def test_bitcoind_feerate_floor(node_factory, bitcoind):
|
||||
"opening": 30000,
|
||||
# This has increased (rounded up)
|
||||
"mutual_close": 20004,
|
||||
# This has increased (rounded up)
|
||||
"unilateral_anchor_close": 20004,
|
||||
# This has increased (rounded up)
|
||||
"unilateral_close": 44000,
|
||||
"penalty": 30000,
|
||||
# This has increased (rounded up)
|
||||
@@ -2019,7 +2028,8 @@ def test_bitcoind_feerate_floor(node_factory, bitcoind):
|
||||
"opening_channel_satoshis": 5265,
|
||||
# This increases too
|
||||
"mutual_close_satoshis": 3365,
|
||||
"unilateral_close_satoshis": 6578,
|
||||
"unilateral_close_satoshis": 5561 if anchors else 6578,
|
||||
"unilateral_close_nonanchor_satoshis": 6578,
|
||||
"htlc_timeout_satoshis": 7326 if anchors else 7293,
|
||||
"htlc_success_satoshis": 7766 if anchors else 7733,
|
||||
}
|
||||
@@ -2037,6 +2047,8 @@ def test_bitcoind_feerate_floor(node_factory, bitcoind):
|
||||
"opening": 30004,
|
||||
# This has increased (rounded up!)
|
||||
"mutual_close": 30004,
|
||||
# This has increased (rounded up!)
|
||||
"unilateral_anchor_close": 30004,
|
||||
"unilateral_close": 44000,
|
||||
# This has increased (rounded up!)
|
||||
"penalty": 30004,
|
||||
@@ -2063,7 +2075,9 @@ def test_bitcoind_feerate_floor(node_factory, bitcoind):
|
||||
"opening_channel_satoshis": 5265,
|
||||
# This increases too
|
||||
"mutual_close_satoshis": 5048,
|
||||
"unilateral_close_satoshis": 6578,
|
||||
# This increases too (anchors uses min(100blocks,5 sat/vB))
|
||||
"unilateral_close_satoshis": 8341 if anchors else 6578,
|
||||
"unilateral_close_nonanchor_satoshis": 6578,
|
||||
"htlc_timeout_satoshis": 7326 if anchors else 7293,
|
||||
"htlc_success_satoshis": 7766 if anchors else 7733,
|
||||
}
|
||||
@@ -2989,6 +3003,7 @@ def test_force_feerates(node_factory):
|
||||
"opening": 1111,
|
||||
"mutual_close": 1111,
|
||||
"unilateral_close": 1111,
|
||||
"unilateral_anchor_close": 1111,
|
||||
"penalty": 1111,
|
||||
"min_acceptable": 1875,
|
||||
"max_acceptable": 150000,
|
||||
@@ -3004,6 +3019,7 @@ def test_force_feerates(node_factory):
|
||||
"opening": 1111,
|
||||
"mutual_close": 2222,
|
||||
"unilateral_close": 2222,
|
||||
"unilateral_anchor_close": 2222,
|
||||
"penalty": 2222,
|
||||
"min_acceptable": 1875,
|
||||
"max_acceptable": 150000,
|
||||
@@ -3019,6 +3035,7 @@ def test_force_feerates(node_factory):
|
||||
"opening": 1111,
|
||||
"mutual_close": 2222,
|
||||
"unilateral_close": 3333,
|
||||
"unilateral_anchor_close": 3333,
|
||||
"penalty": 6666,
|
||||
"min_acceptable": 1875,
|
||||
"max_acceptable": 150000,
|
||||
|
||||
Reference in New Issue
Block a user