Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doublespendinputs: allow RBF per default #118

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmd/chantools/doublespendinputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/hdkeychain"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/mempool"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
Expand Down Expand Up @@ -232,7 +233,10 @@ func (c *doubleSpendInputs) Execute(_ *cobra.Command, _ []string) error {

// Add the inputs.
for _, outpoint := range outpoints {
tx.AddTxIn(wire.NewTxIn(outpoint, nil, nil))
tx.AddTxIn(&wire.TxIn{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AddTxIn already uses wire.MaxTxInSequenceNum under the hood. So I don't think any change is required? I don't think it makes sense to be able to turn off RBF?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default it usse is indeed

	// MaxTxInSequenceNum is the maximum sequence number the sequence field
	// of a transaction input can be.
	MaxTxInSequenceNum uint32 = 0xffffffff

but this value disallows RBF.

therefore to allow RBF this PR changes the default to

	// MaxRBFSequence is the maximum sequence number an input can use to
	// signal that the transaction spending it can be replaced using the
	// Replace-By-Fee (RBF) policy.
	MaxRBFSequence = 0xfffffffd

and introduces a switch to give the users the possibility to make a final transactions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you're right. I got the two values confused. So I guess we'll just want RBF to be the default, no need to turn it off. Removes the need for the boolean flag which has bad UX if the default is true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so i pushed new commit without the rbf flag.

PreviousOutPoint: *outpoint,
Sequence: mempool.MaxRBFSequence,
})
}

tx.AddTxOut(wire.NewTxOut(int64(totalInput-totalFee), sweepScript))
Expand Down
2 changes: 1 addition & 1 deletion doc/chantools_fakechanbackup.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ chantools fakechanbackup --from_channel_graph lncli_describegraph.json \
--channelpoint string funding transaction outpoint of the channel to rescue (<txid>:<txindex>) as it is displayed on 1ml.com
--from_channel_graph string the full LN channel graph in the JSON format that the 'lncli describegraph' returns
-h, --help help for fakechanbackup
--multi_file string the fake channel backup file to create (default "results/fake-2023-04-11-16-33-35.backup")
--multi_file string the fake channel backup file to create (default "results/fake-2024-01-26-02-27-52.backup")
--remote_node_addr string the remote node connection information in the format pubkey@host:port
--rootkey string BIP32 HD root key of the wallet to use for encrypting the backup; leave empty to prompt for lnd 24 word aezeed
--short_channel_id string the short channel ID in the format <blockheight>x<transactionindex>x<outputindex>
Expand Down
1 change: 1 addition & 0 deletions doc/chantools_recoverloopin.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ chantools recoverloopin \
-h, --help help for recoverloopin
--loop_db_dir string path to the loop database directory, where the loop.db file is located
--num_tries int number of tries to try to find the correct key index (default 1000)
--output_amt uint amount of the output to sweep
--publish publish sweep TX to the chain API instead of just printing the TX
--rootkey string BIP32 HD root key of the wallet to use for deriving starting key; leave empty to prompt for lnd 24 word aezeed
--start_key_index int start key index to try to find the correct key index
Expand Down
1 change: 1 addition & 0 deletions doc/chantools_zombierecovery_makeoffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ chantools zombierecovery makeoffer \
--bip39 read a classic BIP39 seed and passphrase from the terminal instead of asking for lnd seed format or providing the --rootkey flag
--feerate uint32 fee rate to use for the sweep transaction in sat/vByte (default 30)
-h, --help help for makeoffer
--matchonly only match the keys, don't create an offer
--node1_keys string the JSON file generated in theprevious step ('preparekeys') command of node 1
--node2_keys string the JSON file generated in theprevious step ('preparekeys') command of node 2
--rootkey string BIP32 HD root key of the wallet to use for signing the offer; leave empty to prompt for lnd 24 word aezeed
Expand Down
1 change: 1 addition & 0 deletions doc/chantools_zombierecovery_preparekeys.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ chantools zombierecovery preparekeys \
--bip39 read a classic BIP39 seed and passphrase from the terminal instead of asking for lnd seed format or providing the --rootkey flag
-h, --help help for preparekeys
--match_file string the match JSON file that was sent to both nodes by the match maker
--num_keys uint32 the number of multisig keys to derive (default 2500)
--payout_addr string the address where this node's rescued funds should be sent to, must be a P2WPKH (native SegWit) address
--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
```
Expand Down
Loading