@@ -10,6 +10,7 @@ import (
1010 "github.com/btcsuite/btcd/btcutil"
1111 "github.com/btcsuite/btcd/btcutil/hdkeychain"
1212 "github.com/btcsuite/btcd/chaincfg/chainhash"
13+ "github.com/btcsuite/btcd/mempool"
1314 "github.com/btcsuite/btcd/txscript"
1415 "github.com/btcsuite/btcd/wire"
1516 "github.com/decred/dcrd/dcrec/secp256k1/v4"
@@ -26,6 +27,7 @@ type doubleSpendInputs struct {
2627 SweepAddr string
2728 FeeRate uint32
2829 RecoveryWindow uint32
30+ Rbf bool
2931
3032 rootKey * rootKey
3133 cmd * cobra.Command
@@ -43,6 +45,7 @@ only be used with inputs that belong to an lnd wallet.`,
4345 --inputoutpoints xxxxxxxxx:y,xxxxxxxxx:y \
4446 --sweepaddr bc1q..... \
4547 --feerate 10 \
48+ --rbf=true \
4649 --publish` ,
4750 RunE : cc .Execute ,
4851 }
@@ -68,6 +71,10 @@ only be used with inputs that belong to an lnd wallet.`,
6871 "number of keys to scan per internal/external branch; output " +
6972 "will consist of double this amount of keys" ,
7073 )
74+ cc .cmd .Flags ().BoolVar (
75+ & cc .Rbf , "rbf" , true , "choose RBF flag for this double spend " +
76+ "transaction. (Be sure to use '=' with this argument)" ,
77+ )
7178 cc .cmd .Flags ().BoolVar (
7279 & cc .Publish , "publish" , false , "publish replacement TX to " +
7380 "the chain API instead of just printing the TX" ,
@@ -230,9 +237,19 @@ func (c *doubleSpendInputs) Execute(_ *cobra.Command, _ []string) error {
230237 // Create the transaction.
231238 tx := wire .NewMsgTx (2 )
232239
240+ // enable/disable RBF
241+ var sequence uint32 = mempool .MaxRBFSequence
242+ if ! c .Rbf {
243+ sequence = wire .MaxTxInSequenceNum
244+ }
245+
233246 // Add the inputs.
234247 for _ , outpoint := range outpoints {
235- tx .AddTxIn (wire .NewTxIn (outpoint , nil , nil ))
248+
249+ tx .AddTxIn (& wire.TxIn {
250+ PreviousOutPoint : * outpoint ,
251+ Sequence : sequence ,
252+ })
236253 }
237254
238255 tx .AddTxOut (wire .NewTxOut (int64 (totalInput - totalFee ), sweepScript ))
0 commit comments