Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cardano-wallet: create/restore a new wallet error #2890

Closed
3 tasks done
tperrelli opened this issue Sep 11, 2021 · 11 comments
Closed
3 tasks done

cardano-wallet: create/restore a new wallet error #2890

tperrelli opened this issue Sep 11, 2021 · 11 comments
Labels

Comments

@tperrelli
Copy link

tperrelli commented Sep 11, 2021

Just checking...

  • This is a cardano-wallet bug.
  • I am using the latest cardano-wallet release.
  • I am using the correct cardano-node version for that release of cardano-wallet.

Version

2021-09-09

Platform

5.11.0-27-generic #29~20.04.1-Ubuntu SMP Wed Aug 11 15:58:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Installation method

cardano-wallet docker method exactly as described below.

wget https://raw.githubusercontent.com/input-output-hk/cardano-wallet/master/docker-compose.yml
NETWORK=testnet docker-compose up

Network configuration

testnet

Context

Hi all, i'm using a xubuntu but it's based on Ubuntu distro.

Description

Steps to Reproduce

  1. NETWORK=testnet docker-compose up -d
  2. Simple make a create wallet request using insomnia. The the example in the image below
  3. I've just followed the cardano api documentation as well (https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postWallet)
  4. I'm pretty sure that i'm using the right words as described here (https://github.com/input-output-hk/cardano-wallet/blob/master/specifications/mnemonic/english.txt)

image
...

Expected behavior

According to the documentation i was suppose to create a new wallet

Actual behavior

I'm getting this error message:

""Error in $['mnemonic_sentence']: Invalid entropy checksum: please double-check the last word of your mnemonic sentence."

@tperrelli tperrelli added the Bug label Sep 11, 2021
@waalge
Copy link

waalge commented Sep 11, 2021

I just had the same issue and couldn't find any (readable) docs on this.

Using this package and based on the snippet in the readme, I could generate a post.

import json
from mnemonic import Mnemonic

passphrase = "superSecurePassphrase"
mnemo = Mnemonic("english")
words = mnemo.generate(strength=256)
seed = mnemo.to_seed(words, passphrase=passphrase)
entropy = mnemo.to_entropy(words)

d = {
    "name": "waalges-wallet",
    "mnemonic_sentence": words.split(),
    "passphrase": passphrase,
    "address_pool_gap": 20,
}

print(json.dumps(d, indent=True))

@tperrelli
Copy link
Author

tperrelli commented Sep 12, 2021

@waalge interesting. And your payload is pretty much the same, there is no additional parameter on that. I'll try to do it without using insomnia or postman and see what happens.

I've just tried using curl directly but in this case it gets frozen and nothing happens.

curl -d 
'{
  "name": "Tiago's Wallet", 
  "mnemonic_sentence":    [
    "squirrel",
    "aerobic",
    "baby",
    "twice",
    "direct",
    "slush",
    "pistol",
    "razor",
    "acid",
    "junk",
    "kingdom",
    "flee",
    "squirrel",
    "dizzy",
    "cram"
], 
"passphrase": "Secure Passphrase hashed password", 
 "address_pool_gap": 20
}' 
-H 'Content-type: application/json' -H 'Accept: application/json' -X POST 'http://localhost:8090/v2/wallets'

@waalge
Copy link

waalge commented Sep 12, 2021

Hanging? Not sure about that. Maybe the address is not localhost?

Regarding the original error: there's some magic in BIP39 that means that not all sequences of words are valid. They must satisfy some criteria which this python lib is written to do.

Why this isn't in the API, or more verbosely and explicitly stated, I'm not sure.
Maybe i'm just looking in the wrong places.

@tperrelli
Copy link
Author

Yeah, i don't know why. And the payload is the same. When i try using isonmnia i get the error saying that there is something about the last word used. I've changed it a lot and nothing happens differently. Oh, and i always use some of these words

https://github.com/input-output-hk/cardano-wallet/blob/master/specifications/mnemonic/english.txt

@waalge
Copy link

waalge commented Sep 12, 2021

The last word has to solve some very specific condition - I'm not sure if there is a unique or very few options based on the first 23 (or n - 1) words.

@piotr-iohk
Copy link
Contributor

piotr-iohk commented Sep 12, 2021

HI, I believe the recovery phrase you are trying to use is invalid (perhaps it is incomplete?), you can verify it for instance here -> https://iancoleman.io/bip39/.

As far as I see from your code snippet:

from mnemonic import Mnemonic
...
mnemo = Mnemonic("english")
words = mnemo.generate(strength=256)

and your generated mnemonic sentence has 15 words (squirrel aerobic baby twice direct slush pistol razor acid junk kingdom flee squirrel dizzy cram). However when I try the same code it generates 24 words for me:

>>> len(mnemo.generate(strength=256).split())
24

Note that I'm able to create wallet with mnemonic sentence generated by https://github.com/trezor/python-mnemonic.

>>> mnemo.generate(strength=256)
'broken funny possible solar field travel sweet flee step mammal music winner crater fresh system hollow diet cloth rain wheel balcony monkey match sense'

...

$ curl -X POST http://localhost:8090/v2/wallets \
-d '{"mnemonic_sentence":["broken","funny","possible","solar","field","travel","sweet","flee","step","mammal","music","winner","crater","fresh","system","hollow","diet","cloth","rain","wheel","balcony","monkey","match","sense"],
"passphrase":"Secure Passphrase",
"name":"My Test Wallet",
"address_pool_gap":20}' \
-H "Content-Type: application/json"

{
  "passphrase": {
    "last_updated_at": "2021-09-12T18:12:02.714264435Z"
  },
  "address_pool_gap": 20,
  "state": {
    "status": "syncing",
    "progress": {
      "quantity": 0,
      "unit": "percent"
    }
  },
  "balance": {
    "reward": {
      "quantity": 0,
      "unit": "lovelace"
    },
    "total": {
      "quantity": 0,
      "unit": "lovelace"
    },
    "available": {
      "quantity": 0,
      "unit": "lovelace"
    }
  },
  "name": "My Test Wallet",
  "delegation": {
    "next": [],
    "active": {
      "status": "not_delegating"
    }
  },
  "id": "e02b2daa27c8ff206b0914027a21a27504103ccf",
  "tip": {
    "height": {
      "quantity": 0,
      "unit": "block"
    },
    "time": "2019-07-24T20:20:16Z",
    "epoch_number": 0,
    "absolute_slot_number": 0,
    "slot_number": 0
  },
  "assets": {
    "total": [],
    "available": []
  }
}

Note that you can also generate mnemonic sentence using cardano-wallet CLI:

$ cardano-wallet recovery-phrase generate
melt hard cushion buffalo deer ladder nurse cereal width atom pen burst okay range short poet tag forum present metal banner join arrow shuffle

@waalge
Copy link

waalge commented Sep 12, 2021

@piotr-iohk : The script is from me, and yeah it works. Thanks for poiinting out this is part of the wallet cli. i was only looking at the api.

@tperrelli After reading This and bagging my head against the keyboard it looks like you can substitute the invalid word cram for actor

@piotr-iohk
Copy link
Contributor

Ok, closing. As stated before the recovery phrase mentioned here is invalid, so wallet returning error (Error in $['mnemonic_sentence']: Invalid entropy checksum: please double-check the last word of your mnemonic sentence.) is expected.

@tperrelli
Copy link
Author

@piotr-iohk, regarding of recovery phrase i'm not sure about that, cuz the error i get is related to the mnemonic words. On the other hand this site (https://iancoleman.io/bip39/) really tells me that the mnemonic words that i'm passing are invalid. Once i had this in mind, i've generated some mnemonic words from this website and they worked for me!

So can we assume that the words provided from the docs are wrong? I mean,
https://github.com/input-output-hk/cardano-wallet/blob/master/specifications/mnemonic/english.txt

@waalge
according to the api documentation we were suppose to be able to choose between 15 and 24 words.

@waalge
Copy link

waalge commented Sep 13, 2021

But not all choices of 15 words are valid.
You have to take the first 14 words, replace them with their respective index , encode the indices into 11 digiti binary values, concat with 6 "0"'s onto the tail, shasum, take the first 5 bits of this output, and this dictates the 15th word.
Its convoluted

@piotr-iohk
Copy link
Contributor

So can we assume that the words provided from the docs are wrong? I mean,
https://github.com/input-output-hk/cardano-wallet/blob/master/specifications/mnemonic/english.txt

No, this is the full list of allowed words in the generated mnemonic sentence. It doesn't mean that you can just randomly pick any of the words and have a valid wallet recovery phrase out of them. See BIP39 - a standard for generating mnemonic sentences. It also lists several implementation libraries you can potentially use for generating. As mentioned before cardano-wallet cli also has this feature -> cardano-wallet recovery-phrase generate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants