diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 96b38b11..9aba9d13 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -1736,11 +1736,11 @@ func (lc *LightningChannel) CancelHTLC(rHash [32]byte) (uint32, error) { if addEntry == nil { return 0, fmt.Errorf("unable to find HTLC to cancel") } - pd := &PaymentDescriptor{ Amount: addEntry.Amount, - Index: lc.ourLogCounter, + RHash: addEntry.RHash, ParentIndex: addEntry.Index, + Index: lc.ourLogCounter, EntryType: Cancel, } @@ -1766,6 +1766,7 @@ func (lc *LightningChannel) ReceiveCancelHTLC(logIndex uint32) error { htlc := addEntry.Value.(*PaymentDescriptor) pd := &PaymentDescriptor{ Amount: htlc.Amount, + RHash: htlc.RHash, ParentIndex: htlc.Index, Index: lc.theirLogCounter, EntryType: Cancel, diff --git a/lnwallet/channel_test.go b/lnwallet/channel_test.go index b21d81ed..f04f32a3 100644 --- a/lnwallet/channel_test.go +++ b/lnwallet/channel_test.go @@ -1222,10 +1222,18 @@ func TestCancelHTLC(t *testing.T) { len(aliceChannel.remoteCommitChain.tip().outgoingHTLCs) != 0 { t.Fatalf("htlc's still active from alice's POV") } + if len(aliceChannel.localCommitChain.tip().incomingHTLCs) != 0 || + len(aliceChannel.remoteCommitChain.tip().incomingHTLCs) != 0 { + t.Fatalf("htlc's still active from alice's POV") + } if len(bobChannel.localCommitChain.tip().outgoingHTLCs) != 0 || len(bobChannel.remoteCommitChain.tip().outgoingHTLCs) != 0 { t.Fatalf("htlc's still active from bob's POV") } + if len(bobChannel.localCommitChain.tip().incomingHTLCs) != 0 || + len(bobChannel.remoteCommitChain.tip().incomingHTLCs) != 0 { + t.Fatalf("htlc's still active from bob's POV") + } expectedBalance := btcutil.Amount(btcutil.SatoshiPerBitcoin * 5) if aliceChannel.channelState.OurBalance != expectedBalance {