forked from TrueCloudLab/neoneo-go
cli: support contract import in wallets
Sometimes we need to use custom verification script, e.g. for contracts where funds needs to become accessible only after a certain amount of time.
This commit is contained in:
parent
ffc0729adb
commit
cc5ec8e6d6
1 changed files with 13 additions and 0 deletions
|
@ -3,6 +3,7 @@ package wallet
|
|||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -143,6 +144,10 @@ func NewCommands() []cli.Command {
|
|||
Name: "name, n",
|
||||
Usage: "Optional account name",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "contract",
|
||||
Usage: "Verification script for custom contracts",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -403,6 +408,14 @@ func importWallet(ctx *cli.Context) error {
|
|||
return cli.NewExitError(err, 1)
|
||||
}
|
||||
|
||||
if ctrFlag := ctx.String("contract"); ctrFlag != "" {
|
||||
ctr, err := hex.DecodeString(ctrFlag)
|
||||
if err != nil {
|
||||
return cli.NewExitError("invalid contract", 1)
|
||||
}
|
||||
acc.Contract.Script = ctr
|
||||
}
|
||||
|
||||
acc.Label = ctx.String("name")
|
||||
if err := addAccountAndSave(wall, acc); err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
|
|
Loading…
Reference in a new issue