@@ -8201,6 +8201,8 @@ type chanCloseOpt struct {
8201
8201
customSort CloseSortFunc
8202
8202
8203
8203
customSequence fn.Option [uint32 ]
8204
+
8205
+ customLockTime fn.Option [uint32 ]
8204
8206
}
8205
8207
8206
8208
// ChanCloseOpt is a closure type that cen be used to modify the set of default
@@ -8234,7 +8236,7 @@ func WithExtraCloseOutputs(extraOutputs []CloseOutput) ChanCloseOpt {
8234
8236
func WithCustomCoopSort (sorter CloseSortFunc ) ChanCloseOpt {
8235
8237
return func (opts * chanCloseOpt ) {
8236
8238
opts .customSort = sorter
8237
- }
8239
+ }
8238
8240
}
8239
8241
8240
8242
// WithCustomSequence can be used to specify a custom sequence number for the
@@ -8245,6 +8247,14 @@ func WithCustomSequence(sequence uint32) ChanCloseOpt {
8245
8247
}
8246
8248
}
8247
8249
8250
+ // WithCustomLockTime can be used to specify a custom lock time for the coop
8251
+ // close transaction.
8252
+ func WithCustomLockTime (lockTime uint32 ) ChanCloseOpt {
8253
+ return func (opts * chanCloseOpt ) {
8254
+ opts .customLockTime = fn .Some (lockTime )
8255
+ }
8256
+ }
8257
+
8248
8258
// CreateCloseProposal is used by both parties in a cooperative channel close
8249
8259
// workflow to generate proposed close transactions and signatures. This method
8250
8260
// should only be executed once all pending HTLCs (if any) on the channel have
@@ -8310,6 +8320,12 @@ func (lc *LightningChannel) CreateCloseProposal(proposedFee btcutil.Amount,
8310
8320
))
8311
8321
})
8312
8322
8323
+ opts .customLockTime .WhenSome (func (lockTime uint32 ) {
8324
+ closeTxOpts = append (closeTxOpts , WithCustomTxLockTime (
8325
+ lockTime ,
8326
+ ))
8327
+ })
8328
+
8313
8329
closeTx , err := CreateCooperativeCloseTx (
8314
8330
fundingTxIn (lc .channelState ), lc .channelState .LocalChanCfg .DustLimit ,
8315
8331
lc .channelState .RemoteChanCfg .DustLimit , ourBalance , theirBalance ,
@@ -8417,6 +8433,12 @@ func (lc *LightningChannel) CompleteCooperativeClose(
8417
8433
))
8418
8434
})
8419
8435
8436
+ opts .customLockTime .WhenSome (func (lockTime uint32 ) {
8437
+ closeTxOpts = append (closeTxOpts , WithCustomTxLockTime (
8438
+ lockTime ,
8439
+ ))
8440
+ })
8441
+
8420
8442
// Create the transaction used to return the current settled balance
8421
8443
// on this active channel back to both parties. In this current model,
8422
8444
// the initiator pays full fees for the cooperative close transaction.
@@ -9138,6 +9160,8 @@ type closeTxOpts struct {
9138
9160
// close transaction. This gives slightly more control compared to the
9139
9161
// enableRBF option.
9140
9162
customSequence fn.Option [uint32 ]
9163
+
9164
+ customLockTime fn.Option [uint32 ]
9141
9165
}
9142
9166
9143
9167
// defaultCloseTxOpts returns a closeTxOpts struct with default values.
@@ -9171,7 +9195,7 @@ func WithExtraTxCloseOutputs(extraOutputs []CloseOutput) CloseTxOpt {
9171
9195
func WithCustomTxSort (sorter CloseSortFunc ) CloseTxOpt {
9172
9196
return func (opts * closeTxOpts ) {
9173
9197
opts .customSort = sorter
9174
- }
9198
+ }
9175
9199
}
9176
9200
9177
9201
// WithCustomTxInSequence allows a caller to set a custom sequence on the sole
@@ -9182,6 +9206,12 @@ func WithCustomTxInSequence(sequence uint32) CloseTxOpt {
9182
9206
}
9183
9207
}
9184
9208
9209
+ func WithCustomTxLockTime (lockTime uint32 ) CloseTxOpt {
9210
+ return func (o * closeTxOpts ) {
9211
+ o .customLockTime = fn .Some (lockTime )
9212
+ }
9213
+ }
9214
+
9185
9215
// CreateCooperativeCloseTx creates a transaction which if signed by both
9186
9216
// parties, then broadcast cooperatively closes an active channel. The creation
9187
9217
// of the closure transaction is modified by a boolean indicating if the party
@@ -9216,6 +9246,10 @@ func CreateCooperativeCloseTx(fundingTxIn wire.TxIn,
9216
9246
closeTx := wire .NewMsgTx (2 )
9217
9247
closeTx .AddTxIn (& fundingTxIn )
9218
9248
9249
+ opts .customLockTime .WhenSome (func (lockTime uint32 ) {
9250
+ closeTx .LockTime = lockTime
9251
+ })
9252
+
9219
9253
// TODO(roasbeef): needs support for dropping inputs
9220
9254
9221
9255
// Create both cooperative closure outputs, properly respecting the
0 commit comments