rpc: add zero-conf, alias information to {list,closed}channels
This commit is contained in:
4 files changed
+2414
-2250
No files matched your search
+2311
-2249
File diff suppressed because it is too large.
Load diff
@@ -1482,6 +1482,18 @@ message Channel {
|
||||
|
||||
// List constraints for the remote node.
|
||||
ChannelConstraints remote_constraints = 30;
|
||||
|
||||
/*
|
||||
This lists out the set of alias short channel ids that exist for a channel.
|
||||
This may be empty.
|
||||
*/
|
||||
repeated uint64 alias_scids = 31;
|
||||
|
||||
// Whether or not this is a zero-conf channel.
|
||||
bool zero_conf = 32;
|
||||
|
||||
// This is the confirmed / on-chain zero-conf SCID.
|
||||
uint64 zero_conf_confirmed_scid = 33;
|
||||
}
|
||||
|
||||
message ListChannelsRequest {
|
||||
@@ -1565,6 +1577,15 @@ message ChannelCloseSummary {
|
||||
Initiator close_initiator = 12;
|
||||
|
||||
repeated Resolution resolutions = 13;
|
||||
|
||||
/*
|
||||
This lists out the set of alias short channel ids that existed for the
|
||||
closed channel. This may be empty.
|
||||
*/
|
||||
repeated uint64 alias_scids = 14;
|
||||
|
||||
// The confirmed SCID for a zero-conf channel.
|
||||
uint64 zero_conf_confirmed_scid = 15 [jstype = JS_STRING];
|
||||
}
|
||||
|
||||
enum ResolutionType {
|
||||
|
||||
@@ -3291,6 +3291,23 @@
|
||||
"remote_constraints": {
|
||||
"$ref": "#/definitions/lnrpcChannelConstraints",
|
||||
"description": "List constraints for the remote node."
|
||||
},
|
||||
"alias_scids": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"format": "uint64"
|
||||
},
|
||||
"description": "This lists out the set of alias short channel ids that exist for a channel.\nThis may be empty."
|
||||
},
|
||||
"zero_conf": {
|
||||
"type": "boolean",
|
||||
"description": "Whether or not this is a zero-conf channel."
|
||||
},
|
||||
"zero_conf_confirmed_scid": {
|
||||
"type": "string",
|
||||
"format": "uint64",
|
||||
"description": "This is the confirmed / on-chain zero-conf SCID."
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -3550,6 +3567,19 @@
|
||||
"items": {
|
||||
"$ref": "#/definitions/lnrpcResolution"
|
||||
}
|
||||
},
|
||||
"alias_scids": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"format": "uint64"
|
||||
},
|
||||
"description": "This lists out the set of alias short channel ids that existed for the\nclosed channel. This may be empty."
|
||||
},
|
||||
"zero_conf_confirmed_scid": {
|
||||
"type": "string",
|
||||
"format": "uint64",
|
||||
"description": "The confirmed SCID for a zero-conf channel."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+52
-1
@@ -4029,12 +4029,17 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
|
||||
// Extract the commitment type from the channel type flags.
|
||||
commitmentType := rpcCommitmentType(dbChannel.ChanType)
|
||||
|
||||
dbScid := dbChannel.ShortChannelID
|
||||
|
||||
// Fetch the set of aliases for the channel.
|
||||
channelAliases := r.server.aliasMgr.GetAliases(dbScid)
|
||||
|
||||
channel := &lnrpc.Channel{
|
||||
Active: isActive,
|
||||
Private: isPrivate(dbChannel),
|
||||
RemotePubkey: nodeID,
|
||||
ChannelPoint: chanPoint.String(),
|
||||
ChanId: dbChannel.ShortChannelID.ToUint64(),
|
||||
ChanId: dbScid.ToUint64(),
|
||||
Capacity: int64(dbChannel.Capacity),
|
||||
LocalBalance: int64(localBalance.ToSatoshis()),
|
||||
RemoteBalance: int64(remoteBalance.ToSatoshis()),
|
||||
@@ -4056,12 +4061,22 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
|
||||
RemoteConstraints: createChannelConstraint(
|
||||
&dbChannel.RemoteChanCfg,
|
||||
),
|
||||
AliasScids: make([]uint64, 0, len(channelAliases)),
|
||||
ZeroConf: dbChannel.IsZeroConf(),
|
||||
ZeroConfConfirmedScid: dbChannel.ZeroConfRealScid().ToUint64(),
|
||||
// TODO: remove the following deprecated fields
|
||||
CsvDelay: uint32(dbChannel.LocalChanCfg.CsvDelay),
|
||||
LocalChanReserveSat: int64(dbChannel.LocalChanCfg.ChanReserve),
|
||||
RemoteChanReserveSat: int64(dbChannel.RemoteChanCfg.ChanReserve),
|
||||
}
|
||||
|
||||
// Populate the set of aliases.
|
||||
for _, chanAlias := range channelAliases {
|
||||
channel.AliasScids = append(
|
||||
channel.AliasScids, chanAlias.ToUint64(),
|
||||
)
|
||||
}
|
||||
|
||||
for i, htlc := range localCommit.Htlcs {
|
||||
var rHash [32]byte
|
||||
copy(rHash[:], htlc.RHash[:])
|
||||
@@ -4227,6 +4242,11 @@ func (r *rpcServer) createRPCClosedChannel(
|
||||
closeType = lnrpc.ChannelCloseSummary_ABANDONED
|
||||
}
|
||||
|
||||
dbScid := dbChannel.ShortChanID
|
||||
|
||||
// Fetch the set of aliases for this channel.
|
||||
channelAliases := r.server.aliasMgr.GetAliases(dbScid)
|
||||
|
||||
channel := &lnrpc.ChannelCloseSummary{
|
||||
Capacity: int64(dbChannel.Capacity),
|
||||
RemotePubkey: nodeID,
|
||||
@@ -4240,6 +4260,37 @@ func (r *rpcServer) createRPCClosedChannel(
|
||||
ClosingTxHash: dbChannel.ClosingTXID.String(),
|
||||
OpenInitiator: openInit,
|
||||
CloseInitiator: closeInitiator,
|
||||
AliasScids: make([]uint64, 0, len(channelAliases)),
|
||||
}
|
||||
|
||||
// Populate the set of aliases.
|
||||
for _, chanAlias := range channelAliases {
|
||||
channel.AliasScids = append(
|
||||
channel.AliasScids, chanAlias.ToUint64(),
|
||||
)
|
||||
}
|
||||
|
||||
// Populate any historical data that the summary needs.
|
||||
histChan, err := r.server.chanStateDB.FetchHistoricalChannel(
|
||||
&dbChannel.ChanPoint,
|
||||
)
|
||||
switch err {
|
||||
// The channel was closed in a pre-historic version of lnd. Ignore the
|
||||
// error.
|
||||
case channeldb.ErrNoHistoricalBucket:
|
||||
case channeldb.ErrChannelNotFound:
|
||||
|
||||
case nil:
|
||||
if histChan.IsZeroConf() && histChan.ZeroConfConfirmed() {
|
||||
// If the channel was zero-conf, it may have confirmed.
|
||||
// Populate the confirmed SCID if so.
|
||||
confirmedScid := histChan.ZeroConfRealScid().ToUint64()
|
||||
channel.ZeroConfConfirmedScid = confirmedScid
|
||||
}
|
||||
|
||||
// Non-nil error not due to older versions of lnd.
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
|
||||
reports, err := r.server.miscDB.FetchChannelReports(
|
||||
|
||||
Reference in new issue
Block a user