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:
Johan T. Halseth committed 2018-04-15 11:36:20 +02:00
1 parent b0709b45f7
commit daeeca0bc3
1 file changed
+3 -1
+3 -1
View File
@@ -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,
}
}