Commit graph

121 commits

Author SHA1 Message Date
Anna Shaleva
9525bc7785 wallet: fix scrypt parameters in wallet regeneration tests
Default NEP2 scrypt parameters should be overriden where needed,
otherwise our regeneration tests won't generate proper wallets.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-03-01 19:19:03 +03:00
Anna Shaleva
1f4e1922ee cli: add new testing wallet
It contains several simple signature accounts that are not related to
network committee or validators. Needed for tests, existing
`testwallet.json` can't de reused since some tests need testing wallet
with a single account.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-02-29 23:48:10 +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
Evgenii Stratonikov
962b161652 wallet: allow complex contract verification schemes, close #3015
This was recently added in neotest, but working with the real RPC is
still not enjoyable. This commit extends `wallet.Account` with
invocation script builder to aid network fee calculations and signing.

Signed-off-by: Evgenii Stratonikov <fyfyrchik@runbox.com>
2023-12-21 11:26:55 +03:00
Evgeny Baydakov
2012c56031
wallet: Add new wallet constructors
Closes #3177

Signed-off-by: Evgeny Baydakov <e.bajdakov@gmail.com>
2023-12-12 08:33:30 +04:00
Anna Shaleva
59baecd39b wallet: provide more detailed errors on failed NewWalletFromFile
Close #3180.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-21 13:07:11 +03:00
Roman Khimov
1c99c21d9a
Merge pull request #2725 from nspcc-dev/move-cli-tests
Move CLI tests
2022-10-06 13:43:39 +07: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
317dd42513 *: use uint*Size and SignatureLen constants where appropriate 2022-10-05 10:45:52 +03:00
Roman Khimov
cad0d7f00d wallet: add some warnings to Decrypt and PrivateKey docs 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
62be6f959c keys/wallet: add Destroy/Close/Close
PrivateKey can be destroyed and Account/Wallet can be closed (destroying keys
in the process).
2022-09-01 17:07:00 +03:00
Roman Khimov
a30e73a0d7 wallet: drop publicKey from Account
It's not very useful and it's only available when we have a private key
anyway.
2022-09-01 17:07:00 +03:00
Roman Khimov
53edbd569f wallet: don't allow to ConvertMultisig a locked account
This stretched the definition of Locked somewhat, but still makes sense to
me, locked accounts better not be touched.
2022-09-01 17:07:00 +03:00
Roman Khimov
0090577446 wallet: don't permanently store wif in the Account
It's useless and it's just another copy of the key. If really needed, it can
be derived from the key.
2022-09-01 17:07:00 +03:00
Roman Khimov
fe50879bb7 wallet: add (*Account).CanSign API 2022-08-26 18:21:58 +03:00
Roman Khimov
8b132cba0c wallet: respect user-locked accounts, don't sign with them
NEP-6 has a notion of locked acccounts and SignTx must respect this user's
choice. For some reason this setting was inappropriately used by our RPC
client tests (probably a different kind of lock was meant).
2022-08-26 18:21:58 +03:00
Roman Khimov
54c5fd61df wallet: make SignTx more precise and accurate
* each account must have an appropriate signer, if there is no signer for
   this account in the tx it's an error
 * we can only safely append to Scripts when account belongs to the next
   signer (we don't have appropriate verification scripts for other signers)
 * when contract has one parameter, the signature shouldn't be appended to
   other data

I think these rules allow to handle more cases and do that safer. We have more
complex scenarios though, like non-signature parameters or mixed-parameter
invocation scripts, but that's out of scope for now.
2022-08-26 18:21:58 +03:00
Roman Khimov
7a930a8e11 wallet: don't fail in SignTx when no contract provided
Unfortunately valid NEP-6 can have no contract inside of account, so this
should be accounted for.
2022-08-26 18:21:58 +03:00
Roman Khimov
593fa4cac8
Merge pull request #2632 from nspcc-dev/rpcclient-actor
RPC client Actor interface
2022-08-09 17:21:24 +03:00
Roman Khimov
260bcc0f49 wallet: fix wallet version to conform to NEP-6
See neo-project/neo#2390. Can't see it there? No wonder, that's why we have
this bug for a year and a half. Not critical, we don't care about versions,
but _very_ annoying.
2022-08-07 22:41:40 +03:00
Roman Khimov
f369c2a359 wallet: allow pre-filled contract-based scripts in SignTx
They're allowed already for regular accounts (see below), but parameterless
accounts always add a script which is wrong.
2022-08-07 22:33:56 +03:00
Anna Shaleva
5f36a7ca0f *: do not call wallet.Close() explicitly
NewWallet and NewWalletFromFile close underlying io.Closer by itself,
no need to close it manually. Introduced in #2184.
2022-07-04 19:09:48 +03:00
Evgeniy Stratonikov
0431e26659 wallet: export SavePretty method
Client code can make use of it, see nspcc-dev/neofs-node#1498.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-06-09 09:47:18 +03:00
Elizaveta Chichindaeva
28908aa3cf [#2442] English Check
Signed-off-by: Elizaveta Chichindaeva <elizaveta@nspcc.ru>
2022-05-04 19:48:27 +03:00
Anna Shaleva
2096ad6e81 *: remove io/ioutil uses
Close #1764.
2022-03-17 19:39:18 +03:00
Roman Khimov
33e37e60e5
Merge pull request #2264 from nspcc-dev/fix-win-tests
*: Windows compatibility fixes
2021-11-29 11:25:35 +03:00
AnnaShaleva
aefb6f9fee *: fix tests failing due to path.Join usage
Solution:
Use `file/filepath` package to construct expected path. This package is OS-aware, see https://github.com/golang/go/issues/30616.
2021-11-29 11:11:09 +03:00
Roman Khimov
ce9d0b22cf *: use NEP-XX naming consistently in docs/comments
Standards are NEP-11 and NEP-17, not NEP11, not NEP17, not anything
else. Variable/function names of course can use whatever fits, but documents
and comments should be consistent wrt this.
2021-11-19 12:58:46 +03:00
Evgeniy Stratonikov
cb5b075e7d wallet: do not store file handle
Close immediately after read/write. This can be a bit slower but
we store everything in memory anyway and code size is smaller.
`wallet.Close()` method is now a no-op.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-06 15:29:52 +03:00
Evgeniy Stratonikov
7b6203d0d4 wallet: allow to open in read-only mode, fix #2182
If wallet was opened via `NewWalletFromFile`, open it as read-only first
and re-open for write if needed.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-10-05 16:25:50 +03:00
Roman Khimov
6d074a96e9 *: make tests use TempDir(), fix #1319
Simplify things, drop TempFile at the same time (refs. #1764)
2021-08-26 17:29:40 +03:00
Evgeniy Stratonikov
283173bb9d wallet: use named constants in Seek
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-07-29 17:11:50 +03:00
Evgeniy Stratonikov
a429aa3e68 wallet: truncate file when writing
If wallet size decreases, we need to remove trailing garbage if it
exists. This can happen when removing account or reading pretty-printed
wallet. It doesn't affect our CLI (we decode only file prefix), but
it is nice to always have a valid JSON file.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-07-29 17:11:49 +03:00
Evgeniy Stratonikov
8f196c8222 wallet: marshal before writing to file
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-07-29 16:07:36 +03:00
Anna Shaleva
472a44a464 *: regenerate test wallets with resources-friendly scrypt parameters 2021-06-11 15:22:32 +03:00
Anna Shaleva
50296975e2 crypto: allow to provide non-default scrypt parameters 2021-06-11 15:22:28 +03:00
Evgeniy Stratonikov
ea49c6b637 wallet: rename isdefault to isDefault
Follow neo-project/neo#2451 .
2021-05-14 10:31:31 +03:00
Roman Khimov
9d2712573f *: enable godot linter and fix all its warnings
It's important for NeoGo to have clean documentation. No functional changes.
2021-05-12 23:17:03 +03:00
Roman Khimov
cfc067dd24 *: remove dead code
Found by deadcode via golangci-lint.
2021-05-12 18:13:14 +03:00
Anna Shaleva
6d59689d9c core: rename Neo.Crypto.CheckMultisig interop 2021-05-11 18:38:14 +03:00
Anna Shaleva
366e79b9b8 core: rename Neo.Crypto.CheckSig interop 2021-05-11 18:37:55 +03:00
Anna Shaleva
af16c3e009 wallet: add test to regenerate testwallet_NEO3.json 2021-05-11 18:36:30 +03:00
Anna Shaleva
5071173dfd wallet: add test to regenerate CLI testwallet 2021-05-11 18:36:30 +03:00
Anna Shaleva
5017f2d2e6 wallet: add test to regenerate examples wallet 2021-05-11 18:36:30 +03:00
Anna Shaleva
68d0249c50 wallet: refactor regenerate test
Move common code to a separate function.
2021-05-11 18:36:30 +03:00
Anna Shaleva
14189c50aa wallet: add test to regenerate Oracle testwallets 2021-05-11 18:36:30 +03:00
Anna Shaleva
56a616f21c wallet: add test to regenerate Notary testwallets 2021-05-11 18:36:30 +03:00