From ba2e7063dd6f95d97ccb666849077c590c686919 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Sun, 7 Aug 2022 21:59:25 +0300 Subject: [PATCH] cli: compensate VUB for prompt waiting time We also have now ways to change it with actor package, so technically this fixes #2618. --- cli/smartcontract/smart_contract.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cli/smartcontract/smart_contract.go b/cli/smartcontract/smart_contract.go index d127cf82a..f6f038418 100644 --- a/cli/smartcontract/smart_contract.go +++ b/cli/smartcontract/smart_contract.go @@ -8,6 +8,7 @@ import ( "os" "path/filepath" "strings" + "time" "github.com/nspcc-dev/neo-go/cli/cmdargs" "github.com/nspcc-dev/neo-go/cli/flags" @@ -735,6 +736,7 @@ func invokeWithArgs(ctx *cli.Context, acc *wallet.Account, wall *wallet.Wallet, if len(resp.Script) == 0 { return sender, cli.NewExitError(errors.New("no script returned from the RPC node"), 1) } + ver := act.GetVersion() tx, err := act.MakeUnsignedUncheckedRun(resp.Script, resp.GasConsumed+int64(sysgas), nil) if err != nil { return sender, cli.NewExitError(fmt.Errorf("failed to create tx: %w", err), 1) @@ -748,10 +750,14 @@ func invokeWithArgs(ctx *cli.Context, acc *wallet.Account, wall *wallet.Wallet, fmt.Fprintln(ctx.App.Writer, tx.Hash().StringLE()) } else { if !ctx.Bool("force") { + promptTime := time.Now() err := input.ConfirmTx(ctx.App.Writer, tx) if err != nil { return sender, cli.NewExitError(err, 1) } + waitTime := time.Since(promptTime) + // Compensate for confirmation waiting. + tx.ValidUntilBlock += uint32((waitTime.Milliseconds() / int64(ver.Protocol.MillisecondsPerBlock))) + 1 } txHash, _, err := act.SignAndSend(tx) if err != nil {