From 8005bfcd32c61c9f6618a3101a3b98e0dadfe415 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 19 Aug 2022 21:37:50 +0300 Subject: [PATCH] cli/wallet: compensate for CLI waiting time Similar to ba2e7063dd6f95d97ccb666849077c590c686919. --- cli/wallet/nep17.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cli/wallet/nep17.go b/cli/wallet/nep17.go index 97a99bddc..c31dc8c51 100644 --- a/cli/wallet/nep17.go +++ b/cli/wallet/nep17.go @@ -6,6 +6,7 @@ import ( "fmt" "math/big" "strings" + "time" "github.com/nspcc-dev/neo-go/cli/cmdargs" "github.com/nspcc-dev/neo-go/cli/flags" @@ -687,17 +688,21 @@ func signAndSendSomeTransaction(ctx *cli.Context, act *actor.Actor, acc *wallet. tx.SystemFee += int64(sysgas) tx.NetworkFee += int64(gas) + ver := act.GetVersion() if outFile := ctx.String("out"); outFile != "" { - ver := act.GetVersion() // Make a long-lived transaction, it's to be signed manually. tx.ValidUntilBlock += (ver.Protocol.MaxValidUntilBlockIncrement - uint32(ver.Protocol.ValidatorsCount)) - 2 err = paramcontext.InitAndSave(ver.Protocol.Network, tx, acc, outFile) } else { if !ctx.Bool("force") { + promptTime := time.Now() err := input.ConfirmTx(ctx.App.Writer, tx) if err != nil { return cli.NewExitError(err, 1) } + waitTime := time.Since(promptTime) + // Compensate for confirmation waiting. + tx.ValidUntilBlock += uint32((waitTime.Milliseconds() / int64(ver.Protocol.MillisecondsPerBlock))) + 1 } _, _, err = act.SignAndSend(tx) }