Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore fees per channel #6398

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion .msggen.json
Expand Up @@ -1002,6 +1002,7 @@
"ListPeerChannels.channels[].funding_outnum": 11,
"ListPeerChannels.channels[].funding_txid": 10,
"ListPeerChannels.channels[].htlcs[]": 52,
"ListPeerChannels.channels[].ignore_fee_limits": 54,
"ListPeerChannels.channels[].in_fulfilled_msat": 47,
"ListPeerChannels.channels[].in_offered_msat": 45,
"ListPeerChannels.channels[].in_payments_fulfilled": 46,
Expand Down Expand Up @@ -1401,6 +1402,7 @@
"SetChannel.channels[].channel_id": 2,
"SetChannel.channels[].fee_base_msat": 4,
"SetChannel.channels[].fee_proportional_millionths": 5,
"SetChannel.channels[].ignore_fee_limits": 10,
"SetChannel.channels[].maximum_htlc_out_msat": 8,
"SetChannel.channels[].minimum_htlc_out_msat": 6,
"SetChannel.channels[].peer_id": 1,
Expand All @@ -1414,7 +1416,8 @@
"SetChannel.feeppm": 3,
"SetChannel.htlcmax": 5,
"SetChannel.htlcmin": 4,
"SetChannel.id": 1
"SetChannel.id": 1,
"SetChannel.ignorefeelimits": 7
},
"SetchannelResponse": {
"SetChannel.channels[]": 1
Expand Down Expand Up @@ -3881,6 +3884,10 @@
"added": "v23.02",
"deprecated": false
},
"ListPeerChannels.channels[].ignore_fee_limits": {
"added": "v23.08",
"deprecated": false
},
"ListPeerChannels.channels[].in_fulfilled_msat": {
"added": "v23.02",
"deprecated": false
Expand Down Expand Up @@ -5013,6 +5020,10 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"SetChannel.channels[].ignore_fee_limits": {
"added": "v23.08",
"deprecated": false
},
"SetChannel.channels[].maximum_htlc_out_msat": {
"added": "pre-v0.10.1",
"deprecated": false
Expand Down Expand Up @@ -5061,6 +5072,10 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"SetChannel.ignorefeelimits": {
"added": "v23.08",
"deprecated": false
},
"SignInvoice": {
"added": "v23.02",
"deprecated": null
Expand Down
3 changes: 3 additions & 0 deletions cln-grpc/proto/node.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions cln-grpc/src/convert.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions cln-rpc/src/model.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion contrib/pyln-client/pyln/client/lightning.py
Expand Up @@ -1321,7 +1321,7 @@ def sendonion(
}
return self.call("sendonion", payload)

def setchannel(self, id, feebase=None, feeppm=None, htlcmin=None, htlcmax=None, enforcedelay=None):
def setchannel(self, id, feebase=None, feeppm=None, htlcmin=None, htlcmax=None, enforcedelay=None, ignorefeelimits=None):
"""Set configuration a channel/peer {id} (or 'all').

{feebase} is a value in millisatoshi that is added as base fee
Expand All @@ -1339,6 +1339,8 @@ def setchannel(self, id, feebase=None, feeppm=None, htlcmin=None, htlcmax=None,
{enforcedelay} is the number of seconds before enforcing this
change.

{ignorefeelimits} is a flag to indicate peer can set any feerate (dangerous!)

"""
payload = {
"id": id,
Expand All @@ -1347,6 +1349,7 @@ def setchannel(self, id, feebase=None, feeppm=None, htlcmin=None, htlcmax=None,
"htlcmin": htlcmin,
"htlcmax": htlcmax,
"enforcedelay": enforcedelay,
"ignorefeelimits": ignorefeelimits,
}
return self.call("setchannel", payload)

Expand Down
292 changes: 146 additions & 146 deletions contrib/pyln-grpc-proto/pyln/grpc/node_pb2.py

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions contrib/pyln-testing/pyln/testing/grpc2py.py
Expand Up @@ -790,6 +790,7 @@ def listpeerchannels_channels2py(m):
"peer_connected": m.peer_connected, # PrimitiveField in generate_composite
"state": str(m.state), # EnumField in generate_composite
"scratch_txid": hexlify(m.scratch_txid), # PrimitiveField in generate_composite
"ignore_fee_limits": m.ignore_fee_limits, # PrimitiveField in generate_composite
"owner": m.owner, # PrimitiveField in generate_composite
"short_channel_id": m.short_channel_id, # PrimitiveField in generate_composite
"channel_id": hexlify(m.channel_id), # PrimitiveField in generate_composite
Expand Down Expand Up @@ -1297,6 +1298,7 @@ def setchannel_channels2py(m):
"short_channel_id": m.short_channel_id, # PrimitiveField in generate_composite
"fee_base_msat": amount2msat(m.fee_base_msat), # PrimitiveField in generate_composite
"fee_proportional_millionths": m.fee_proportional_millionths, # PrimitiveField in generate_composite
"ignore_fee_limits": m.ignore_fee_limits, # PrimitiveField in generate_composite
"minimum_htlc_out_msat": amount2msat(m.minimum_htlc_out_msat), # PrimitiveField in generate_composite
"warning_htlcmin_too_low": m.warning_htlcmin_too_low, # PrimitiveField in generate_composite
"maximum_htlc_out_msat": amount2msat(m.maximum_htlc_out_msat), # PrimitiveField in generate_composite
Expand Down
3 changes: 2 additions & 1 deletion doc/lightning-listpeerchannels.7.md
Expand Up @@ -36,6 +36,7 @@ On success, an object containing **channels** is returned. It is an array of ob
- Bit number
- **names** (array of strings): Feature name for each bit set in this channel\_type:
- Name of feature bit (one of "static\_remotekey/even", "anchor\_outputs/even", "anchors\_zero\_fee\_htlc\_tx/even", "scid\_alias/even", "zeroconf/even")
- **ignore\_fee\_limits** (boolean, optional): set if we allow this peer to set fees to anything they want *(added v23.08)*
- **feerate** (object, optional): Feerates for the current tx:
- **perkw** (u32): Feerate per 1000 weight (i.e kSipa)
- **perkb** (u32): Feerate per 1000 virtual bytes
Expand Down Expand Up @@ -194,4 +195,4 @@ Main web site: <https://github.com/ElementsProject/lightning> Lightning
RFC site (BOLT \#9):
<https://github.com/lightningnetwork/lightning-rfc/blob/master/09-features.md>

[comment]: # ( SHA256STAMP:f5103dae3b20a7d2a4112a368e753f1dd0518a269bd34c2fd17657c9f90596d7)
[comment]: # ( SHA256STAMP:c530e39c9144b5fbef0f6474170865095bd7b4c48e6378fdb7f9a7697b909473)
12 changes: 10 additions & 2 deletions doc/lightning-setchannel.7.md
Expand Up @@ -4,7 +4,7 @@ lightning-setchannel -- Command for configuring fees / htlc range advertized for
SYNOPSIS
--------

**setchannel** *id* [*feebase*] [*feeppm*] [*htlcmin*] [*htlcmax*] [*enforcedelay*]
**setchannel** *id* [*feebase*] [*feeppm*] [*htlcmin*] [*htlcmax*] [*enforcedelay*] [*ignorefeelimits*]

DESCRIPTION
-----------
Expand Down Expand Up @@ -62,6 +62,13 @@ only applied to a single rate increase per channel (we don't remember
an arbitrary number of prior feerates) and if the node is restarted
the updated configuration is enforced immediately.

*ignorefeelimits* set to True means to allow the peer to set the commitment
transaction fees (or closing transaction fees) to any value they want. This is dangerous: they could
set an exorbitant fee (so HTLCs are unenforcable), or a tiny fee (so that
commitment transactions cannot be relayed), but avoids channel breakage
in case of feerate disagreements. (Note: the global `ignore_fee_limits`
setting overrides this).

RETURN VALUE
------------

Expand All @@ -72,6 +79,7 @@ On success, an object containing **channels** is returned. It is an array of ob
- **channel\_id** (hex): The channel\_id of the channel (always 64 characters)
- **fee\_base\_msat** (msat): The resulting feebase (this is the BOLT #7 name)
- **fee\_proportional\_millionths** (u32): The resulting feeppm (this is the BOLT #7 name)
- **ignore\_fee\_limits** (boolean): If we are now allowing peer to set feerate on commitment transaction without restriction *(added v23.08)*
- **minimum\_htlc\_out\_msat** (msat): The resulting htlcmin we will advertize (the BOLT #7 name is htlc\_minimum\_msat)
- **maximum\_htlc\_out\_msat** (msat): The resulting htlcmax we will advertize (the BOLT #7 name is htlc\_maximum\_msat)
- **short\_channel\_id** (short\_channel\_id, optional): the short\_channel\_id (if locked in)
Expand Down Expand Up @@ -107,4 +115,4 @@ RESOURCES

Main web site: <https://github.com/ElementsProject/lightning>

[comment]: # ( SHA256STAMP:0175aaf74aa6d75640d0b79f68b552b1b700f93ad7576465c73de93af04d71e6)
[comment]: # ( SHA256STAMP:5209ba4d4bbe2d897d9824f95a97fa48d968e83ffec2e4cfbd87df6fd90c48f0)
3 changes: 2 additions & 1 deletion doc/lightning-sql.7.md
Expand Up @@ -250,6 +250,7 @@ The following tables are currently supported:
- `row` (reference to `peerchannels_channel_type.rowid`, sqltype `INTEGER`)
- `arrindex` (index within array, sqltype `INTEGER`)
- `names` (type `string`, sqltype `TEXT`)
- `ignore_fee_limits` (type `boolean`, sqltype `INTEGER`)
- `feerate_perkw` (type `u32`, sqltype `INTEGER`, from JSON object `feerate`)
- `feerate_perkb` (type `u32`, sqltype `INTEGER`, from JSON object `feerate`)
- `owner` (type `string`, sqltype `TEXT`)
Expand Down Expand Up @@ -510,4 +511,4 @@ RESOURCES
---------

Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:68c72c66bdc8b0515c6d5dddd5ffd14aa0342bd00f17a44929177c48c36a213f)
[comment]: # ( SHA256STAMP:4cfeeb2855f92a12d6a52d912a58df7573fc34f1f17a190bba26e46695f54de6)
3 changes: 2 additions & 1 deletion doc/lightningd-config.5.md
Expand Up @@ -332,7 +332,8 @@ falls below this.
Allow nodes which establish channels to us to set any fee they want.
This may result in a channel which cannot be closed, should fees
increase, but make channels far more reliable since we never close it
due to unreasonable fees.
due to unreasonable fees. Note that this can be set on a per-channel
basis with lightning-setchannel(7).

* **commit-time**=*MILLISECONDS*

Expand Down
9 changes: 9 additions & 0 deletions doc/schemas/listpeerchannels.schema.json
Expand Up @@ -84,6 +84,11 @@
}
}
},
"ignore_fee_limits": {
"type": "boolean",
"added": "v23.08",
"description": "set if we allow this peer to set fees to anything they want"
},
"feerate": {
"type": "object",
"description": "Feerates for the current tx",
Expand Down Expand Up @@ -609,6 +614,7 @@
"scratch_txid": {},
"channel_type": {},
"feerate": {},
"ignore_fee_limits": {},
"owner": {},
"short_channel_id": {},
"channel_id": {},
Expand Down Expand Up @@ -699,6 +705,7 @@
"scratch_txid": {},
"channel_type": {},
"feerate": {},
"ignore_fee_limits": {},
"owner": {},
"short_channel_id": {},
"channel_id": {},
Expand Down Expand Up @@ -788,6 +795,7 @@
"scratch_txid": {},
"channel_type": {},
"feerate": {},
"ignore_fee_limits": {},
"owner": {},
"short_channel_id": {},
"channel_id": {},
Expand Down Expand Up @@ -878,6 +886,7 @@
"scratch_txid": {},
"channel_type": {},
"feerate": {},
"ignore_fee_limits": {},
"owner": {},
"alias": {},
"short_channel_id": {},
Expand Down
4 changes: 4 additions & 0 deletions doc/schemas/setchannel.request.json
Expand Up @@ -23,6 +23,10 @@
},
"enforcedelay": {
"type": "u32"
},
"ignorefeelimits": {
"added": "v23.08",
"type": "boolean"
}
}
}
8 changes: 7 additions & 1 deletion doc/schemas/setchannel.schema.json
Expand Up @@ -18,7 +18,8 @@
"fee_base_msat",
"fee_proportional_millionths",
"minimum_htlc_out_msat",
"maximum_htlc_out_msat"
"maximum_htlc_out_msat",
"ignore_fee_limits"
],
"properties": {
"peer_id": {
Expand All @@ -43,6 +44,11 @@
"type": "u32",
"description": "The resulting feeppm (this is the BOLT #7 name)"
},
"ignore_fee_limits": {
"type": "boolean",
"added": "v23.08",
"description": "If we are now allowing peer to set feerate on commitment transaction without restriction"
},
"minimum_htlc_out_msat": {
"type": "msat",
"description": "The resulting htlcmin we will advertize (the BOLT #7 name is htlc_minimum_msat)"
Expand Down
40 changes: 16 additions & 24 deletions lightningd/chaintopology.c
Expand Up @@ -1142,30 +1142,25 @@ u32 feerate_min(struct lightningd *ld, bool *unknown)
*
* [1] https://github.com/ElementsProject/lightning/issues/6362
* */
if (ld->config.ignore_fee_limits)
min = 1;
else {
min = 0xFFFFFFFF;
for (size_t i = 0; i < ARRAY_SIZE(topo->feerates); i++) {
for (size_t j = 0; j < tal_count(topo->feerates[i]); j++) {
if (topo->feerates[i][j].rate < min)
min = topo->feerates[i][j].rate;
}
}
if (min == 0xFFFFFFFF) {
if (unknown)
*unknown = true;
min = 0;
min = 0xFFFFFFFF;
for (size_t i = 0; i < ARRAY_SIZE(topo->feerates); i++) {
for (size_t j = 0; j < tal_count(topo->feerates[i]); j++) {
if (topo->feerates[i][j].rate < min)
min = topo->feerates[i][j].rate;
}

/* FIXME: This is what bcli used to do: halve the slow feerate! */
min /= 2;

/* We can't allow less than feerate_floor, since that won't relay */
if (min < get_feerate_floor(topo))
return get_feerate_floor(topo);
}
if (min == 0xFFFFFFFF) {
if (unknown)
*unknown = true;
min = 0;
}

/* FIXME: This is what bcli used to do: halve the slow feerate! */
min /= 2;

/* We can't allow less than feerate_floor, since that won't relay */
if (min < get_feerate_floor(topo))
return get_feerate_floor(topo);
return min;
}

Expand All @@ -1177,9 +1172,6 @@ u32 feerate_max(struct lightningd *ld, bool *unknown)
if (unknown)
*unknown = false;

if (ld->config.ignore_fee_limits)
return UINT_MAX;

for (size_t i = 0; i < ARRAY_SIZE(topo->feerates); i++) {
for (size_t j = 0; j < tal_count(topo->feerates[i]); j++) {
if (topo->feerates[i][j].rate > max)
Expand Down