forked from TrueCloudLab/neoneo-go
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:
parent
ba2e7063dd
commit
d9feec2be5
4 changed files with 14 additions and 5 deletions
|
@ -12,14 +12,9 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
"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
|
// InitAndSave creates an incompletely signed transaction which can be used
|
||||||
// as an input to `multisig sign`.
|
// as an input to `multisig sign`.
|
||||||
func InitAndSave(net netmode.Magic, tx *transaction.Transaction, acc *wallet.Account, filename string) error {
|
func InitAndSave(net netmode.Magic, tx *transaction.Transaction, acc *wallet.Account, filename string) error {
|
||||||
// avoid fast transaction expiration
|
|
||||||
tx.ValidUntilBlock += validUntilBlockIncrement
|
|
||||||
priv := acc.PrivateKey()
|
priv := acc.PrivateKey()
|
||||||
pub := priv.PublicKey()
|
pub := priv.PublicKey()
|
||||||
sign := priv.SignHashable(uint32(net), tx)
|
sign := priv.SignHashable(uint32(net), tx)
|
||||||
|
|
|
@ -743,6 +743,8 @@ func invokeWithArgs(ctx *cli.Context, acc *wallet.Account, wall *wallet.Wallet,
|
||||||
}
|
}
|
||||||
tx.NetworkFee += int64(gas)
|
tx.NetworkFee += int64(gas)
|
||||||
if out != "" {
|
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()
|
m := act.GetNetwork()
|
||||||
if err := paramcontext.InitAndSave(m, tx, acc, out); err != nil {
|
if err := paramcontext.InitAndSave(m, tx, acc, out); err != nil {
|
||||||
return sender, cli.NewExitError(err, 1)
|
return sender, cli.NewExitError(err, 1)
|
||||||
|
|
|
@ -275,6 +275,12 @@ func signAndSendNEP11Transfer(ctx *cli.Context, c *rpcclient.Client, acc *wallet
|
||||||
tx.SystemFee += int64(sysgas)
|
tx.SystemFee += int64(sysgas)
|
||||||
|
|
||||||
if outFile := ctx.String("out"); outFile != "" {
|
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()
|
m, err := c.GetNetwork()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(fmt.Errorf("failed to save tx: %w", err), 1)
|
return cli.NewExitError(fmt.Errorf("failed to save tx: %w", err), 1)
|
||||||
|
|
|
@ -647,6 +647,12 @@ func signAndSendNEP17Transfer(ctx *cli.Context, c *rpcclient.Client, acc *wallet
|
||||||
tx.SystemFee += int64(sysgas)
|
tx.SystemFee += int64(sysgas)
|
||||||
|
|
||||||
if outFile := ctx.String("out"); outFile != "" {
|
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()
|
m, err := c.GetNetwork()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(fmt.Errorf("failed to save tx: %w", err), 1)
|
return cli.NewExitError(fmt.Errorf("failed to save tx: %w", err), 1)
|
||||||
|
|
Loading…
Reference in a new issue