From c3560932b6f1786cf3ac0f9e9fdad4d324ee0d7f Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Thu, 1 Nov 2018 16:53:18 +0100 Subject: [PATCH 1/2] cnct: fix log line --- contractcourt/contract_resolvers.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contractcourt/contract_resolvers.go b/contractcourt/contract_resolvers.go index aa743856..6d3570a1 100644 --- a/contractcourt/contract_resolvers.go +++ b/contractcourt/contract_resolvers.go @@ -837,7 +837,8 @@ func (h *htlcOutgoingContestResolver) Resolve() (ContractResolver, error) { if uint32(currentHeight) >= h.htlcResolution.Expiry-1 { log.Infof("%T(%v): HTLC has expired (height=%v, expiry=%v), "+ "transforming into timeout resolver", h, - h.htlcResolution.ClaimOutpoint) + h.htlcResolution.ClaimOutpoint, currentHeight, + h.htlcResolution.Expiry) return &h.htlcTimeoutResolver, nil } From 839752857fe8f72a08bead01e23433e71aa1bb95 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Fri, 2 Nov 2018 10:00:13 +0100 Subject: [PATCH 2/2] cnct: add comment on expiry calculation --- contractcourt/contract_resolvers.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/contractcourt/contract_resolvers.go b/contractcourt/contract_resolvers.go index 6d3570a1..71ea72dc 100644 --- a/contractcourt/contract_resolvers.go +++ b/contractcourt/contract_resolvers.go @@ -834,6 +834,16 @@ func (h *htlcOutgoingContestResolver) Resolve() (ContractResolver, error) { // If the current height is >= expiry-1, then a spend will be valid to // be included in the next block, and we can immediately return the // resolver. + // + // TODO(joostjager): Statement above may not be valid. For CLTV locks, + // the expiry value is the last _invalid_ block. The likely reason that + // this does not create a problem, is that utxonursery is checking the + // expiry again (in the proper way). Same holds for minus one operation + // below. + // + // Source: + // https://github.com/btcsuite/btcd/blob/991d32e72fe84d5fbf9c47cd604d793a0cd3a072/blockchain/validate.go#L154 + if uint32(currentHeight) >= h.htlcResolution.Expiry-1 { log.Infof("%T(%v): HTLC has expired (height=%v, expiry=%v), "+ "transforming into timeout resolver", h,