Skip to content

Commit 3b50a5c

Browse files
committed
doublespendinputs: allow RBF per default
1 parent d5d5a91 commit 3b50a5c

File tree

6 files changed

+24
-2
lines changed

6 files changed

+24
-2
lines changed

cmd/chantools/doublespendinputs.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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))

doc/chantools_doublespendinputs.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ chantools doublespendinputs \
1919
--inputoutpoints xxxxxxxxx:y,xxxxxxxxx:y \
2020
--sweepaddr bc1q..... \
2121
--feerate 10 \
22+
--rbf=true \
2223
--publish
2324
```
2425

@@ -31,6 +32,7 @@ chantools doublespendinputs \
3132
-h, --help help for doublespendinputs
3233
--inputoutpoints strings list of outpoints to double spend in the format txid:vout
3334
--publish publish replacement TX to the chain API instead of just printing the TX
35+
--rbf choose RBF flag for this double spend transaction. (Be sure to use '=' with this argument) (default true)
3436
--recoverywindow uint32 number of keys to scan per internal/external branch; output will consist of double this amount of keys (default 2500)
3537
--rootkey string BIP32 HD root key of the wallet to use for deriving the input keys; leave empty to prompt for lnd 24 word aezeed
3638
--sweepaddr string address to recover the funds to; specify 'fromseed' to derive a new address from the seed automatically

doc/chantools_fakechanbackup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ chantools fakechanbackup --from_channel_graph lncli_describegraph.json \
6161
--channelpoint string funding transaction outpoint of the channel to rescue (<txid>:<txindex>) as it is displayed on 1ml.com
6262
--from_channel_graph string the full LN channel graph in the JSON format that the 'lncli describegraph' returns
6363
-h, --help help for fakechanbackup
64-
--multi_file string the fake channel backup file to create (default "results/fake-2023-04-11-16-33-35.backup")
64+
--multi_file string the fake channel backup file to create (default "results/fake-2024-01-26-02-27-52.backup")
6565
--remote_node_addr string the remote node connection information in the format pubkey@host:port
6666
--rootkey string BIP32 HD root key of the wallet to use for encrypting the backup; leave empty to prompt for lnd 24 word aezeed
6767
--short_channel_id string the short channel ID in the format <blockheight>x<transactionindex>x<outputindex>

doc/chantools_recoverloopin.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ chantools recoverloopin \
2727
-h, --help help for recoverloopin
2828
--loop_db_dir string path to the loop database directory, where the loop.db file is located
2929
--num_tries int number of tries to try to find the correct key index (default 1000)
30+
--output_amt uint amount of the output to sweep
3031
--publish publish sweep TX to the chain API instead of just printing the TX
3132
--rootkey string BIP32 HD root key of the wallet to use for deriving starting key; leave empty to prompt for lnd 24 word aezeed
3233
--start_key_index int start key index to try to find the correct key index

doc/chantools_zombierecovery_makeoffer.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ chantools zombierecovery makeoffer \
3131
--bip39 read a classic BIP39 seed and passphrase from the terminal instead of asking for lnd seed format or providing the --rootkey flag
3232
--feerate uint32 fee rate to use for the sweep transaction in sat/vByte (default 30)
3333
-h, --help help for makeoffer
34+
--matchonly only match the keys, don't create an offer
3435
--node1_keys string the JSON file generated in theprevious step ('preparekeys') command of node 1
3536
--node2_keys string the JSON file generated in theprevious step ('preparekeys') command of node 2
3637
--rootkey string BIP32 HD root key of the wallet to use for signing the offer; leave empty to prompt for lnd 24 word aezeed

doc/chantools_zombierecovery_preparekeys.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ chantools zombierecovery preparekeys \
2828
--bip39 read a classic BIP39 seed and passphrase from the terminal instead of asking for lnd seed format or providing the --rootkey flag
2929
-h, --help help for preparekeys
3030
--match_file string the match JSON file that was sent to both nodes by the match maker
31+
--num_keys uint32 the number of multisig keys to derive (default 2500)
3132
--payout_addr string the address where this node's rescued funds should be sent to, must be a P2WPKH (native SegWit) address
3233
--rootkey string BIP32 HD root key of the wallet to use for deriving the multisig keys; leave empty to prompt for lnd 24 word aezeed
3334
```

0 commit comments

Comments
 (0)