@@ -50,11 +50,16 @@ type SwapKit struct {
50
50
// AddressParams is the chain parameters of the chain the deposit is
51
51
// being created on.
52
52
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
53
58
}
54
59
55
60
// GetSuccessScript returns the success path script of the swap HTLC.
56
61
func (s * SwapKit ) GetSuccessScript () ([]byte , error ) {
57
- return GenSuccessPathScript (s .ReceiverPubKey , s .SwapHash )
62
+ return GenSuccessPathScript (s .ReceiverPubKey , s .SwapHash , s . CheckCSV )
58
63
}
59
64
60
65
// GetTimeoutScript returns the timeout path script of the swap HTLC.
@@ -160,10 +165,8 @@ func (s *SwapKit) CreateHtlcVpkt() (*tappsbt.VPacket, error) {
160
165
ScriptKey : asset .NUMSScriptKey ,
161
166
})
162
167
pkt .Outputs = append (pkt .Outputs , & tappsbt.VOutput {
163
- // todo(sputn1ck) assetversion
164
- AssetVersion : asset .Version (1 ),
168
+ AssetVersion : asset .V1 ,
165
169
Amount : uint64 (s .Amount ),
166
- Interactive : true ,
167
170
AnchorOutputIndex : 1 ,
168
171
ScriptKey : asset .NewScriptKey (
169
172
tapScriptKey .PubKey ,
@@ -337,7 +340,9 @@ func (s *SwapKit) CreatePreimageWitness(ctx context.Context,
337
340
Value : sweepBtcPacket .Inputs [1 ].WitnessUtxo .Value ,
338
341
}
339
342
340
- //sweepBtcPacket.UnsignedTx.TxIn[0].Sequence = 1
343
+ if s .CheckCSV {
344
+ sweepBtcPacket .UnsignedTx .TxIn [0 ].Sequence = 1
345
+ }
341
346
342
347
successScript , err := s .GetSuccessScript ()
343
348
if err != nil {
0 commit comments