mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-19 00:00:21 +02:00
rpcserver: use HtlcIndex
as the unique key
This commit is contained in:
parent
70dec8e169
commit
43409c7840
22
rpcserver.go
22
rpcserver.go
@ -4841,12 +4841,17 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
|
||||
)
|
||||
}
|
||||
|
||||
// Create a set of the HTLCs found in the remote commitment, which is
|
||||
// Create two sets 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]()
|
||||
remoteIncomingHTLCs := fn.NewSet[uint64]()
|
||||
remoteOutgoingHTLCs := fn.NewSet[uint64]()
|
||||
for _, htlc := range dbChannel.RemoteCommitment.Htlcs {
|
||||
remoteHTLCs.Add(htlc.RHash)
|
||||
if htlc.Incoming {
|
||||
remoteIncomingHTLCs.Add(htlc.HtlcIndex)
|
||||
} else {
|
||||
remoteOutgoingHTLCs.Add(htlc.HtlcIndex)
|
||||
}
|
||||
}
|
||||
|
||||
for i, htlc := range localCommit.Htlcs {
|
||||
@ -4855,7 +4860,10 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
|
||||
|
||||
circuitMap := r.server.htlcSwitch.CircuitLookup()
|
||||
|
||||
var forwardingChannel, forwardingHtlcIndex uint64
|
||||
var (
|
||||
forwardingChannel, forwardingHtlcIndex uint64
|
||||
lockedIn bool
|
||||
)
|
||||
switch {
|
||||
case htlc.Incoming:
|
||||
circuit := circuitMap.LookupCircuit(
|
||||
@ -4871,6 +4879,8 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
|
||||
forwardingHtlcIndex = circuit.Outgoing.HtlcID
|
||||
}
|
||||
|
||||
lockedIn = remoteIncomingHTLCs.Contains(htlc.HtlcIndex)
|
||||
|
||||
case !htlc.Incoming:
|
||||
circuit := circuitMap.LookupOpenCircuit(
|
||||
htlcswitch.CircuitKey{
|
||||
@ -4890,6 +4900,8 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
|
||||
|
||||
forwardingHtlcIndex = circuit.Incoming.HtlcID
|
||||
}
|
||||
|
||||
lockedIn = remoteOutgoingHTLCs.Contains(htlc.HtlcIndex)
|
||||
}
|
||||
|
||||
channel.PendingHtlcs[i] = &lnrpc.HTLC{
|
||||
@ -4900,7 +4912,7 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
|
||||
HtlcIndex: htlc.HtlcIndex,
|
||||
ForwardingChannel: forwardingChannel,
|
||||
ForwardingHtlcIndex: forwardingHtlcIndex,
|
||||
LockedIn: remoteHTLCs.Contains(rHash),
|
||||
LockedIn: lockedIn,
|
||||
}
|
||||
|
||||
// Add the Pending Htlc Amount to UnsettledBalance field.
|
||||
|
Loading…
x
Reference in New Issue
Block a user