mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-10 19:03:16 +02:00
lncli: add new removetx cmd.
This new command calls the new rpc endpoint RemoveTransaction.
This commit is contained in:
@@ -75,6 +75,7 @@ func walletCommands() []cli.Command {
|
|||||||
labelTxCommand,
|
labelTxCommand,
|
||||||
publishTxCommand,
|
publishTxCommand,
|
||||||
getTxCommand,
|
getTxCommand,
|
||||||
|
removeTxCommand,
|
||||||
releaseOutputCommand,
|
releaseOutputCommand,
|
||||||
leaseOutputCommand,
|
leaseOutputCommand,
|
||||||
listLeasesCommand,
|
listLeasesCommand,
|
||||||
@@ -545,7 +546,6 @@ func publishTransaction(ctx *cli.Context) error {
|
|||||||
|
|
||||||
req := &walletrpc.Transaction{
|
req := &walletrpc.Transaction{
|
||||||
TxHex: tx,
|
TxHex: tx,
|
||||||
Label: ctx.String("label"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = walletClient.PublishTransaction(ctxc, req)
|
_, err = walletClient.PublishTransaction(ctxc, req)
|
||||||
@@ -599,6 +599,66 @@ func getTransaction(ctx *cli.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var removeTxCommand = cli.Command{
|
||||||
|
Name: "removetx",
|
||||||
|
Usage: "Attempts to remove the unconfirmed transaction with the " +
|
||||||
|
"specified txid and all its children from the underlying " +
|
||||||
|
"internal wallet.",
|
||||||
|
ArgsUsage: "txid",
|
||||||
|
Description: `
|
||||||
|
Removes the transaction with the specified txid from the underlying
|
||||||
|
wallet which must still be unconfirmmed (in mempool). This command is
|
||||||
|
useful when a transaction is RBFed by another transaction. The wallet
|
||||||
|
will only resolve this conflict when the other transaction is mined
|
||||||
|
(which can take time). If a transaction was removed erronously a simple
|
||||||
|
rebroadcast of the former transaction with the "publishtx" cmd will
|
||||||
|
register the relevant outputs of the raw tx again with the wallet
|
||||||
|
(if there are no errors broadcasting this transaction due to an RBF
|
||||||
|
replacement sitting in the mempool). As soon as a removed transaction
|
||||||
|
is confirmed funds will be registered with the wallet again.`,
|
||||||
|
Flags: []cli.Flag{},
|
||||||
|
Action: actionDecorator(removeTransaction),
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeTransaction(ctx *cli.Context) error {
|
||||||
|
ctxc := getContext()
|
||||||
|
|
||||||
|
// Display the command's help message if we do not have the expected
|
||||||
|
// number of arguments/flags.
|
||||||
|
if ctx.NArg() != 1 {
|
||||||
|
return cli.ShowCommandHelp(ctx, "removetx")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch the only cmd argument which must be a valid txid.
|
||||||
|
txid := ctx.Args().First()
|
||||||
|
txHash, err := chainhash.NewHashFromStr(txid)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
walletClient, cleanUp := getWalletClient(ctx)
|
||||||
|
defer cleanUp()
|
||||||
|
|
||||||
|
req := &walletrpc.GetTransactionRequest{
|
||||||
|
Txid: txHash.String(),
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := walletClient.RemoveTransaction(ctxc, req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
printJSON(&struct {
|
||||||
|
Status string `json:"status"`
|
||||||
|
TxID string `json:"txid"`
|
||||||
|
}{
|
||||||
|
Status: resp.GetStatus(),
|
||||||
|
TxID: txHash.String(),
|
||||||
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// utxoLease contains JSON annotations for a lease on an unspent output.
|
// utxoLease contains JSON annotations for a lease on an unspent output.
|
||||||
type utxoLease struct {
|
type utxoLease struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
|
Reference in New Issue
Block a user