cnct: add comment on expiry calculation

This commit is contained in:
Joost Jager 2018-11-02 10:00:13 +01:00
parent c3560932b6
commit 839752857f
No known key found for this signature in database
GPG Key ID: AE6B0D042C8E38D9

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