From be7fc9dd3ecb6ecf16716a5743a5599451f693c8 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Thu, 12 Sep 2019 15:31:48 +0200 Subject: [PATCH] cnct: do not create an action for incoming dust htlcs This commit fixes the 'unable to find incoming resolution' error that occured when trying to resolve incoming htlcs below the dust limit that are not actually present on the commitment tx. --- contractcourt/channel_arbitrator.go | 9 +++++++++ contractcourt/channel_arbitrator_test.go | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/contractcourt/channel_arbitrator.go b/contractcourt/channel_arbitrator.go index 47004d1d..9008894f 100644 --- a/contractcourt/channel_arbitrator.go +++ b/contractcourt/channel_arbitrator.go @@ -1316,6 +1316,15 @@ func (c *ChannelArbitrator) checkCommitChainActions(height uint32, // either learn of it eventually from the outgoing HTLC, or the sender // will timeout the HTLC. for _, htlc := range htlcs.incomingHTLCs { + // If the HTLC is dust, there is no action to be taken. + if htlc.OutputIndex < 0 { + log.Debugf("ChannelArbitrator(%v): no resolution "+ + "needed for incoming dust htlc=%x", + c.cfg.ChanPoint, htlc.RHash[:]) + + continue + } + log.Tracef("ChannelArbitrator(%v): watching chain to decide "+ "action for incoming htlc=%x", c.cfg.ChanPoint, htlc.RHash[:]) diff --git a/contractcourt/channel_arbitrator_test.go b/contractcourt/channel_arbitrator_test.go index c0f78e62..7b413669 100644 --- a/contractcourt/channel_arbitrator_test.go +++ b/contractcourt/channel_arbitrator_test.go @@ -527,8 +527,15 @@ func TestChannelArbitratorLocalForceClosePendingHtlc(t *testing.T) { OutputIndex: -1, } + incomingDustHtlc := channeldb.HTLC{ + Incoming: true, + Amt: 105, + HtlcIndex: 101, + OutputIndex: -1, + } + htlcSet := []channeldb.HTLC{ - htlc, outgoingDustHtlc, + htlc, outgoingDustHtlc, incomingDustHtlc, } htlcUpdates <- &ContractUpdate{