Merge pull request #2166 from joostjager/cnct-fixes
cnct: add todo for invalid expiry value handling
This commit is contained in:
commit
b0c6f666f6
@ -834,10 +834,21 @@ func (h *htlcOutgoingContestResolver) Resolve() (ContractResolver, error) {
|
|||||||
// If the current height is >= expiry-1, then a spend will be valid to
|
// 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
|
// be included in the next block, and we can immediately return the
|
||||||
// resolver.
|
// 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 {
|
if uint32(currentHeight) >= h.htlcResolution.Expiry-1 {
|
||||||
log.Infof("%T(%v): HTLC has expired (height=%v, expiry=%v), "+
|
log.Infof("%T(%v): HTLC has expired (height=%v, expiry=%v), "+
|
||||||
"transforming into timeout resolver", h,
|
"transforming into timeout resolver", h,
|
||||||
h.htlcResolution.ClaimOutpoint)
|
h.htlcResolution.ClaimOutpoint, currentHeight,
|
||||||
|
h.htlcResolution.Expiry)
|
||||||
return &h.htlcTimeoutResolver, nil
|
return &h.htlcTimeoutResolver, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user