rooch-network / rooch

VApp Container with Move Language
https://rooch.network
Apache License 2.0
144 stars 66 forks source link

[cli] `rooch account create` can not create more account #2022

Open jolestar opened 1 week ago

jolestar commented 1 week ago

The rooch account create command can not create more accounts.

Execute the rooch account create twice. It outputs the same account address.

feliciss commented 1 week ago

🙋‍♀️

feliciss commented 5 days ago

@jolestar I printed the command line output using rooch account create but they're the different addresses:

rooch init  --config-dir ./test                                   
Rooch server config file generated at ./test/server.yaml
Creating client config file ["./test/rooch.yaml"] with rooch native validator.
Enter a password to encrypt the keys. Press enter to leave it an empty password: 
Generated new keypair for address [0x94b1f7f69fa9bbe4d4c65c561bac462fd1de085ab0e3b9ea2d237d3f111db56c]
Secret Recovery Phrase : [review push decide quit amused barrel diagram uncle scorpion firm accuse transfer]
Rooch client config file generated at ./test/rooch.yaml
null

rooch account list --config-dir ./test
                     Rooch Address (Ed25519)                       |                         Multichain Address                         |               Public Key (Base64)                | Has session key  | Active Address
---------------------------------------------------------------------------------------------------------------------------------------------------------
0x94b1f7f69fa9bbe4d4c65c561bac462fd1de085ab0e3b9ea2d237d3f111db56c |                                                                    |   AIgNoJ4mjVDaJ1RzVtbteSdFkXYb6HZjlmCgF1+ejkdj   |      false       |     True    

rooch account create --config-dir ./test                                            
Generated new keypair for address with key pair type [0x87e67fc771fe08dd6fa6c4220e184ff58a209be5cc6cee36ecdfece9207dd05f]
Secret Recovery Phrase : [review push decide quit amused barrel diagram uncle scorpion firm accuse transfer]
"0x87e67fc771fe08dd6fa6c4220e184ff58a209be5cc6cee36ecdfece9207dd05f"

rooch account list --config-dir ./test
                     Rooch Address (Ed25519)                       |                         Multichain Address                         |               Public Key (Base64)                | Has session key  | Active Address
---------------------------------------------------------------------------------------------------------------------------------------------------------
0x87e67fc771fe08dd6fa6c4220e184ff58a209be5cc6cee36ecdfece9207dd05f |                                                                    |   AG6+zNp8Q74D6vPq+gVYZ+a6pvY/MzAMk4I2WnkCdzJg   |      false       |             
0x94b1f7f69fa9bbe4d4c65c561bac462fd1de085ab0e3b9ea2d237d3f111db56c |                                                                    |   AIgNoJ4mjVDaJ1RzVtbteSdFkXYb6HZjlmCgF1+ejkdj   |      false       |     True    

rooch account create --config-dir ./test
Generated new keypair for address with key pair type [0xfd518e245ab24f9426055eedbdc30199fd7d13fc94a6c7a1e596b87e9f4ff2d3]
Secret Recovery Phrase : [review push decide quit amused barrel diagram uncle scorpion firm accuse transfer]
"0xfd518e245ab24f9426055eedbdc30199fd7d13fc94a6c7a1e596b87e9f4ff2d3"

rooch account list --config-dir ./test  
                     Rooch Address (Ed25519)                       |                         Multichain Address                         |               Public Key (Base64)                | Has session key  | Active Address
---------------------------------------------------------------------------------------------------------------------------------------------------------
0x87e67fc771fe08dd6fa6c4220e184ff58a209be5cc6cee36ecdfece9207dd05f |                                                                    |   AG6+zNp8Q74D6vPq+gVYZ+a6pvY/MzAMk4I2WnkCdzJg   |      false       |             
0x94b1f7f69fa9bbe4d4c65c561bac462fd1de085ab0e3b9ea2d237d3f111db56c |                                                                    |   AIgNoJ4mjVDaJ1RzVtbteSdFkXYb6HZjlmCgF1+ejkdj   |      false       |     True    
0xfd518e245ab24f9426055eedbdc30199fd7d13fc94a6c7a1e596b87e9f4ff2d3 |                                                                    |   AH3A0hIueJbqXnJm2wYSgpvK/Fpr7oHbio4Q6sFMRfVn   |      false       |             

However, there's an order issue with the rooch account list command.

jolestar commented 4 days ago

@feliciss use the latest version.

feliciss commented 4 days ago

@feliciss use the latest version.

I see there are differences:

{
  "keys": {
    "rooch1y9kygtg2epl2c9pm9ak3zvk6n0ekwu2y3jr3p5xdaascj88jy7zqccejv0": {
      "nonce": "2h/qt97R8Rl151Zn",
      "ciphertext": "042RGxSSAz4PRyQhXQH+U6u7512cgrnQytHUmt/1tAm8HUIOHEw8lX697cY2",
      "tag": "XqCVndUxnWl/7BHlaxnFEw=="
    },
    "rooch1klfvadnu9upzt56k8aa5gs08puptkkfey3pyltq29uqljwmc4alq7yy4hx": {
      "nonce": "9FzQmt4QwGC5vayO",
      "ciphertext": "7DfT8c7TPBo6ZSEXRG+QcaUf8lV5ty7zCHN2DFuppqf2CnasBMzzwwBLDnes",
      "tag": "FduidMWkBs0k9KFRyGcx5w=="
    }
  },
  "mnemonic": {
    "addresses": [
      "rooch1y9kygtg2epl2c9pm9ak3zvk6n0ekwu2y3jr3p5xdaascj88jy7zqccejv0"
    ],
    "mnemonic_phrase_encryption": {
      "nonce": "VK2oWIHOFvAhOkzA",
      "ciphertext": "ObsLv1YoTHBIdgefRyaqxnLOaV3zHziYkIyUCPKJUUp/ERpY5k2BCfj+yHgQfY1/lW6Y7eFzZ5wViR2Pp+yNC7nakmETaa96oX9V6eHr",
      "tag": "P2ID3wd1RErD1VwkX/UX2w=="
    }
  },
  "session_keys": {},
  "password_hash": "$argon2id$v=19$m=19456,t=2,p=1$2h/qt97R8Rl151Zn$5O0xCnk6cK6JwWYyC+3fdJ2Q/7QZ7VpkUl2F2aYzGjo",
  "is_password_empty": true
}

I'm trying to resolve this issue.

feliciss commented 1 day ago

The issue is found by getting the mnemonic. addresses as the account index rather than the total of keys as index.

I'm submitting a PR to resolve this issue.

feliciss commented 1 day ago

There's only one addresses in the mnemonic field and getting the addresses will always result in one account_index.

feliciss commented 1 day ago

The rooch account create command can not create more accounts.

Execute the rooch account create twice. It outputs the same account address.

When the account index equals to 1 and always should there be 1, the account encryption data will be generated and leave the account_index and derivation_path to be the only two the same as the first-time account create command's result.