cli: use MVUBI for saved transactions

And DO NOT CHANGE TX in paramcontext InitAndSave, because it's really
unobvious and must not be done this way.
This commit is contained in:
Roman Khimov 2022-08-07 22:08:13 +03:00
parent ba2e7063dd
commit d9feec2be5
4 changed files with 14 additions and 5 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)