diff --git a/cli/paramcontext/context.go b/cli/paramcontext/context.go index 361af66fe..5ebfe9efc 100644 --- a/cli/paramcontext/context.go +++ b/cli/paramcontext/context.go @@ -12,14 +12,9 @@ import ( "github.com/nspcc-dev/neo-go/pkg/wallet" ) -// validUntilBlockIncrement is the number of extra blocks to add to an exported transaction. -const validUntilBlockIncrement = 50 - // InitAndSave creates an incompletely signed transaction which can be used // as an input to `multisig sign`. func InitAndSave(net netmode.Magic, tx *transaction.Transaction, acc *wallet.Account, filename string) error { - // avoid fast transaction expiration - tx.ValidUntilBlock += validUntilBlockIncrement priv := acc.PrivateKey() pub := priv.PublicKey() sign := priv.SignHashable(uint32(net), tx) diff --git a/cli/smartcontract/smart_contract.go b/cli/smartcontract/smart_contract.go index f6f038418..e571f6630 100644 --- a/cli/smartcontract/smart_contract.go +++ b/cli/smartcontract/smart_contract.go @@ -743,6 +743,8 @@ func invokeWithArgs(ctx *cli.Context, acc *wallet.Account, wall *wallet.Wallet, } tx.NetworkFee += int64(gas) if out != "" { + // Make a long-lived transaction, it's to be signed manually. + tx.ValidUntilBlock += (ver.Protocol.MaxValidUntilBlockIncrement - uint32(ver.Protocol.ValidatorsCount)) - 2 m := act.GetNetwork() if err := paramcontext.InitAndSave(m, tx, acc, out); err != nil { return sender, cli.NewExitError(err, 1) diff --git a/cli/wallet/nep11.go b/cli/wallet/nep11.go index 0631e8bc8..e910966b8 100644 --- a/cli/wallet/nep11.go +++ b/cli/wallet/nep11.go @@ -275,6 +275,12 @@ func signAndSendNEP11Transfer(ctx *cli.Context, c *rpcclient.Client, acc *wallet tx.SystemFee += int64(sysgas) if outFile := ctx.String("out"); outFile != "" { + ver, err := c.GetVersion() + if err != nil { + return cli.NewExitError(fmt.Errorf("RPC failure: %w", err), 1) + } + // Make a long-lived transaction, it's to be signed manually. + tx.ValidUntilBlock += (ver.Protocol.MaxValidUntilBlockIncrement - uint32(ver.Protocol.ValidatorsCount)) - 2 m, err := c.GetNetwork() if err != nil { return cli.NewExitError(fmt.Errorf("failed to save tx: %w", err), 1) diff --git a/cli/wallet/nep17.go b/cli/wallet/nep17.go index 0999df7e5..1591f980f 100644 --- a/cli/wallet/nep17.go +++ b/cli/wallet/nep17.go @@ -647,6 +647,12 @@ func signAndSendNEP17Transfer(ctx *cli.Context, c *rpcclient.Client, acc *wallet tx.SystemFee += int64(sysgas) if outFile := ctx.String("out"); outFile != "" { + ver, err := c.GetVersion() + if err != nil { + return cli.NewExitError(fmt.Errorf("RPC failure: %w", err), 1) + } + // Make a long-lived transaction, it's to be signed manually. + tx.ValidUntilBlock += (ver.Protocol.MaxValidUntilBlockIncrement - uint32(ver.Protocol.ValidatorsCount)) - 2 m, err := c.GetNetwork() if err != nil { return cli.NewExitError(fmt.Errorf("failed to save tx: %w", err), 1)