Blockstream / green_android

Blockstream Green Wallet for Android
GNU General Public License v3.0
177 stars 74 forks source link

Error: "Unexpected child number" trying to import public key from electrum #201

Open 532910 opened 1 month ago

532910 commented 1 month ago

Unable to add watch only wallet due to the error: "Unexpected child number". The xpub string is got from electrum wallet. The same string (public key) imports successfully in unstoppable wallet.

LeoComandini commented 1 month ago

Hi @532910 ,

The Green apps use GDK, a common library to handle most of their operations.

GDK exposes a interface where most calls have a mandatory parameter "subaccount", e.g. https://gdk.readthedocs.io/en/release_0.71.0/gdk-json.html#unspent-outputs-request-json.

When importing a xpub, we need to deduce the subaccount number from the xpub, this is done here.

We expect the subaccount number to be the child number of your xpub, in hardened format. If that is not the case we return an error.

We can relax that constraint, but it takes a bit of time, and we need some evidence that is a common case.

Do you have the descriptor string for that xpub? That can be used as well, you might want to try it.