Grinnode-live / 2020-grin-bug-bash-challenge

Finding bugs in Grin-Wallet & Grin-nodes for a bounty prior to Grin fork v5.
3 stars 1 forks source link

[GRIN-Wallet][Owner API] testing the create wallet method #28

Closed marekyggdrasil closed 3 years ago

marekyggdrasil commented 3 years ago

Description Testing the create wallet method from the Owner API

Prerequisites

  1. GRIN-Node
  2. GRIN-Wallet

Test procedure

  1. Run GRIN-Wallet in Owner API listener mode
  2. Use node.js or python to run an encrypted request to create wallet method

Expected result: Creates a new wallet seed and empty wallet database in the wallet_data directory of the top level directory. Provide requests and response full payloads as well as wallet and node logs.

Include the output of command

grin-wallet -V

and your environment

uname -a
mojitoo commented 3 years ago

Prerequisites:

Step 1 (Runs the wallet's local web API)

grin-wallet owner_api
Password: 
20201220 07:55:46.473 WARN grin_wallet_controller::controller - Starting HTTP Foreign API on Owner server at 127.0.0.1:3420.
20201220 07:55:46.473 WARN grin_wallet_controller::controller - Starting HTTP Owner API server at 127.0.0.1:3420.
20201220 07:55:46.473 WARN grin_wallet_controller::controller - HTTP Owner listener started

HTTP Owner successfully started.

Create a new wallet "wallet2"

Before runnning the script, we need to make sure to edit the configuration.

change to your grin owner_api sercret file

api_sercet_file = '/Users/path/.grin/main/.owner_api_secret'

change to you wallet password

wallet_password = 'xxx'

call this following function at the end of wallet_v3.py

pp.pprint(wallet.create_wallet("password", "wallet2", None, mnemonic_length=32))
python3 /Users/workstation/Downloads/grin.py 
Traceback (most recent call last):
  File "/Users/workstation/Downloads/grin.py", line 471, in <module>
    pp.pprint(wallet.create_wallet("password", "wallet3", None, mnemonic_length=32))
  File "/Users/workstation/Downloads/grin.py", line 437, in create_wallet
    resp = self.post_encrypted('create_wallet', params)
  File "/Users/workstation/Downloads/grin.py", line 93, in post_encrypted
    raise WalletError(method, params, response_json["error"]["code"], response_json["error"]["message"])
__main__.WalletError: Callng create_wallet with params {'password': 'password', 'name': 'wallet3', 'mnemonic': None, 'mnemonic_length': 32} failed with error code -32099 because: WalletSeedExists: Wallet seed already exists at: /Users/workstation/.grin/main/wallet_data

the command seems to work fine, but i already have an existing wallet. we need to add another function maybe to have the option to choose another path


in the python file, please check line 435 and replace 'mnemonic_length=': by 'mnemonic_length':

marekyggdrasil commented 3 years ago

@bladedoyle , @mojitoo made some suggestions for the API wrapper, would you review and if you find them reasonable, make update?

https://github.com/grinfans/grin.py/blob/df41a7f51b44481eb8675433feaa67b5ce071f14/wallet_v3.py#L435

marekyggdrasil commented 3 years ago

Sorry, misunderstood initially @mojitoo. Closing. Thanks!