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

lnrpc+rpcserver: add custom channel data for closed channels #9504

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/release-notes/release-notes-0.19.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
RPC method now applies a default timeout of 60 seconds when the
`timeout_seconds` field is not set or is explicitly set to 0.

* [`lnrpc.ClosedChannels` now also includes the `custom_channel_data` used by
custom channels](https://github.com/lightningnetwork/lnd/pull/9504).

## lncli Additions

* [A pre-generated macaroon root key can now be specified in `lncli create` and
Expand Down
17 changes: 15 additions & 2 deletions lnrpc/lightning.pb.go

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

4 changes: 4 additions & 0 deletions lnrpc/lightning.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1751,6 +1751,10 @@ message ChannelCloseSummary {

// The confirmed SCID for a zero-conf channel.
uint64 zero_conf_confirmed_scid = 15 [jstype = JS_STRING];

// The TLV encoded custom channel data records for this output, which might
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"might be set for custom channels", so its not always set for custom channels ?

// be set for custom channels.
bytes custom_channel_data = 16;
}

enum ResolutionType {
Expand Down
5 changes: 5 additions & 0 deletions lnrpc/lightning.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4182,6 +4182,11 @@
"type": "string",
"format": "uint64",
"description": "The confirmed SCID for a zero-conf channel."
},
"custom_channel_data": {
"type": "string",
"format": "byte",
"description": "The TLV encoded custom channel data records for this output, which might\nbe set for custom channels."
}
}
},
Expand Down
25 changes: 21 additions & 4 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -4447,6 +4447,16 @@ func (r *rpcServer) ClosedChannels(ctx context.Context,
resp.Channels = append(resp.Channels, channel)
}

err = fn.MapOptionZ(
r.server.implCfg.AuxDataParser,
func(parser AuxDataParser) error {
return parser.InlineParseCustomData(resp)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs an update on the litd side if we are going to support it.

},
)
if err != nil {
return nil, fmt.Errorf("error parsing custom data: %w", err)
}

return resp, nil
}

Expand Down Expand Up @@ -4899,7 +4909,8 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
// createRPCClosedChannel creates an *lnrpc.ClosedChannelSummary from a
// *channeldb.ChannelCloseSummary.
func (r *rpcServer) createRPCClosedChannel(
dbChannel *channeldb.ChannelCloseSummary) (*lnrpc.ChannelCloseSummary, error) {
dbChannel *channeldb.ChannelCloseSummary) (*lnrpc.ChannelCloseSummary,
error) {

nodePub := dbChannel.RemotePub
nodeID := hex.EncodeToString(nodePub.SerializeCompressed())
Expand All @@ -4913,9 +4924,7 @@ func (r *rpcServer) createRPCClosedChannel(

// Lookup local and remote cooperative initiators. If these values
// are not known they will just return unknown.
openInit, closeInitiator, err = r.getInitiators(
&dbChannel.ChanPoint,
)
openInit, closeInitiator, err = r.getInitiators(&dbChannel.ChanPoint)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -4982,6 +4991,14 @@ func (r *rpcServer) createRPCClosedChannel(
channel.ZeroConfConfirmedScid = confirmedScid
}

// Finally we'll attempt to encode the custom channel data if
// any exists.
channel.CustomChannelData, err = encodeCustomChanData(histChan)
if err != nil {
return nil, fmt.Errorf("unable to encode open chan "+
"data: %w", err)
}

// Non-nil error not due to older versions of lnd.
default:
return nil, err
Expand Down
Loading