cli: compensate VUB for prompt waiting time

We also have now ways to change it with actor package, so technically this
fixes #2618.
This commit is contained in:
Roman Khimov 2022-08-07 21:59:25 +03:00
parent 7132b38425
commit ba2e7063dd

View file

@ -8,6 +8,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"time"
"github.com/nspcc-dev/neo-go/cli/cmdargs" "github.com/nspcc-dev/neo-go/cli/cmdargs"
"github.com/nspcc-dev/neo-go/cli/flags" "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 { if len(resp.Script) == 0 {
return sender, cli.NewExitError(errors.New("no script returned from the RPC node"), 1) 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) tx, err := act.MakeUnsignedUncheckedRun(resp.Script, resp.GasConsumed+int64(sysgas), nil)
if err != nil { if err != nil {
return sender, cli.NewExitError(fmt.Errorf("failed to create tx: %w", err), 1) 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()) fmt.Fprintln(ctx.App.Writer, tx.Hash().StringLE())
} else { } else {
if !ctx.Bool("force") { if !ctx.Bool("force") {
promptTime := time.Now()
err := input.ConfirmTx(ctx.App.Writer, tx) err := input.ConfirmTx(ctx.App.Writer, tx)
if err != nil { if err != nil {
return sender, cli.NewExitError(err, 1) 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) txHash, _, err := act.SignAndSend(tx)
if err != nil { if err != nil {