@@ -21,7 +21,7 @@ import (
21
21
"github.com/lightningnetwork/lnd/lntypes"
22
22
)
23
23
24
- var (
24
+ const (
25
25
// Define route independent max routing fees. We have currently no way
26
26
// to get a reliable estimate of the routing fees. Best we can do is
27
27
// the minimum routing fees, which is not very indicative.
46
46
// defaultPollPaymentTime is the default time to poll the server for the
47
47
// payment status.
48
48
defaultPollPaymentTime = time .Second * 15
49
+
50
+ // htlcExpiryDelta is the delta in blocks we require between the htlc
51
+ // expiry and reservation expiry.
52
+ htlcExpiryDelta = int32 (40 )
49
53
)
50
54
51
55
// InitInstantOutCtx contains the context for the InitInstantOutAction.
@@ -96,6 +100,15 @@ func (f *FSM) InitInstantOutAction(eventCtx fsm.EventContext) fsm.EventType {
96
100
reservationAmt += uint64 (res .Value )
97
101
reservationIds = append (reservationIds , resId [:])
98
102
reservations = append (reservations , res )
103
+
104
+ // Check that the reservation expiry is larger than the cltv
105
+ // expiry of the swap, with an additional delta to allow for
106
+ // preimage reveal.
107
+ if int32 (res .Expiry ) < initCtx .cltvExpiry + htlcExpiryDelta {
108
+ return f .HandleError (fmt .Errorf ("reservation %x has " +
109
+ "expiry %v which is less than the swap expiry %v" ,
110
+ resId , res .Expiry , initCtx .cltvExpiry ))
111
+ }
99
112
}
100
113
101
114
// Create the preimage for the swap.
0 commit comments