@@ -47,11 +47,16 @@ type SwapKit struct {
47
47
// AddressParams is the chain parameters of the chain the deposit is
48
48
// being created on.
49
49
AddressParams * address.ChainParams
50
+
51
+ // CheckCSV indicates whether the success path script should include a
52
+ // CHECKSEQUENCEVERIFY check. This is used to prevent potential pinning
53
+ // attacks when the HTLC is not part of a package relay.
54
+ CheckCSV bool
50
55
}
51
56
52
57
// GetSuccessScript returns the success path script of the swap HTLC.
53
58
func (s * SwapKit ) GetSuccessScript () ([]byte , error ) {
54
- return GenSuccessPathScript (s .ReceiverPubKey , s .SwapHash )
59
+ return GenSuccessPathScript (s .ReceiverPubKey , s .SwapHash , s . CheckCSV )
55
60
}
56
61
57
62
// GetTimeoutScript returns the timeout path script of the swap HTLC.
@@ -158,10 +163,8 @@ func (s *SwapKit) CreateHtlcVpkt() (*tappsbt.VPacket, error) {
158
163
ScriptKey : asset .NUMSScriptKey ,
159
164
})
160
165
pkt .Outputs = append (pkt .Outputs , & tappsbt.VOutput {
161
- // todo(sputn1ck) assetversion
162
- AssetVersion : asset .Version (1 ),
166
+ AssetVersion : asset .V1 ,
163
167
Amount : uint64 (s .Amount ),
164
- Interactive : true ,
165
168
AnchorOutputIndex : 1 ,
166
169
ScriptKey : asset .NewScriptKey (
167
170
tapScriptKey .PubKey ,
@@ -194,7 +197,7 @@ func (s *SwapKit) GenTimeoutBtcControlBlock(taprootAssetRoot []byte) (
194
197
InternalKey : internalKey ,
195
198
LeafVersion : txscript .BaseLeafVersion ,
196
199
InclusionProof : append (
197
- successLeafHash [:], taprootAssetRoot [:] ... ,
200
+ successLeafHash [:], taprootAssetRoot ... ,
198
201
),
199
202
}
200
203
@@ -235,7 +238,7 @@ func (s *SwapKit) GenSuccessBtcControlBlock(taprootAssetRoot []byte) (
235
238
InternalKey : internalKey ,
236
239
LeafVersion : txscript .BaseLeafVersion ,
237
240
InclusionProof : append (
238
- timeOutLeafHash [:], taprootAssetRoot [:] ... ,
241
+ timeOutLeafHash [:], taprootAssetRoot ... ,
239
242
),
240
243
}
241
244
@@ -324,7 +327,9 @@ func (s *SwapKit) CreatePreimageWitness(ctx context.Context,
324
327
Value : sweepBtcPacket .Inputs [1 ].WitnessUtxo .Value ,
325
328
}
326
329
327
- //sweepBtcPacket.UnsignedTx.TxIn[0].Sequence = 1
330
+ if s .CheckCSV {
331
+ sweepBtcPacket .UnsignedTx .TxIn [0 ].Sequence = 1
332
+ }
328
333
329
334
successScript , err := s .GetSuccessScript ()
330
335
if err != nil {
0 commit comments