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 2018-04-13 16:50:31 +02:00
parent b0709b45f7
commit daeeca0bc3
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

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,
}
}