@@ -4841,12 +4841,17 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
4841
4841
)
4842
4842
}
4843
4843
4844
- // Create a set of the HTLCs found in the remote commitment, which is
4844
+ // Create two sets of the HTLCs found in the remote commitment, which is
4845
4845
// used to decide whether the HTLCs from the local commitment has been
4846
4846
// locked in or not.
4847
- remoteHTLCs := fn .NewSet [[32 ]byte ]()
4847
+ remoteIncomingHTLCs := fn .NewSet [uint64 ]()
4848
+ remoteOutgoingHTLCs := fn .NewSet [uint64 ]()
4848
4849
for _ , htlc := range dbChannel .RemoteCommitment .Htlcs {
4849
- remoteHTLCs .Add (htlc .RHash )
4850
+ if htlc .Incoming {
4851
+ remoteIncomingHTLCs .Add (htlc .HtlcIndex )
4852
+ } else {
4853
+ remoteOutgoingHTLCs .Add (htlc .HtlcIndex )
4854
+ }
4850
4855
}
4851
4856
4852
4857
for i , htlc := range localCommit .Htlcs {
@@ -4855,7 +4860,10 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
4855
4860
4856
4861
circuitMap := r .server .htlcSwitch .CircuitLookup ()
4857
4862
4858
- var forwardingChannel , forwardingHtlcIndex uint64
4863
+ var (
4864
+ forwardingChannel , forwardingHtlcIndex uint64
4865
+ lockedIn bool
4866
+ )
4859
4867
switch {
4860
4868
case htlc .Incoming :
4861
4869
circuit := circuitMap .LookupCircuit (
@@ -4871,6 +4879,8 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
4871
4879
forwardingHtlcIndex = circuit .Outgoing .HtlcID
4872
4880
}
4873
4881
4882
+ lockedIn = remoteIncomingHTLCs .Contains (htlc .HtlcIndex )
4883
+
4874
4884
case ! htlc .Incoming :
4875
4885
circuit := circuitMap .LookupOpenCircuit (
4876
4886
htlcswitch.CircuitKey {
@@ -4890,6 +4900,8 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
4890
4900
4891
4901
forwardingHtlcIndex = circuit .Incoming .HtlcID
4892
4902
}
4903
+
4904
+ lockedIn = remoteOutgoingHTLCs .Contains (htlc .HtlcIndex )
4893
4905
}
4894
4906
4895
4907
channel .PendingHtlcs [i ] = & lnrpc.HTLC {
@@ -4900,7 +4912,7 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
4900
4912
HtlcIndex : htlc .HtlcIndex ,
4901
4913
ForwardingChannel : forwardingChannel ,
4902
4914
ForwardingHtlcIndex : forwardingHtlcIndex ,
4903
- LockedIn : remoteHTLCs . Contains ( rHash ) ,
4915
+ LockedIn : lockedIn ,
4904
4916
}
4905
4917
4906
4918
// Add the Pending Htlc Amount to UnsettledBalance field.
0 commit comments