Commit graph

249 commits

Author SHA1 Message Date
Ekaterina Pavlova
d4a3c912fb cli: fix errors format
Error string should not be capitalized or end with punctuation mark.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-07-12 12:35:10 +03:00
Ekaterina Pavlova
39559b90e2 cli: add Required field for flags
Close #2861

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-07-12 11:58:12 +03:00
Ekaterina Pavlova
acde7bd0de cli: upgrade urfave lib to v2
Close #3097

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-07-12 11:58:12 +03:00
Ekaterina Pavlova
2f5c26f14b cli: use capital letter for Usage
To unified cli help only capital letter is used in Usage field.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-07-12 11:58:12 +03:00
Ekaterina Pavlova
b4fdf8c3c9 wallet: do not store deployed contract script inside Contract account
`Contract` account field should not contain deployed contract script.

Close #3348

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-06-05 15:27:20 +03:00
Ekaterina Pavlova
ae3515e819 crypto: add StringCompressed() for PublicKey
Add StringCompressed to get a string representation of the key in
compressed form.

Close #3263

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-04-11 15:24:46 +03:00
Ekaterina Pavlova
700a550973 cli: improve wallet unmarshalling error
Made errors more user-friendly.
```
./bin/neo-go wallet import --wif qweqweqweqwe -w wallet1.json
failed to read wallet: open wallet: open wallet.json: no such file or
directory

touch wallet.json

./bin/neo-go wallet import --wif qweqweqweqwe -w wallet.json
failed to read wallet: unmarshal wallet: EOF
```

Close #3134

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-04-04 13:46:54 +03:00
Anna Shaleva
8162e9033d *: replace slice.Copy with bytes.Clone
And refactor some code a bit, don't use bytes.Clone where type-specific
helpers may be used instead.

Close #2907.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-05 13:54:10 +03:00
Anna Shaleva
46a3ff3348 *: regenerate all wallets with adjusted parameters
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-01 19:19:03 +03:00
Ekaterina Pavlova
57aa05add3 wallet: make --wif optional in import-multisig command
We have a full list of public keys in the import-multisig command, so if
 we have a key in the wallet that corresponds to one of these keys
 (simple sig), just reuse it for the account automatically

Closes #3266

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-01-26 18:36:29 +03:00
Ekaterina Pavlova
0ffa24932b cli: add await flag for operations with transactions
New --await flag is an option to synchronize on transaction execution
for CLI commands.

Closes #3244

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2023-12-29 15:14:16 +03:00
Ekaterina Pavlova
44e21c9a8e cli: optimize CosignersSeparator check in loops
No functional changes.
We have 2 exactly the same cycles,and in the 1st cycle we set
cosignersOffset to the right value. So we don't need to check for arg ==
 cmdargs.CosignersSeparator one more time.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2023-12-07 10:37:01 +03:00
Ekaterina Pavlova
8bdbac3c5e cli: move actor-related functions handling to options package
Move actor handling into CLI package.
GetRPCWithActor returns RPC with actor instances.

Close #2682.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2023-12-07 10:35:37 +03:00
Ekaterina Pavlova
d7cab3b82c cli: move wallet-related flags handling to options package
Move GetAccFromContext, GetUnlockedAccount, ReadWalletConfig handling
into options package to reuse this code from all CLI handlers.
getDecryptedAccount is replaced by GetUnlockedAccount.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2023-12-06 10:49:50 +03:00
Ekaterina Pavlova
f93e2fbba4 cli: use (*transaction.Transaction).HasSigner where possible
No functional changes.
tx.HasSigner usage to avoid code duplication.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2023-12-06 10:49:50 +03:00
Roman Khimov
413caac941 rpcclient: drop deprecated Client APIs
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-10-10 13:26:07 +03:00
Anna Shaleva
7e709313d3 cli: ask for NEP2 account label if not provided
If NEP2 account label is not provided as a flag for import-related
CLI commands then ask it in the interactive mode.

This change breaks the compatibility with the old behaviour (add
the unnamed account if the name wasn't specified).
2023-01-26 08:50:06 +03:00
Anna Shaleva
b77c2846ee cli: allow to request NEP2 password from input
In case if wrong password was provided via config file we allow the
user to provide the password manually.
2023-01-25 14:20:59 +03:00
Anna Shaleva
1ef39a6e30 cli: properly handle --name and password-related wallet commands
Fetch account's name from the CLI argument and do not ask for the
user's input if provided, close #2882. Fetch password from config
if provided, close #2883.
2023-01-25 14:20:56 +03:00
Anna Shaleva
82221b0ca7 *: fix Neo and NeoGo misuses 2022-12-07 17:29:09 +03:00
Roman Khimov
573ed6c39e
Merge pull request #2834 from nspcc-dev/doc-updates
Minor documentation fixes
2022-12-07 20:16:59 +07:00
Anna Shaleva
9087854b1e services: allow multiple listen addresses for simple services
And deprecate the old way of Address/Port configuration for these services.
2022-12-07 11:23:01 +03:00
Roman Khimov
b1723f1a79 cli/wallet: improve wallet flag help text, fix #2820 2022-12-06 20:54:01 +03:00
Roman Khimov
0efe3dd42c cli: deduplicate smartcontract/wallet tx confirm/sign/save/send
It's the same code.
2022-10-06 23:03:32 +03:00
Roman Khimov
5200765dab cli/wallet: add out/force flags to claim/candidate cmds
Fixes #2669.
2022-10-06 22:19:40 +03:00
Roman Khimov
5bafa5f6b4 cli/wallet: add sysgas option to candidate and claim commands
It doesn't make a lot of sense, but hey, it's a transaction, it can have a bit
more GAS.
2022-10-06 22:09:32 +03:00
Roman Khimov
1ea06e9757 cli/wallet: unify claim and candidate code
Add -g option to claim which doesn't have a lot of sense, but can be used
anyway.
2022-10-06 21:52:40 +03:00
Roman Khimov
29e858df66 cli: move nep11/nep17 tests into a package of their own
The tests are still there, coverage should counted fine, but it improves things:

?       github.com/nspcc-dev/neo-go/cli [no test files]
ok      github.com/nspcc-dev/neo-go/cli/app     0.058s  coverage: 100.0% of statements
ok      github.com/nspcc-dev/neo-go/cli/cmdargs 0.005s  coverage: 60.8% of statements
ok      github.com/nspcc-dev/neo-go/cli/flags   0.027s  coverage: 97.7% of statements
?       github.com/nspcc-dev/neo-go/cli/input   [no test files]
ok      github.com/nspcc-dev/neo-go/cli/nep_test        30.443s coverage: [no statements]
ok      github.com/nspcc-dev/neo-go/cli/options 0.054s  coverage: 50.0% of statements
?       github.com/nspcc-dev/neo-go/cli/paramcontext    [no test files]
ok      github.com/nspcc-dev/neo-go/cli/query   2.089s  coverage: 45.3% of statements
ok      github.com/nspcc-dev/neo-go/cli/server  1.510s  coverage: 67.8% of statements
ok      github.com/nspcc-dev/neo-go/cli/smartcontract   8.433s  coverage: 94.3% of statements
ok      github.com/nspcc-dev/neo-go/cli/util    0.013s  coverage: 10.9% of statements
?       github.com/nspcc-dev/neo-go/cli/vm      [no test files]
ok      github.com/nspcc-dev/neo-go/cli/wallet  47.252s coverage: 63.0% of statements
2022-10-06 09:21:26 +03:00
Roman Khimov
1ac60ada19 cli: move tests to subpackages
Refs. #2379, but not completely solves it, one package seriously outweights
others:

?       github.com/nspcc-dev/neo-go/cli [no test files]
ok      github.com/nspcc-dev/neo-go/cli/app     0.036s  coverage: 100.0% of statements
ok      github.com/nspcc-dev/neo-go/cli/cmdargs 0.011s  coverage: 60.8% of statements
ok      github.com/nspcc-dev/neo-go/cli/flags   0.009s  coverage: 97.7% of statements
?       github.com/nspcc-dev/neo-go/cli/input   [no test files]
ok      github.com/nspcc-dev/neo-go/cli/options 0.033s  coverage: 50.0% of statements
?       github.com/nspcc-dev/neo-go/cli/paramcontext    [no test files]
ok      github.com/nspcc-dev/neo-go/cli/query   2.155s  coverage: 45.3% of statements
ok      github.com/nspcc-dev/neo-go/cli/server  1.373s  coverage: 67.8% of statements
ok      github.com/nspcc-dev/neo-go/cli/smartcontract   8.819s  coverage: 94.3% of statements
ok      github.com/nspcc-dev/neo-go/cli/util    0.006s  coverage: 10.9% of statements
?       github.com/nspcc-dev/neo-go/cli/vm      [no test files]
ok      github.com/nspcc-dev/neo-go/cli/wallet  72.103s coverage: 88.2% of statements

Still a nice thing to have.
2022-10-06 09:21:26 +03:00
Roman Khimov
d2d190913b cli: add historic abilities for all invoking commands
Notice that we can't do this for balance commands (unless we change the
interface in some manner) because they use getnepXXbalances.

Fixes #2620.
2022-09-08 19:20:18 +03:00
Roman Khimov
4f3ffe7290 golangci: enable errorlint and fix everything it found 2022-09-02 18:36:23 +03:00
Roman Khimov
58dc8d0c9b *: always close the wallet after use
Fix #2631.
2022-09-02 14:44:32 +03:00
Roman Khimov
cbc2299295 cli/wallet: add warning for dump and export commands 2022-09-02 14:44:18 +03:00
Roman Khimov
e164625a7f wallet: provide (*Account).SignHashable API
Make PrivateKey() less used and less useful.
2022-09-02 14:44:01 +03:00
Roman Khimov
e569edc841 wallet: add ScriptHash() to Account
It allows to simplify a lot of code and avoid getting a PrivateKey in some
cases.
2022-09-02 14:43:34 +03:00
Roman Khimov
8d33206bb8 *: don't get private key from account if just public one is needed
Add PublicKey() API to the Account and use it as appropriate, avoid creating
additional references to the private key.
2022-09-02 14:43:28 +03:00
Roman Khimov
411ebdf51e cli: add complete support for offline signing, fix #2662
See documentation update for an example. Some code is made generic as well,
GetCompleteTransaction can now be used directly on ParameterContext.
2022-09-01 15:30:34 +03:00
Roman Khimov
2e6bd51727 cli/wallet: add strip-keys command
To strip keys from wallets.
2022-09-01 15:30:34 +03:00
Roman Khimov
a9237659ff cli/wallet: correct error message
It can be both NEP-11 and NEP-17.
2022-09-01 15:30:33 +03:00
Roman Khimov
c2c10c111c cli/wallet: process non-out non-rpc calls to sign
And document the behavior better. Fixes #2664.
2022-09-01 15:30:33 +03:00
Roman Khimov
c316107c9f cli/wallet: avoid parsing address in signStoredTransaction
It's not needed, we already have the hash and getDecryptedAccount can't return
an account for a different one.
2022-09-01 15:30:33 +03:00
Roman Khimov
1da4b333f6 cli/wallet: modernize nep11 balances command, unify with nep17
Make NEP-11 code use getnep11balances the same way NEP-17 code uses
getnep17balances. This command was introduced well before getnep11balances
appeared, so it required always specifying contract explicitly. Now this
constraint can be relaxed somewhat in most cases.
2022-08-30 12:52:14 +03:00
Roman Khimov
7cfcf072b8 cli/wallet: make NEP-17 token selection logic a bit more robust
1. In the single token mode compare known hashes instead of names, names can
   be misleading.
2. Hardcode NEO/GAS, they are special (if not overrided by the wallet data).
2022-08-30 12:52:14 +03:00
Roman Khimov
5f1fe72504 cli/wallet: use token data from getnepXXbalances
We have this data available since 0.99.1 while all public networks require at
least 0.99.2 for compatibility and NeoFS setups use 0.99.2+ too. This data can
simplify account handling considerably making additional requests unneccessary
in many cases.
2022-08-29 22:52:27 +03:00
Roman Khimov
e28bf55ebb cli/wallet: search for NEP-11 token name in balances
In the same way we do for NEP-17 tokens. This code predates "getnep11balances"
call, so this wasn't possible back then, but now we can improve the situation
(allow specifying names/symbols instead of hashes only).
2022-08-29 22:52:27 +03:00
Roman Khimov
ed6ed61712 neptoken: add Info to replace old NEPXXTokenInfo methods
I'm still not sure it's good to have this exposed from neptoken at all, but
let's try it this way.
2022-08-29 22:52:27 +03:00
Roman Khimov
8005bfcd32 cli/wallet: compensate for CLI waiting time
Similar to ba2e7063dd.
2022-08-22 09:55:31 +03:00
Roman Khimov
f60fa02a96 cli/wallet: deduplicate some transfer code 2022-08-22 09:55:31 +03:00
Roman Khimov
7e212de41a cli: drop the use of deprecated APIs from sc/nep11/nep17 2022-08-19 21:52:43 +03:00
Roman Khimov
194933a5cc rpcclient: provide nep11 package for NEP-11 tokens
Unfortunately Go doesn't allow to easily reuse readers in full packages, still
we can have this wrapper with a little overhead (the alternative is to move
specific methods into types of their own, but I'm not sure how it's going to
be accepted user-side).
2022-08-19 10:37:22 +03:00