@@ -50,11 +50,16 @@ type SwapKit struct {
5050 // AddressParams is the chain parameters of the chain the deposit is
5151 // being created on.
5252 AddressParams * address.ChainParams
53+
54+ // CheckCSV indicates whether the success path script should include a
55+ // CHECKSEQUENCEVERIFY check. This is used to prevent potential pinning
56+ // attacks when the HTLC is not part of a package relay.
57+ CheckCSV bool
5358}
5459
5560// GetSuccessScript returns the success path script of the swap HTLC.
5661func (s * SwapKit ) GetSuccessScript () ([]byte , error ) {
57- return GenSuccessPathScript (s .ReceiverPubKey , s .SwapHash )
62+ return GenSuccessPathScript (s .ReceiverPubKey , s .SwapHash , s . CheckCSV )
5863}
5964
6065// GetTimeoutScript returns the timeout path script of the swap HTLC.
@@ -160,10 +165,8 @@ func (s *SwapKit) CreateHtlcVpkt() (*tappsbt.VPacket, error) {
160165 ScriptKey : asset .NUMSScriptKey ,
161166 })
162167 pkt .Outputs = append (pkt .Outputs , & tappsbt.VOutput {
163- // todo(sputn1ck) assetversion
164- AssetVersion : asset .Version (1 ),
168+ AssetVersion : asset .V1 ,
165169 Amount : uint64 (s .Amount ),
166- Interactive : true ,
167170 AnchorOutputIndex : 1 ,
168171 ScriptKey : asset .NewScriptKey (
169172 tapScriptKey .PubKey ,
@@ -337,7 +340,9 @@ func (s *SwapKit) CreatePreimageWitness(ctx context.Context,
337340 Value : sweepBtcPacket .Inputs [1 ].WitnessUtxo .Value ,
338341 }
339342
340- //sweepBtcPacket.UnsignedTx.TxIn[0].Sequence = 1
343+ if s .CheckCSV {
344+ sweepBtcPacket .UnsignedTx .TxIn [0 ].Sequence = 1
345+ }
341346
342347 successScript , err := s .GetSuccessScript ()
343348 if err != nil {
0 commit comments