Enhance lncli listchannels command with the chan_id and short_chan_id (human readable format)#9390
Conversation
|
Important Review skippedAuto reviews are limited to specific labels. 🏷️ Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
6cf95f0 to
755d729
Compare
|
PTAL @ziggie1984 |
|
Please read the contribution guidelines thoroughly in particular what was immediately catching my eye is the commit structure |
Got it! Working on it Now... |
|
Maybe people should be warned that a renaming an API attribute would break things |
755d729 to
3d19e19
Compare
|
Hey @ziggie1984, I have addressed the Git commit structure and made the required changes based on your review. Please take a look. |
|
Thank you for the PR, I think it is enough to have the short_chan_id and the normal channel_id in the rpc msg. Then when for example depicting the channel struct via |
Addresses the reviewed changes. Here is how the {
"channels": [
{
"active": true,
"remote_pubkey": "02769271ddfb03149bc9e2e6124bb8d83209284dda3affed0dead73f57b64f45dd",
"channel_point": "6ab312e3b744e1b80a33a6541697df88766515c31c08e839bf11dc9fcc036a19:0",
"chan_id": "829031767408640",
"capacity": "20000",
"local_balance": "16530",
"remote_balance": "0",
"commit_fee": "3140",
"commit_weight": "772",
"fee_per_kw": "2500",
"unsettled_balance": "0",
"total_satoshis_sent": "0",
"total_satoshis_received": "0",
"num_updates": "0",
"pending_htlcs": [],
"csv_delay": 144,
"private": false,
"initiator": true,
"chan_status_flags": "ChanStatusDefault",
"local_chan_reserve_sat": "354",
"remote_chan_reserve_sat": "354",
"static_remote_key": false,
"commitment_type": "ANCHORS",
"lifetime": "11",
"uptime": "11",
"close_address": "",
"push_amount_sat": "0",
"thaw_height": 0,
"local_constraints": {
"csv_delay": 144,
"chan_reserve_sat": "354",
"dust_limit_sat": "354",
"max_pending_amt_msat": "19800000",
"min_htlc_msat": "1",
"max_accepted_htlcs": 483
},
"remote_constraints": {
"csv_delay": 144,
"chan_reserve_sat": "354",
"dust_limit_sat": "354",
"max_pending_amt_msat": "19800000",
"min_htlc_msat": "1",
"max_accepted_htlcs": 483
},
"alias_scids": [],
"zero_conf": false,
"zero_conf_confirmed_scid": "0",
"peer_alias": "02769271ddfb03149bc9",
"peer_scid_alias": "0",
"memo": "",
"custom_channel_data": "",
"channel_id": "196a03cc9fdc11bf39e8081cc315657688df971654a6330ab8e144b7e312b36a",
"short_chan_id": "829031767408640",
"short_chan_id_str": "754x1x0"
},
{
"active": true,
"remote_pubkey": "02769271ddfb03149bc9e2e6124bb8d83209284dda3affed0dead73f57b64f45dd",
"channel_point": "e428fb553769e4e53dbfb9749f8b057272969517ea85c63f46288487bfd62cf0:0",
"chan_id": "807041534853120",
"capacity": "100000",
"local_balance": "0",
"remote_balance": "96530",
"commit_fee": "3140",
"commit_weight": "772",
"fee_per_kw": "2500",
"unsettled_balance": "0",
"total_satoshis_sent": "0",
"total_satoshis_received": "0",
"num_updates": "0",
"pending_htlcs": [],
"csv_delay": 144,
"private": false,
"initiator": false,
"chan_status_flags": "ChanStatusDefault",
"local_chan_reserve_sat": "1000",
"remote_chan_reserve_sat": "1000",
"static_remote_key": false,
"commitment_type": "ANCHORS",
"lifetime": "459",
"uptime": "421",
"close_address": "",
"push_amount_sat": "0",
"thaw_height": 0,
"local_constraints": {
"csv_delay": 144,
"chan_reserve_sat": "1000",
"dust_limit_sat": "354",
"max_pending_amt_msat": "99000000",
"min_htlc_msat": "1",
"max_accepted_htlcs": 483
},
"remote_constraints": {
"csv_delay": 144,
"chan_reserve_sat": "1000",
"dust_limit_sat": "354",
"max_pending_amt_msat": "99000000",
"min_htlc_msat": "1",
"max_accepted_htlcs": 483
},
"alias_scids": [],
"zero_conf": false,
"zero_conf_confirmed_scid": "0",
"peer_alias": "02769271ddfb03149bc9",
"peer_scid_alias": "0",
"memo": "",
"custom_channel_data": "",
"channel_id": "f02cd6bf878428463fc685ea1795967272058b9f74b9bf3de5e4693755fb28e4",
"short_chan_id": "807041534853120",
"short_chan_id_str": "734x1x0"
}
]
} |
|
While looking at the protobuf file, a lot of the structs use Maybe something like I think it is not really worth dealing with all these name changes in the protofiles if so many structs are affected. Wdyt @guggero ? |
|
I have a better idea: So initial request was to make the We can do all this by just changing the So I favour the approach to not change anything in the RPC code, but just add all the information on the lncli side! |
90ed477 to
de85265
Compare
Done. Here is how the {
"channels": [
{
"active": false,
"remote_pubkey": "02769271ddfb03149bc9e2e6124bb8d83209284dda3affed0dead73f57b64f45dd",
"channel_point": "6ab312e3b744e1b80a33a6541697df88766515c31c08e839bf11dc9fcc036a19:0",
"funding_outpoint_id": "196a03cc9fdc11bf39e8081cc315657688df971654a6330ab8e144b7e312b36a",
"chan_id": "829031767408640",
"chan_id_str": "754x1x0",
"capacity": "20000",
"local_balance": "16530",
"remote_balance": "0",
"commit_fee": "3140",
"commit_weight": "772",
"fee_per_kw": "2500",
"unsettled_balance": "0",
"total_satoshis_sent": "0",
"total_satoshis_received": "0",
"num_updates": "0",
"pending_htlcs": [],
"csv_delay": 144,
"private": false,
"initiator": true,
"chan_status_flags": "ChanStatusDefault",
"local_chan_reserve_sat": "354",
"remote_chan_reserve_sat": "354",
"static_remote_key": false,
"commitment_type": "ANCHORS",
"lifetime": "0",
"uptime": "0",
"close_address": "",
"push_amount_sat": "0",
"thaw_height": 0,
"local_constraints": {
"csv_delay": 144,
"chan_reserve_sat": "354",
"dust_limit_sat": "354",
"max_pending_amt_msat": "19800000",
"min_htlc_msat": "1",
"max_accepted_htlcs": 483
},
"remote_constraints": {
"csv_delay": 144,
"chan_reserve_sat": "354",
"dust_limit_sat": "354",
"max_pending_amt_msat": "19800000",
"min_htlc_msat": "1",
"max_accepted_htlcs": 483
},
"alias_scids": [],
"zero_conf": false,
"zero_conf_confirmed_scid": "0",
"peer_alias": "02769271ddfb03149bc9",
"peer_scid_alias": "0",
"memo": "",
"custom_channel_data": ""
},
{
"active": false,
"remote_pubkey": "02769271ddfb03149bc9e2e6124bb8d83209284dda3affed0dead73f57b64f45dd",
"channel_point": "e428fb553769e4e53dbfb9749f8b057272969517ea85c63f46288487bfd62cf0:0",
"funding_outpoint_id": "f02cd6bf878428463fc685ea1795967272058b9f74b9bf3de5e4693755fb28e4",
"chan_id": "807041534853120",
"chan_id_str": "734x1x0",
"capacity": "100000",
"local_balance": "0",
"remote_balance": "96530",
"commit_fee": "3140",
"commit_weight": "772",
"fee_per_kw": "2500",
"unsettled_balance": "0",
"total_satoshis_sent": "0",
"total_satoshis_received": "0",
"num_updates": "0",
"pending_htlcs": [],
"csv_delay": 144,
"private": false,
"initiator": false,
"chan_status_flags": "ChanStatusDefault",
"local_chan_reserve_sat": "1000",
"remote_chan_reserve_sat": "1000",
"static_remote_key": false,
"commitment_type": "ANCHORS",
"lifetime": "0",
"uptime": "0",
"close_address": "",
"push_amount_sat": "0",
"thaw_height": 0,
"local_constraints": {
"csv_delay": 144,
"chan_reserve_sat": "1000",
"dust_limit_sat": "354",
"max_pending_amt_msat": "99000000",
"min_htlc_msat": "1",
"max_accepted_htlcs": 483
},
"remote_constraints": {
"csv_delay": 144,
"chan_reserve_sat": "1000",
"dust_limit_sat": "354",
"max_pending_amt_msat": "99000000",
"min_htlc_msat": "1",
"max_accepted_htlcs": 483
},
"alias_scids": [],
"zero_conf": false,
"zero_conf_confirmed_scid": "0",
"peer_alias": "02769271ddfb03149bc9",
"peer_scid_alias": "0",
"memo": "",
"custom_channel_data": ""
}
]
} |
Hi @ziggie1984, just following up in case my previous message was missed. |
ziggie1984
left a comment
There was a problem hiding this comment.
Yes this is the right approach, left some suggestions. Please also update all the comments as well if you adopt them.
| This is a protocol gadget required for Dynamic Commitments and Splicing that | ||
| will be added later. | ||
|
|
||
| * [Added]((https://github.com/lightningnetwork/lnd/pull/9390)) |
There was a problem hiding this comment.
add the release notes under the lncli section
de85265 to
2999a81
Compare
|
New output: {
"channels": [
{
"active": false,
"remote_pubkey": "0367cb414c9487311a1466b51b911c994d3438713edc373a27110a7162ac1046f5",
"chan_point": "6ab312e3b744e1b80a33a6541697df88766515c31c08e839bf11dc9fcc036a19:0",
"chan_id": "196a03cc9fdc11bf39e8081cc315657688df971654a6330ab8e144b7e312b36a",
"scid": "829031767408640",
"scid_str": "754x1x0",
"capacity": "20000",
"local_balance": "0",
"remote_balance": "16530",
"commit_fee": "3140",
"commit_weight": "772",
"fee_per_kw": "2500",
"unsettled_balance": "0",
"total_satoshis_sent": "0",
"total_satoshis_received": "0",
"num_updates": "0",
"pending_htlcs": [],
"csv_delay": 144,
"private": false,
"initiator": false,
"chan_status_flags": "ChanStatusDefault",
"local_chan_reserve_sat": "354",
"remote_chan_reserve_sat": "354",
"static_remote_key": false,
"commitment_type": "ANCHORS",
"lifetime": "0",
"uptime": "0",
"close_address": "",
"push_amount_sat": "0",
"thaw_height": 0,
"local_constraints": {
"csv_delay": 144,
"chan_reserve_sat": "354",
"dust_limit_sat": "354",
"max_pending_amt_msat": "19800000",
"min_htlc_msat": "1",
"max_accepted_htlcs": 483
},
"remote_constraints": {
"csv_delay": 144,
"chan_reserve_sat": "354",
"dust_limit_sat": "354",
"max_pending_amt_msat": "19800000",
"min_htlc_msat": "1",
"max_accepted_htlcs": 483
},
"alias_scids": [],
"zero_conf": false,
"zero_conf_confirmed_scid": "0",
"peer_alias": "0367cb414c9487311a14",
"peer_scid_alias": "0",
"memo": "",
"custom_channel_data": ""
},
{
"active": false,
"remote_pubkey": "0367cb414c9487311a1466b51b911c994d3438713edc373a27110a7162ac1046f5",
"chan_point": "e428fb553769e4e53dbfb9749f8b057272969517ea85c63f46288487bfd62cf0:0",
"chan_id": "f02cd6bf878428463fc685ea1795967272058b9f74b9bf3de5e4693755fb28e4",
"scid": "807041534853120",
"scid_str": "734x1x0",
"capacity": "100000",
"local_balance": "96530",
"remote_balance": "0",
"commit_fee": "3140",
"commit_weight": "772",
"fee_per_kw": "2500",
"unsettled_balance": "0",
"total_satoshis_sent": "0",
"total_satoshis_received": "0",
"num_updates": "0",
"pending_htlcs": [],
"csv_delay": 144,
"private": false,
"initiator": true,
"chan_status_flags": "ChanStatusDefault",
"local_chan_reserve_sat": "1000",
"remote_chan_reserve_sat": "1000",
"static_remote_key": false,
"commitment_type": "ANCHORS",
"lifetime": "0",
"uptime": "0",
"close_address": "",
"push_amount_sat": "0",
"thaw_height": 0,
"local_constraints": {
"csv_delay": 144,
"chan_reserve_sat": "1000",
"dust_limit_sat": "354",
"max_pending_amt_msat": "99000000",
"min_htlc_msat": "1",
"max_accepted_htlcs": 483
},
"remote_constraints": {
"csv_delay": 144,
"chan_reserve_sat": "1000",
"dust_limit_sat": "354",
"max_pending_amt_msat": "99000000",
"min_htlc_msat": "1",
"max_accepted_htlcs": 483
},
"alias_scids": [],
"zero_conf": false,
"zero_conf_confirmed_scid": "0",
"peer_alias": "0367cb414c9487311a14",
"peer_scid_alias": "0",
"memo": "",
"custom_channel_data": ""
}
]
} |
lncli listchannels command with the chan_id and short_chan_id (human readable format)
ziggie1984
left a comment
There was a problem hiding this comment.
Great work, had some final comments.
2999a81 to
7e44c02
Compare
guggero
left a comment
There was a problem hiding this comment.
Thanks for the PR. Approach ACK.
| // Format a new JSON field for the scid (chan_id), | ||
| // including both its numeric representation and its | ||
| // string representation (scid_str). | ||
| scidStr := lnwire.NewShortChanIDFromInt(scid).String() |
There was a problem hiding this comment.
Related to my previous comment, we could either call into the alternative method here or do some replacement here directly.
| now update the channel policy if the edge was not found in the graph | ||
| database if the `create_missing_edge` flag is set. | ||
|
|
||
| * [Enhance](https://github.com/lightningnetwork/lnd/pull/9390) the `lncli listchannels` output by adding the human readable short channel id and the channel id defined in BOLT02. Moreover change the misnomer of `chan_id` which was describing the short channel id to `scid` to represent what it really is. |
There was a problem hiding this comment.
Please wrap lines at 80 characters here as well.
64bf8a9 to
0b11cec
Compare
guggero
left a comment
There was a problem hiding this comment.
Nice, thanks for the update. Two more nits then we're good to go!
| return fmt.Sprintf("%d:%d:%d", c.BlockHeight, c.TxIndex, c.TxPosition) | ||
| } | ||
|
|
||
| // String generates a human-readable representation of the channel ID |
There was a problem hiding this comment.
The Godoc domment needs to match the actual method name here.
| )[1] | ||
|
|
||
| chanOutpoint, err := wire.NewOutPointFromString( | ||
| chanPoint) |
There was a problem hiding this comment.
nit: closing parenthesis should go to a new line.
|
Maybe I was not clear enough in my previous comment but I meant to squash unnecessary commits that didn't mean squashing the release notes for example. |
Add the `AltString` method for `ShortChannelID` to produce a human-readable format with 'x' as a separator (block x transaction x output). Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
0b11cec to
58cb93a
Compare
ziggie1984
left a comment
There was a problem hiding this comment.
Can squash the unit test commit with the commit which introduces the functions.
LGTM
Added scid_str as a string representation of chan_id, replacing chan_id with scid, and including chan_id(BOLT02) in lncli listchannels output. Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
58cb93a to
c2897a4
Compare
Change Description
Fixes: #8650
This PR enhances channel ID representation by introducing both integer and string formats for
ShortChannelId:Renamed
ChanIdtoShortChanIdInt:ShortChannelId.Added
ShortChanId:ShortChannelIdin the formatblock x transaction x output.Introduced
chan_id:chan_idbased on the definition in the BOLT-2 Peer Protocol specification, aligning with Lightning Network standards.Steps to Test
Steps for reviewers to follow to test the change.
Pull Request Checklist
Testing
Code Style and Documentation
[skip ci]in the commit message for small changes.📝 Please see our Contribution Guidelines for further guidance.