|
|
|
@ -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"
|
|
|
|
@ -26,6 +27,7 @@ type doubleSpendInputs struct {
|
|
|
|
|
SweepAddr string
|
|
|
|
|
FeeRate uint32
|
|
|
|
|
RecoveryWindow uint32
|
|
|
|
|
Rbf bool
|
|
|
|
|
|
|
|
|
|
rootKey *rootKey
|
|
|
|
|
cmd *cobra.Command
|
|
|
|
@ -43,6 +45,7 @@ only be used with inputs that belong to an lnd wallet.`,
|
|
|
|
|
--inputoutpoints xxxxxxxxx:y,xxxxxxxxx:y \
|
|
|
|
|
--sweepaddr bc1q..... \
|
|
|
|
|
--feerate 10 \
|
|
|
|
|
--rbf=true \
|
|
|
|
|
--publish`,
|
|
|
|
|
RunE: cc.Execute,
|
|
|
|
|
}
|
|
|
|
@ -68,6 +71,10 @@ only be used with inputs that belong to an lnd wallet.`,
|
|
|
|
|
"number of keys to scan per internal/external branch; output "+
|
|
|
|
|
"will consist of double this amount of keys",
|
|
|
|
|
)
|
|
|
|
|
cc.cmd.Flags().BoolVar(
|
|
|
|
|
&cc.Rbf, "rbf", true, "choose RBF flag for this double spend "+
|
|
|
|
|
"transaction. (Be sure to use '=' with this argument)",
|
|
|
|
|
)
|
|
|
|
|
cc.cmd.Flags().BoolVar(
|
|
|
|
|
&cc.Publish, "publish", false, "publish replacement TX to "+
|
|
|
|
|
"the chain API instead of just printing the TX",
|
|
|
|
@ -230,9 +237,19 @@ func (c *doubleSpendInputs) Execute(_ *cobra.Command, _ []string) error {
|
|
|
|
|
// Create the transaction.
|
|
|
|
|
tx := wire.NewMsgTx(2)
|
|
|
|
|
|
|
|
|
|
// enable/disable RBF
|
|
|
|
|
var sequence uint32 = mempool.MaxRBFSequence
|
|
|
|
|
if !c.Rbf {
|
|
|
|
|
sequence = wire.MaxTxInSequenceNum
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add the inputs.
|
|
|
|
|
for _, outpoint := range outpoints {
|
|
|
|
|
tx.AddTxIn(wire.NewTxIn(outpoint, nil, nil))
|
|
|
|
|
|
|
|
|
|
tx.AddTxIn(&wire.TxIn{
|
|
|
|
|
PreviousOutPoint: *outpoint,
|
|
|
|
|
Sequence: sequence,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tx.AddTxOut(wire.NewTxOut(int64(totalInput-totalFee), sweepScript))
|
|
|
|
|