add max_htlc_value_in_flight_msat to listpeerchan

Changelog-Added: JSON-RPC: `listpeerchannels` new output fields `their_max_total_htlc_out_msat` and `our_max_total_htlc_out_msat` as the value of `max_htlc_value_in_flight` (as of BOLT02) set by the local and remote nodes on channel creation.

Changelog-Deprecated: JSON-RPC: `listpeerchannels` value `max_total_htlc_in_msat`: use `our_max_total_htlc_out_msat` instead to follow spec naming convention.
This commit is contained in:
Lagrang3 2025-02-21 15:05:10 +10:30 committed by Alex Myers
parent 0df3c5869a
commit fe4d5036c2
10 changed files with 889 additions and 770 deletions

View file

@ -2669,6 +2669,7 @@
"ListPeerChannels.channels[].next_fee_step": 15,
"ListPeerChannels.channels[].next_feerate": 14,
"ListPeerChannels.channels[].opener": 19,
"ListPeerChannels.channels[].our_max_htlc_value_in_flight_msat": 62,
"ListPeerChannels.channels[].our_reserve_msat": 32,
"ListPeerChannels.channels[].our_to_self_delay": 39,
"ListPeerChannels.channels[].out_fulfilled_msat": 51,
@ -2687,6 +2688,7 @@
"ListPeerChannels.channels[].state": 3,
"ListPeerChannels.channels[].state_changes[]": 42,
"ListPeerChannels.channels[].status[]": 43,
"ListPeerChannels.channels[].their_max_htlc_value_in_flight_msat": 61,
"ListPeerChannels.channels[].their_reserve_msat": 31,
"ListPeerChannels.channels[].their_to_self_delay": 38,
"ListPeerChannels.channels[].to_us_msat": 23,
@ -10106,7 +10108,7 @@
},
"ListPeerChannels.channels[].max_total_htlc_in_msat": {
"added": "v23.02",
"deprecated": null
"deprecated": "v25.02"
},
"ListPeerChannels.channels[].maximum_htlc_out_msat": {
"added": "v23.02",
@ -10136,6 +10138,10 @@
"added": "v23.02",
"deprecated": null
},
"ListPeerChannels.channels[].our_max_htlc_value_in_flight_msat": {
"added": "v25.02",
"deprecated": null
},
"ListPeerChannels.channels[].our_reserve_msat": {
"added": "v23.02",
"deprecated": null
@ -10228,6 +10234,10 @@
"added": "v23.02",
"deprecated": null
},
"ListPeerChannels.channels[].their_max_htlc_value_in_flight_msat": {
"added": "v25.02",
"deprecated": null
},
"ListPeerChannels.channels[].their_reserve_msat": {
"added": "v23.02",
"deprecated": null

View file

@ -1453,6 +1453,8 @@ message ListpeerchannelsChannels {
optional bool reestablished = 58;
optional Amount last_tx_fee_msat = 59;
optional uint32 direction = 60;
optional Amount their_max_htlc_value_in_flight_msat = 61;
optional Amount our_max_htlc_value_in_flight_msat = 62;
}
message ListpeerchannelsChannelsUpdates {

View file

@ -1298,7 +1298,7 @@ impl From<responses::ListpeerchannelsChannelsUpdates> for pb::ListpeerchannelsCh
}
}
#[allow(unused_variables)]
#[allow(unused_variables,deprecated)]
impl From<responses::ListpeerchannelsChannels> for pb::ListpeerchannelsChannels {
fn from(c: responses::ListpeerchannelsChannels) -> Self {
Self {
@ -1331,6 +1331,7 @@ impl From<responses::ListpeerchannelsChannels> for pb::ListpeerchannelsChannels
lost_state: c.lost_state, // Rule #2 for type boolean?
max_accepted_htlcs: c.max_accepted_htlcs, // Rule #2 for type u32?
max_to_us_msat: c.max_to_us_msat.map(|f| f.into()), // Rule #2 for type msat?
#[allow(deprecated)]
max_total_htlc_in_msat: c.max_total_htlc_in_msat.map(|f| f.into()), // Rule #2 for type msat?
maximum_htlc_out_msat: c.maximum_htlc_out_msat.map(|f| f.into()), // Rule #2 for type msat?
min_to_us_msat: c.min_to_us_msat.map(|f| f.into()), // Rule #2 for type msat?
@ -1339,6 +1340,7 @@ impl From<responses::ListpeerchannelsChannels> for pb::ListpeerchannelsChannels
next_fee_step: c.next_fee_step, // Rule #2 for type u32?
next_feerate: c.next_feerate, // Rule #2 for type string?
opener: c.opener as i32,
our_max_htlc_value_in_flight_msat: c.our_max_htlc_value_in_flight_msat.map(|f| f.into()), // Rule #2 for type msat?
our_reserve_msat: c.our_reserve_msat.map(|f| f.into()), // Rule #2 for type msat?
our_to_self_delay: c.our_to_self_delay, // Rule #2 for type u32?
out_fulfilled_msat: c.out_fulfilled_msat.map(|f| f.into()), // Rule #2 for type msat?
@ -1357,6 +1359,7 @@ impl From<responses::ListpeerchannelsChannels> for pb::ListpeerchannelsChannels
state: c.state as i32,
// Field: ListPeerChannels.channels[].status[]
status: c.status.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3
their_max_htlc_value_in_flight_msat: c.their_max_htlc_value_in_flight_msat.map(|f| f.into()), // Rule #2 for type msat?
their_reserve_msat: c.their_reserve_msat.map(|f| f.into()), // Rule #2 for type msat?
their_to_self_delay: c.their_to_self_delay, // Rule #2 for type u32?
to_us_msat: c.to_us_msat.map(|f| f.into()), // Rule #2 for type msat?

9
cln-rpc/src/model.rs generated
View file

@ -7060,6 +7060,9 @@ pub mod responses {
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListpeerchannelsChannels {
#[deprecated]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_total_htlc_in_msat: Option<Amount>,
#[serde(skip_serializing_if = "Option::is_none")]
pub alias: Option<ListpeerchannelsChannelsAlias>,
#[serde(skip_serializing_if = "Option::is_none")]
@ -7111,8 +7114,6 @@ pub mod responses {
#[serde(skip_serializing_if = "Option::is_none")]
pub max_to_us_msat: Option<Amount>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_total_htlc_in_msat: Option<Amount>,
#[serde(skip_serializing_if = "Option::is_none")]
pub maximum_htlc_out_msat: Option<Amount>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_to_us_msat: Option<Amount>,
@ -7125,6 +7126,8 @@ pub mod responses {
#[serde(skip_serializing_if = "Option::is_none")]
pub next_feerate: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub our_max_htlc_value_in_flight_msat: Option<Amount>,
#[serde(skip_serializing_if = "Option::is_none")]
pub our_reserve_msat: Option<Amount>,
#[serde(skip_serializing_if = "Option::is_none")]
pub our_to_self_delay: Option<u32>,
@ -7151,6 +7154,8 @@ pub mod responses {
#[serde(skip_serializing_if = "Option::is_none")]
pub spendable_msat: Option<Amount>,
#[serde(skip_serializing_if = "Option::is_none")]
pub their_max_htlc_value_in_flight_msat: Option<Amount>,
#[serde(skip_serializing_if = "Option::is_none")]
pub their_reserve_msat: Option<Amount>,
#[serde(skip_serializing_if = "Option::is_none")]
pub their_to_self_delay: Option<u32>,

View file

@ -24438,7 +24438,25 @@
"max_total_htlc_in_msat": {
"type": "msat",
"description": [
"Max amount accept in a single payment."
"Max amount accept in a single payment. This field is deprecated, use instead our_max_htlc_value_in_flight_msat"
],
"deprecated": [
"v25.02",
"v26.05"
]
},
"their_max_htlc_value_in_flight_msat": {
"type": "msat",
"added": "v25.02",
"description": [
"Cap on total value of outstanding HTLCs offered to the remote node. This limits the total amount in flight we can send through this channel."
]
},
"our_max_htlc_value_in_flight_msat": {
"type": "msat",
"added": "v25.02",
"description": [
"Cap on total value of outstanding HTLCs we accept from the remote node. This limits the total amount in flight we can receive through this channel."
]
},
"their_reserve_msat": {
@ -24911,6 +24929,8 @@
"fee_proportional_millionths": {},
"dust_limit_msat": {},
"max_total_htlc_in_msat": {},
"our_max_total_htlc_in_msat": {},
"their_max_total_htlc_in_msat": {},
"their_reserve_msat": {},
"our_reserve_msat": {},
"spendable_msat": {},
@ -24929,6 +24949,8 @@
"msatoshi_total": {},
"dust_limit_satoshis": {},
"max_htlc_value_in_flight_msat": {},
"our_max_htlc_value_in_flight_msat": {},
"their_max_htlc_value_in_flight_msat": {},
"our_channel_reserve_satoshis": {},
"their_channel_reserve_satoshis": {},
"spendable_satoshis": {},
@ -25008,6 +25030,8 @@
"fee_proportional_millionths": {},
"dust_limit_msat": {},
"max_total_htlc_in_msat": {},
"our_max_total_htlc_in_msat": {},
"their_max_total_htlc_in_msat": {},
"their_reserve_msat": {},
"our_reserve_msat": {},
"spendable_msat": {},
@ -25026,6 +25050,8 @@
"msatoshi_total": {},
"dust_limit_satoshis": {},
"max_htlc_value_in_flight_msat": {},
"our_max_htlc_value_in_flight_msat": {},
"their_max_htlc_value_in_flight_msat": {},
"our_channel_reserve_satoshis": {},
"their_channel_reserve_satoshis": {},
"spendable_satoshis": {},
@ -25104,6 +25130,8 @@
"fee_proportional_millionths": {},
"dust_limit_msat": {},
"max_total_htlc_in_msat": {},
"our_max_total_htlc_in_msat": {},
"their_max_total_htlc_in_msat": {},
"their_reserve_msat": {},
"our_reserve_msat": {},
"spendable_msat": {},
@ -25122,6 +25150,8 @@
"msatoshi_total": {},
"dust_limit_satoshis": {},
"max_htlc_value_in_flight_msat": {},
"our_max_htlc_value_in_flight_msat": {},
"their_max_htlc_value_in_flight_msat": {},
"our_channel_reserve_satoshis": {},
"their_channel_reserve_satoshis": {},
"spendable_satoshis": {},
@ -25202,6 +25232,8 @@
"fee_proportional_millionths": {},
"dust_limit_msat": {},
"max_total_htlc_in_msat": {},
"our_max_total_htlc_in_msat": {},
"their_max_total_htlc_in_msat": {},
"their_reserve_msat": {},
"our_reserve_msat": {},
"spendable_msat": {},
@ -25220,6 +25252,8 @@
"msatoshi_total": {},
"dust_limit_satoshis": {},
"max_htlc_value_in_flight_msat": {},
"our_max_htlc_value_in_flight_msat": {},
"their_max_htlc_value_in_flight_msat": {},
"our_channel_reserve_satoshis": {},
"their_channel_reserve_satoshis": {},
"spendable_satoshis": {},
@ -25386,6 +25420,8 @@
"fee_proportional_millionths": 10,
"dust_limit_msat": 546000,
"max_total_htlc_in_msat": 18446744073709552000,
"their_max_htlc_value_in_flight_msat": 18446744073709552000,
"our_max_htlc_value_in_flight_msat": 18446744073709552000,
"their_reserve_msat": 10000000,
"our_reserve_msat": 10000000,
"spendable_msat": 363951707,
@ -25516,6 +25552,8 @@
"fee_proportional_millionths": 10,
"dust_limit_msat": 546000,
"max_total_htlc_in_msat": 18446744073709552000,
"their_max_htlc_value_in_flight_msat": 18446744073709552000,
"our_max_htlc_value_in_flight_msat": 18446744073709552000,
"their_reserve_msat": 10000000,
"our_reserve_msat": 10000000,
"spendable_msat": 363951707,
@ -25640,6 +25678,8 @@
"fee_proportional_millionths": 10,
"dust_limit_msat": 546000,
"max_total_htlc_in_msat": 18446744073709552000,
"their_max_htlc_value_in_flight_msat": 18446744073709552000,
"our_max_htlc_value_in_flight_msat": 18446744073709552000,
"their_reserve_msat": 546000,
"our_reserve_msat": 546000,
"spendable_msat": 8172000,

File diff suppressed because one or more lines are too long

View file

@ -1018,6 +1018,7 @@ def listpeerchannels_channels2py(m):
"minimum_htlc_out_msat": amount2msat(m.minimum_htlc_out_msat), # PrimitiveField in generate_composite
"next_fee_step": m.next_fee_step, # PrimitiveField in generate_composite
"next_feerate": m.next_feerate, # PrimitiveField in generate_composite
"our_max_htlc_value_in_flight_msat": amount2msat(m.our_max_htlc_value_in_flight_msat), # PrimitiveField in generate_composite
"our_reserve_msat": amount2msat(m.our_reserve_msat), # PrimitiveField in generate_composite
"our_to_self_delay": m.our_to_self_delay, # PrimitiveField in generate_composite
"out_fulfilled_msat": amount2msat(m.out_fulfilled_msat), # PrimitiveField in generate_composite
@ -1033,6 +1034,7 @@ def listpeerchannels_channels2py(m):
"scratch_txid": hexlify(m.scratch_txid), # PrimitiveField in generate_composite
"short_channel_id": m.short_channel_id, # PrimitiveField in generate_composite
"spendable_msat": amount2msat(m.spendable_msat), # PrimitiveField in generate_composite
"their_max_htlc_value_in_flight_msat": amount2msat(m.their_max_htlc_value_in_flight_msat), # PrimitiveField in generate_composite
"their_reserve_msat": amount2msat(m.their_reserve_msat), # PrimitiveField in generate_composite
"their_to_self_delay": m.their_to_self_delay, # PrimitiveField in generate_composite
"to_us_msat": amount2msat(m.to_us_msat), # PrimitiveField in generate_composite

View file

@ -543,7 +543,25 @@
"max_total_htlc_in_msat": {
"type": "msat",
"description": [
"Max amount accept in a single payment."
"Max amount accept in a single payment. This field is deprecated, use instead our_max_htlc_value_in_flight_msat"
],
"deprecated": [
"v25.02",
"v26.05"
]
},
"their_max_htlc_value_in_flight_msat": {
"type": "msat",
"added": "v25.02",
"description": [
"Cap on total value of outstanding HTLCs offered to the remote node. This limits the total amount in flight we can send through this channel."
]
},
"our_max_htlc_value_in_flight_msat": {
"type": "msat",
"added": "v25.02",
"description": [
"Cap on total value of outstanding HTLCs we accept from the remote node. This limits the total amount in flight we can receive through this channel."
]
},
"their_reserve_msat": {
@ -1016,6 +1034,8 @@
"fee_proportional_millionths": {},
"dust_limit_msat": {},
"max_total_htlc_in_msat": {},
"our_max_total_htlc_in_msat": {},
"their_max_total_htlc_in_msat": {},
"their_reserve_msat": {},
"our_reserve_msat": {},
"spendable_msat": {},
@ -1034,6 +1054,8 @@
"msatoshi_total": {},
"dust_limit_satoshis": {},
"max_htlc_value_in_flight_msat": {},
"our_max_htlc_value_in_flight_msat": {},
"their_max_htlc_value_in_flight_msat": {},
"our_channel_reserve_satoshis": {},
"their_channel_reserve_satoshis": {},
"spendable_satoshis": {},
@ -1113,6 +1135,8 @@
"fee_proportional_millionths": {},
"dust_limit_msat": {},
"max_total_htlc_in_msat": {},
"our_max_total_htlc_in_msat": {},
"their_max_total_htlc_in_msat": {},
"their_reserve_msat": {},
"our_reserve_msat": {},
"spendable_msat": {},
@ -1131,6 +1155,8 @@
"msatoshi_total": {},
"dust_limit_satoshis": {},
"max_htlc_value_in_flight_msat": {},
"our_max_htlc_value_in_flight_msat": {},
"their_max_htlc_value_in_flight_msat": {},
"our_channel_reserve_satoshis": {},
"their_channel_reserve_satoshis": {},
"spendable_satoshis": {},
@ -1209,6 +1235,8 @@
"fee_proportional_millionths": {},
"dust_limit_msat": {},
"max_total_htlc_in_msat": {},
"our_max_total_htlc_in_msat": {},
"their_max_total_htlc_in_msat": {},
"their_reserve_msat": {},
"our_reserve_msat": {},
"spendable_msat": {},
@ -1227,6 +1255,8 @@
"msatoshi_total": {},
"dust_limit_satoshis": {},
"max_htlc_value_in_flight_msat": {},
"our_max_htlc_value_in_flight_msat": {},
"their_max_htlc_value_in_flight_msat": {},
"our_channel_reserve_satoshis": {},
"their_channel_reserve_satoshis": {},
"spendable_satoshis": {},
@ -1307,6 +1337,8 @@
"fee_proportional_millionths": {},
"dust_limit_msat": {},
"max_total_htlc_in_msat": {},
"our_max_total_htlc_in_msat": {},
"their_max_total_htlc_in_msat": {},
"their_reserve_msat": {},
"our_reserve_msat": {},
"spendable_msat": {},
@ -1325,6 +1357,8 @@
"msatoshi_total": {},
"dust_limit_satoshis": {},
"max_htlc_value_in_flight_msat": {},
"our_max_htlc_value_in_flight_msat": {},
"their_max_htlc_value_in_flight_msat": {},
"our_channel_reserve_satoshis": {},
"their_channel_reserve_satoshis": {},
"spendable_satoshis": {},
@ -1491,6 +1525,8 @@
"fee_proportional_millionths": 10,
"dust_limit_msat": 546000,
"max_total_htlc_in_msat": 18446744073709552000,
"their_max_htlc_value_in_flight_msat": 18446744073709552000,
"our_max_htlc_value_in_flight_msat": 18446744073709552000,
"their_reserve_msat": 10000000,
"our_reserve_msat": 10000000,
"spendable_msat": 363951707,
@ -1621,6 +1657,8 @@
"fee_proportional_millionths": 10,
"dust_limit_msat": 546000,
"max_total_htlc_in_msat": 18446744073709552000,
"their_max_htlc_value_in_flight_msat": 18446744073709552000,
"our_max_htlc_value_in_flight_msat": 18446744073709552000,
"their_reserve_msat": 10000000,
"our_reserve_msat": 10000000,
"spendable_msat": 363951707,
@ -1745,6 +1783,8 @@
"fee_proportional_millionths": 10,
"dust_limit_msat": 546000,
"max_total_htlc_in_msat": 18446744073709552000,
"their_max_htlc_value_in_flight_msat": 18446744073709552000,
"our_max_htlc_value_in_flight_msat": 18446744073709552000,
"their_reserve_msat": 546000,
"our_reserve_msat": 546000,
"spendable_msat": 8172000,

View file

@ -1148,6 +1148,12 @@ static void NON_NULL_ARGS(1, 2, 4, 5) json_add_channel(struct command *cmd,
channel->our_config.dust_limit);
json_add_amount_msat(response, "max_total_htlc_in_msat",
channel->our_config.max_htlc_value_in_flight);
json_add_amount_msat(
response, "their_max_htlc_value_in_flight_msat",
channel->channel_info.their_config.max_htlc_value_in_flight);
json_add_amount_msat(
response, "our_max_htlc_value_in_flight_msat",
channel->our_config.max_htlc_value_in_flight);
/* The `channel_reserve_satoshis` is imposed on
* the *other* side (see `channel_reserve_msat`

View file

@ -3873,6 +3873,11 @@ def test_sql(node_factory, bitcoind):
{'name': 'dust_limit_msat',
'type': 'msat'},
{'name': 'max_total_htlc_in_msat',
'type': 'msat',
'deprecated': True},
{'name': 'their_max_htlc_value_in_flight_msat',
'type': 'msat'},
{'name': 'our_max_htlc_value_in_flight_msat',
'type': 'msat'},
{'name': 'their_reserve_msat',
'type': 'msat'},
@ -4163,6 +4168,12 @@ def test_sql(node_factory, bitcoind):
assert row[0] > 0
for col in schema['columns']:
# We will get a complaint for trying to access deprecated cols by name:
if 'deprecated' in col:
name = f'{table}.{col["name"]}'
with pytest.raises(RpcError, match=fr'query failed with access to {name} is prohibited \(Deprecated column table {name}\)'):
l2.rpc.sql("SELECT {} FROM {};".format(col['name'], table))
continue
val = only_one(l2.rpc.sql("SELECT {} FROM {};".format(col['name'], table))['rows'][0])
# Could be null
if val is None: