From 4f5e3f363a83bbb2ca43471097cc1ff90deebbb2 Mon Sep 17 00:00:00 2001 From: Ekaterina Pavlova Date: Wed, 27 Dec 2023 12:26:02 +0300 Subject: [PATCH] cli: fix canceltx ValidUntilBlock parameter of conflicting transaction If main transaction is known, then conflicting transaction shouldn't be valid longer than the main one. Signed-off-by: Ekaterina Pavlova --- cli/util/cancel.go | 3 +++ cli/util/convert.go | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cli/util/cancel.go b/cli/util/cancel.go index 495704e3e..19376217d 100644 --- a/cli/util/cancel.go +++ b/cli/util/cancel.go @@ -64,6 +64,9 @@ func cancelTx(ctx *cli.Context) error { t.NetworkFee = mainTx.NetworkFee + 1 } t.NetworkFee += int64(flags.Fixed8FromContext(ctx, "gas")) + if mainTx != nil { + t.ValidUntilBlock = mainTx.ValidUntilBlock + } return nil }) if err != nil { diff --git a/cli/util/convert.go b/cli/util/convert.go index 002711b52..98ea3ac22 100644 --- a/cli/util/convert.go +++ b/cli/util/convert.go @@ -56,16 +56,16 @@ func NewCommands() []cli.Command { Usage: "Cancel transaction by sending conflicting transaction", UsageText: "canceltx -r --wallet [--account ] [--wallet-config ] [--gas ]", Description: `Aims to prevent a transaction from being added to the blockchain by dispatching a more -prioritized conflicting transaction to the specified RPC node. The input for this command should -be the transaction hash. If another account is not specified, the conflicting transaction is -automatically generated and signed by the default account in the wallet. If the target transaction -is in the memory pool of the provided RPC node, the NetworkFee value of the conflicting transaction -is set to the target transaction's NetworkFee value plus one (if it's sufficient for the -conflicting transaction itself). If the target transaction is not in the memory pool, standard -NetworkFee calculations are performed based on the calculatenetworkfee RPC request. If the --gas -flag is included, the specified value is added to the resulting conflicting transaction network fee -in both scenarios. -`, + prioritized conflicting transaction to the specified RPC node. The input for this command should + be the transaction hash. If another account is not specified, the conflicting transaction is + automatically generated and signed by the default account in the wallet. If the target transaction + is in the memory pool of the provided RPC node, the NetworkFee value of the conflicting transaction + is set to the target transaction's NetworkFee value plus one (if it's sufficient for the + conflicting transaction itself), the ValidUntilBlock value of the conflicting transaction is set to the + target transaction's ValidUntilBlock value. If the target transaction is not in the memory pool, standard + NetworkFee calculations are performed based on the calculatenetworkfee RPC request. If the --gas + flag is included, the specified value is added to the resulting conflicting transaction network fee + in both scenarios.`, Action: cancelTx, Flags: txCancelFlags, },