lnrpc+rpcserver: add new field LockedIn for HTLCs

In this commit, we add a new field `LockedIn` on HTLCs so it can be used
to decide whether an HTLC found on the local commitment has been
committed on the remote commitment.
This commit is contained in:
yyforyongyu committed 2025-03-21 03:25:23 +08:00
1 parent be4c4cc8ff
commit 0892b595dd
4 files changed
+2748 -2715

No files matched your search

+2728 -2715
View File
File diff suppressed because it is too large. Load diff
+7
View File
@@ -1381,6 +1381,13 @@ message HTLC {
// Index identifying the htlc on the forwarding channel.
uint64 forwarding_htlc_index = 7;
/*
Whether the HTLC is locked in. An HTLC is considered locked in when the
remote party has sent us the `revoke_and_ack` to irrevocably commit this
HTLC.
*/
bool locked_in = 8;
}
enum CommitmentType {
+4
View File
@@ -5302,6 +5302,10 @@
"type": "string",
"format": "uint64",
"description": "Index identifying the htlc on the forwarding channel."
},
"locked_in": {
"type": "boolean",
"description": "Whether the HTLC is locked in. An HTLC is considered locked in when the\nremote party has sent us the `revoke_and_ack` to irrevocably commit this\nHTLC."
}
}
},
+9
View File
@@ -4842,6 +4842,14 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
)
}
// Create a set of the HTLCs found in the remote commitment, which is
// used to decide whether the HTLCs from the local commitment has been
// locked in or not.
remoteHTLCs := fn.NewSet[[32]byte]()
for _, htlc := range dbChannel.RemoteCommitment.Htlcs {
remoteHTLCs.Add(htlc.RHash)
}
for i, htlc := range localCommit.Htlcs {
var rHash [32]byte
copy(rHash[:], htlc.RHash[:])
@@ -4893,6 +4901,7 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
HtlcIndex: htlc.HtlcIndex,
ForwardingChannel: forwardingChannel,
ForwardingHtlcIndex: forwardingHtlcIndex,
LockedIn: remoteHTLCs.Contains(rHash),
}
// Add the Pending Htlc Amount to UnsettledBalance field.