cli: allow to specify cosigners with Neo addresses

Make it a bit more usable.
This commit is contained in:
Roman Khimov 2021-01-27 22:32:29 +03:00
parent 48e3a41133
commit 79e11c93a1
2 changed files with 12 additions and 5 deletions

View file

@ -187,6 +187,9 @@ func TestComlileAndInvokeFunction(t *testing.T) {
e.Run(t, "neo-go", "contract", "testinvokescript", e.Run(t, "neo-go", "contract", "testinvokescript",
"--rpc-endpoint", "http://"+e.RPC.Addr, "--rpc-endpoint", "http://"+e.RPC.Addr,
"--in", nefName, "--", util.Uint160{1, 2, 3}.StringLE()) "--in", nefName, "--", util.Uint160{1, 2, 3}.StringLE())
e.Run(t, "neo-go", "contract", "testinvokescript",
"--rpc-endpoint", "http://"+e.RPC.Addr,
"--in", nefName, "--", address.Uint160ToString(util.Uint160{1, 2, 3}))
e.In.WriteString("one\r") e.In.WriteString("one\r")
e.Run(t, "neo-go", "contract", "deploy", e.Run(t, "neo-go", "contract", "deploy",

View file

@ -266,8 +266,8 @@ func NewCommands() []cli.Command {
Signers represent a set of Uint160 hashes with witness scopes and are used Signers represent a set of Uint160 hashes with witness scopes and are used
to verify hashes in System.Runtime.CheckWitness syscall. First signer is treated to verify hashes in System.Runtime.CheckWitness syscall. First signer is treated
as a sender. To specify signers use signer[:scope] syntax where as a sender. To specify signers use signer[:scope] syntax where
* 'signer' is hex-encoded 160 bit (20 byte) LE value of signer's address, * 'signer' is a signer's address (as Neo address or hex-encoded 160 bit (20 byte)
which could have '0x' prefix. LE value with or without '0x' prefix).
* 'scope' is a comma-separated set of cosigner's scopes, which could be: * 'scope' is a comma-separated set of cosigner's scopes, which could be:
- 'None' - default witness scope which may be used for the sender - 'None' - default witness scope which may be used for the sender
to only pay fee for the transaction. to only pay fee for the transaction.
@ -286,9 +286,9 @@ func NewCommands() []cli.Command {
neo-go RPC server only. C# implementation does not support scopes capability. neo-go RPC server only. C# implementation does not support scopes capability.
Examples: Examples:
* '0000000009070e030d0f0e020d0c06050e030c02' * 'NNQk4QXsxvsrr3GSozoWBUxEmfag7B6hz5'
* 'NVquyZHoPirw6zAEPvY1ZezxM493zMWQqs:Global'
* '0x0000000009070e030d0f0e020d0c06050e030c02' * '0x0000000009070e030d0f0e020d0c06050e030c02'
* '0x0000000009070e030d0f0e020d0c06050e030c02:Global'
* '0000000009070e030d0f0e020d0c06050e030c02:CalledByEntry,CustomGroups' * '0000000009070e030d0f0e020d0c06050e030c02:CalledByEntry,CustomGroups'
`, `,
Action: testInvokeFunction, Action: testInvokeFunction,
@ -888,7 +888,11 @@ func parseCosigner(c string) (transaction.Signer, error) {
if len(s) == 2*util.Uint160Size+2 && s[0:2] == "0x" { if len(s) == 2*util.Uint160Size+2 && s[0:2] == "0x" {
s = s[2:] s = s[2:]
} }
res.Account, err = util.Uint160DecodeStringLE(s) if len(s) == util.Uint160Size*2 {
res.Account, err = util.Uint160DecodeStringLE(s)
} else {
res.Account, err = address.StringToUint160(s)
}
if err != nil { if err != nil {
return res, err return res, err
} }