rpcserver: make copy of htlc rhash before returning in listchannels
This commit fixes a bug where all the HTLC rhash slices in a ListChannelsResponse would be tied to the loop variable, making them all take the hash of the last HTLC in the list. This commit fixes it by making a copy of the slice.
This commit is contained in:
parent
b0709b45f7
commit
daeeca0bc3
@ -1636,10 +1636,12 @@ func (r *rpcServer) ListChannels(ctx context.Context,
|
||||
}
|
||||
|
||||
for i, htlc := range localCommit.Htlcs {
|
||||
var rHash [32]byte
|
||||
copy(rHash[:], htlc.RHash[:])
|
||||
channel.PendingHtlcs[i] = &lnrpc.HTLC{
|
||||
Incoming: htlc.Incoming,
|
||||
Amount: int64(htlc.Amt.ToSatoshis()),
|
||||
HashLock: htlc.RHash[:],
|
||||
HashLock: rHash[:],
|
||||
ExpirationHeight: htlc.RefundTimeout,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user