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

[PoC] Wallet policies (and miniscript support) #647

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bigspider
Copy link
Contributor

@bigspider bigspider commented Nov 16, 2022

Hello,

this in an exploratory PR as a proof of concept of how wallet policies could look like in HWI.

Wallet policies were presented to the bitcoin-dev mailing list back in May.
A BIP proposal is in preparation here.

The goals of this PR are to:

  • show that adding wallet policies to hwi is relatively straightforward and can be done with non-breaking changes
  • argue that wallet policies naturally and conveniently represent the "accounts" of a typical single-signature, multisignature or miniscript-based wallet accounts;
  • demo how a typical wallet-policy workflow could look like with hwi;
  • showcase specifically the implementation and UX in the Ledger bitcoin application.

Wallet policies are designed to be vendor-agnostic.
In fact, they are ready for miniscript wallets, and they might in my opinion be a convenient, opinionated way of adding miniscript support to HWI.

They are implemented in the Ledger bitcoin app since version 2.1.0, which uses them to support miniscript (on segwit only, at this time).

Implementation details

Not production-ready!

In this PR, I attempted to add wallet policies as a first-class object, while not breaking compatibility with existing code.

The three commit add:

  • The wallet-policy-related methods in HardwareWalletClient: can_register_wallet_policies, register_wallet_policy, display_wallet_policy_address, sign_tx_with_wallet_policy.
  • Support in CLI within displayaddress and signtx; added registerpolicy.
  • The specific implementation of wallet policies for the Ledger client in ledger.py.

For subclasses not implementing wallet policies, a compatibility layer guarantees that if the policy falls back into the supported cases (single-signature, or standard multisignature), calls to functions using wallet policies are automatically converted to the corresponding single-sig or multi-sig function to show addresses or sign transactions.

With this approach, software wallets adopting wallet policies, therefore, could use them directly without using any other HardwareWalletClient function without wallet policies.

Demo

In the following, I'd like to walk you through an end-to-end demo of wallet policies that can be tested from this PR's branch using the Ledger bitcoin testnet app version 2.1.0 in the speculos emulator; the app will be released in production within a few weeks.

In all the examples with multiple keys, internal keys are the ones with fingerprint f5acc2fd, which is the fingerprint for the default seed used by the speculos emulator.

The command should be run from the root folder of the HWI repository, or after installing the module from this PR (e.g. with pip install .).

Screenshots are based on the UX for a Ledger NanoS+ device.

Single-signature

In this example, we use a wallet policy for a standard BIP-86 taproot address. Ledger devices require no registration for standard single-signature policies, so this can be used directly.

# display address for a taproot BIP-86 address
python -m hwi --chain test --device-type ledger displayaddress\
       --policy "tr(@0/**)"\
       --keys "[\"[f5acc2fd/86'/1'/0']tpubDDKYE6BREvDsSWMazgHoyQWiJwYaDDYPbCFjYxN3HFXJP5fokeiK4hwK5tTLBNEDBwrDXn8cQ4v9b2xdW62Xr5yxoQdMu1v6c7UDXYVH27U\"]"

Device screen:

out

Output:


{"address": "tb1pws8wvnj99ca6acf8kq7pjk7vyxknah0d9mexckh5s0vu2ccy68js9am6u7"}

Multisignature

Register policy

# register a legacy multisig policy on the device
python -m hwi --chain test --device-type ledger registerpolicy\
       --policy "sh(sortedmulti(2,@0/**,@1/**))"\
       --name "Cold storage"\
       --keys "[\"[5c9e228d/48'/1'/0'/0']tpubDEGquuorgFNb8bjh5kNZQMPtABJzoWwNm78FUmeoPkfRtoPF7JLrtoZeT3J3ybq1HmC3Rn1Q8wFQ8J5usanzups5rj7PJoQLNyvq8QbJruW\",\"[f5acc2fd/48'/1'/0'/0']tpubDFAqEGNyad35WQAZMmPD4vgBXnjH16RGciLdWekPe4f4d5JzoHVu1PS86Sy4Tm63vDf8rfV3UjifhrRuSUDfiZj5KPffTPyZ4ZXBKvjD8jm\"]"

Device screen:
01-register

Output:

{"proof_of_registration": "fa73e36119324fbe4cc1ca94aa842c6261526d44112a22164bc57c3335102b04"}

Display address

# display an address for a registered multisig policy
python -m hwi --chain test --device-type ledger displayaddress\
       --policy "sh(sortedmulti(2,@0/**,@1/**))"\
       --name "Cold storage"\
       --keys "[\"[5c9e228d/48'/1'/0'/0']tpubDEGquuorgFNb8bjh5kNZQMPtABJzoWwNm78FUmeoPkfRtoPF7JLrtoZeT3J3ybq1HmC3Rn1Q8wFQ8J5usanzups5rj7PJoQLNyvq8QbJruW\",\"[f5acc2fd/48'/1'/0'/0']tpubDFAqEGNyad35WQAZMmPD4vgBXnjH16RGciLdWekPe4f4d5JzoHVu1PS86Sy4Tm63vDf8rfV3UjifhrRuSUDfiZj5KPffTPyZ4ZXBKvjD8jm\"]"\
       --extra "{\"proof_of_registration\": \"fa73e36119324fbe4cc1ca94aa842c6261526d44112a22164bc57c3335102b04\"}"

Device screen:
02-receive

Output:

{"address": "2Mx69MjHC4ViZAH1koVXPvVgaazbBCdr89j"}

Sign a psbt with policy

It is relevant to point out that when using wallet policies, it makes sense to use a more specific action rather than "sign a transaction": in fact, the wallet policy specifies exactly what kind of scripts/inputs should be signed, and similarly, what outputs can match a change address.
This allows hardware wallets to correctly identify internal inputs and outputs.

The necessary information about what exact wallet policy should be used for signing is in fact typically available to the software wallet.
Therefore, the action is "sign a transaction with a certain wallet policy".

# sign a psbt using a registered multisig policy
python -m hwi --chain test --device-type ledger signtx\
       cHNidP8BAH0CAAAAATu7ic6eCZKS8ISJpxQmv/DpLPyQgxBDTD7ECvecufnvAQAAAAD9////AjkwAAAAAAAAFgAUMxjgT65sEq/LAJxpzVflslBK5rTmQQEAAAAAACIAIKgAjP1KDkIBgF3Cmo+Jj+uu9mUmnEuPjoFZDYcT5J9YAAAAAAABAJQCAAAAAdnPFpiaZHjHIp9948kMd6KSqdFfHTv74HHnrMapIZneAAAAABcWABSPMOw+gW7W+tfmjgw1zGwPbdtlvv7///8CoQ7VAAAAAAAWABRv0DCr8w8BHXhZ+5ysOZpTo3v91KCGAQAAAAAAIgAg2TvCCm8+G8E0Ds5MifVQC5rxzbKlEwHbKRkVgPCLrgMjhh4AAQEroIYBAAAAAAAiACDZO8IKbz4bwTQOzkyJ9VALmvHNsqUTAdspGRWA8IuuAwEFR1IhAlAXEIvs6o3txTALsiOGs6swNnrCYvnOXlgybrg+OiL1IQNrFujB+Xn6TMDwW2owCv//lBRZtvIN533lWwFg745MrFKuIgYCUBcQi+zqje3FMAuyI4azqzA2esJi+c5eWDJuuD46IvUcdiI6bjAAAIABAACAAAAAgAIAAIAAAAAAAAAAACIGA2sW6MH5efpMwPBbajAK//+UFFm28g3nfeVbAWDvjkysHPWswv0wAACAAQAAgAAAAIACAACAAAAAAAAAAAAAAAEBR1IhAleBu0CgoDHY9QkXQyIkVOKYC765sDDZaHeMfWd9xszJIQLdg+T/0aVgy1q/LtEqLdTb6+V2KvUPwDCqjBF5gd9eO1KuIgICV4G7QKCgMdj1CRdDIiRU4pgLvrmwMNlod4x9Z33GzMkcdiI6bjAAAIABAACAAAAAgAIAAIABAAAAAAAAACICAt2D5P/RpWDLWr8u0Sot1Nvr5XYq9Q/AMKqMEXmB3147HPWswv0wAACAAQAAgAAAAIACAACAAQAAAAAAAAAA\
       --policy "wsh(sortedmulti(2,@0/**,@1/**))"\
       --name "Cold storage"\
       --keys "[\"[76223a6e/48'/1'/0'/2']tpubDE7NQymr4AFtewpAsWtnreyq9ghkzQBXpCZjWLFVRAvnbf7vya2eMTvT2fPapNqL8SuVvLQdbUbMfWLVDCZKnsEBqp6UK93QEzL8Ck23AwF\",\"[f5acc2fd/48'/1'/0'/2']tpubDFAqEGNyad35aBCKUAXbQGDjdVhNueno5ZZVEn3sQbW5ci457gLR7HyTmHBg93oourBssgUxuWz1jX5uhc1qaqFo9VsybY1J5FuedLfm4dK\"]"\
       --extra "{\"proof_of_registration\": \"d7c7a60b4ab4a14c1bf8901ba627d72140b2fb907f2b4e35d2e693bce9fbb371\"}"

Device screen:
03-spend

Output:

{"psbt": "cHNidP8BAH0CAAAAATu7ic6eCZKS8ISJpxQmv/DpLPyQgxBDTD7ECvecufnvAQAAAAD9////AjkwAAAAAAAAFgAUMxjgT65sEq/LAJxpzVflslBK5rTmQQEAAAAAACIAIKgAjP1KDkIBgF3Cmo+Jj+uu9mUmnEuPjoFZDYcT5J9YAAAAAAABAJQCAAAAAdnPFpiaZHjHIp9948kMd6KSqdFfHTv74HHnrMapIZneAAAAABcWABSPMOw+gW7W+tfmjgw1zGwPbdtlvv7///8CoQ7VAAAAAAAWABRv0DCr8w8BHXhZ+5ysOZpTo3v91KCGAQAAAAAAIgAg2TvCCm8+G8E0Ds5MifVQC5rxzbKlEwHbKRkVgPCLrgMjhh4AAQEroIYBAAAAAAAiACDZO8IKbz4bwTQOzkyJ9VALmvHNsqUTAdspGRWA8IuuAyICA2sW6MH5efpMwPBbajAK//+UFFm28g3nfeVbAWDvjkysRzBEAiBqspfIOrZuVzcjiSBh2CfFrAFQ4gRP7X7TR0L+28+ybgIgMZzfTq3f9j/DCM31PiJeoDQCTvlt4D/Qk5tt7uoei9MBAQVHUiECUBcQi+zqje3FMAuyI4azqzA2esJi+c5eWDJuuD46IvUhA2sW6MH5efpMwPBbajAK//+UFFm28g3nfeVbAWDvjkysUq4iBgJQFxCL7OqN7cUwC7IjhrOrMDZ6wmL5zl5YMm64Pjoi9Rx2IjpuMAAAgAEAAIAAAACAAgAAgAAAAAAAAAAAIgYDaxbowfl5+kzA8FtqMAr//5QUWbbyDed95VsBYO+OTKwc9azC/TAAAIABAACAAAAAgAIAAIAAAAAAAAAAAAAAAQFHUiECV4G7QKCgMdj1CRdDIiRU4pgLvrmwMNlod4x9Z33GzMkhAt2D5P/RpWDLWr8u0Sot1Nvr5XYq9Q/AMKqMEXmB3147Uq4iAgJXgbtAoKAx2PUJF0MiJFTimAu+ubAw2Wh3jH1nfcbMyRx2IjpuMAAAgAEAAIAAAACAAgAAgAEAAAAAAAAAIgIC3YPk/9GlYMtavy7RKi3U2+vldir1D8AwqowReYHfXjsc9azC/TAAAIABAACAAAAAgAIAAIABAAAAAAAAAAA=", "signed": true}

Miniscript

Miniscript policy: a 3-of-3 that becomes a 2-of-3 after 90 days: thresh(3,pk(key_1),pk(key_2),pk(key_3),older(12960)).

Register policy

# register the wallet policy
python -m hwi --chain test --device-type ledger registerpolicy\
       --policy "wsh(thresh(3,pk(@0/**),s:pk(@1/**),s:pk(@2/**),sln:older(12960)))"\
       --name "Decaying 3of3"\
       --keys "[\"[f5acc2fd/48'/1'/0'/2']tpubDFAqEGNyad35aBCKUAXbQGDjdVhNueno5ZZVEn3sQbW5ci457gLR7HyTmHBg93oourBssgUxuWz1jX5uhc1qaqFo9VsybY1J5FuedLfm4dK\",\"tpubDCsD8geGfXgcBhxuvqqEGSmCR5P56f2rwxvcg51h9PL39zYXS4k4Ryn5eNdxN9H9umPbezhKZjpzS6Bjv6WbRQZqtvoHtQ29pkn1VZ3GA7k\",\"tpubDD1dWr4oGX2148MJ3WBGTCfC8i2H5juMExoSzE5nHdzRNJeVcxY1qT1WFBASTubBQpbW6Tt2KBbmy8rZNiC4oXZhEnc9BW6x33yPYizRjpc\"]"

Device screen:
01-register

Output:

{"proof_of_registration": "bac398f60b85214815051bc89bd7f6d94097f0b53ae61a18acad6c7bc3e9f80b"}

Display address

# display a specific address
python -m hwi --chain test --device-type ledger displayaddress\
       --policy "wsh(thresh(3,pk(@0/**),s:pk(@1/**),s:pk(@2/**),sln:older(12960)))"\
       --name "Decaying 3of3"\
       --keys "[\"[f5acc2fd/48'/1'/0'/2']tpubDFAqEGNyad35aBCKUAXbQGDjdVhNueno5ZZVEn3sQbW5ci457gLR7HyTmHBg93oourBssgUxuWz1jX5uhc1qaqFo9VsybY1J5FuedLfm4dK\",\"tpubDCsD8geGfXgcBhxuvqqEGSmCR5P56f2rwxvcg51h9PL39zYXS4k4Ryn5eNdxN9H9umPbezhKZjpzS6Bjv6WbRQZqtvoHtQ29pkn1VZ3GA7k\",\"tpubDD1dWr4oGX2148MJ3WBGTCfC8i2H5juMExoSzE5nHdzRNJeVcxY1qT1WFBASTubBQpbW6Tt2KBbmy8rZNiC4oXZhEnc9BW6x33yPYizRjpc\"]"\
       --extra "{\"proof_of_registration\": \"bac398f60b85214815051bc89bd7f6d94097f0b53ae61a18acad6c7bc3e9f80b\"}"\
       --change 1\
       --index 3

Device screen:
02-receive

Output:

{"address": "tb1qca0tjjln3fhp3rsyg7tvmyf2x5fmvgk6lcp0zfzmmwr2y8vapllstc36ug"}

Sign a psbt with the policy

# sign a tx
python -m hwi --chain test --device-type ledger signtx\
       cHNidP8BAH0CAAAAAUN7Z9JlC6y6LtlwbTIVzEtWHw6AiBgWuDRIkxoZCKMpAQAAAAD9////AkBCDwAAAAAAFgAUYE60U6z6Rpo5RK6oC+g6RUkxu7usTIkAAAAAACIAIESrl1+a21z6n3pLozjP4AHIQOofzJHNgz3NwDxBwASBAAAAAAABAIkCAAAAAa15z+lMT/YZ0sRDAkaL5A5tBBPIAmil+V/5AePextPvAAAAAAD+////AttabSkBAAAAIlEg0VQ1MNBHwNuDbYWtzEaEV1yANsJurWNqvZxlikhKbbKAlpgAAAAAACIAIESyacRc1GKFR/8RdvMWQ0hcAleGITHMJP6A4Kn5YBy7aQAAAAEBK4CWmAAAAAAAIgAgRLJpxFzUYoVH/xF28xZDSFwCV4YhMcwk/oDgqflgHLsBBXohAp5kb7ngRSRglE5J+IafmrnakIINpdU4Qa+eEnGjvPnOrHwhAoz4Y6xeDg72tAuWuExobc18NXLIzXVx22mvkaLEE3NIrJN8IQIOXt2k+7FDkz0OYPBWmB18LIpxqwY4t8C/kRn7SyouvqyTfGMAZwKgMrKSaJNThyIGAg5e3aT7sUOTPQ5g8FaYHXwsinGrBji3wL+RGftLKi6+DGYCRCIAAAAAAwAAACIGAoz4Y6xeDg72tAuWuExobc18NXLIzXVx22mvkaLEE3NIDKjFojkAAAAAAwAAACIGAp5kb7ngRSRglE5J+IafmrnakIINpdU4Qa+eEnGjvPnOHPWswv0wAACAAQAAgAAAAIACAACAAAAAAAMAAAAAAAEBeiEDRKw0XW+7Q+lxieEI8mjMwAlG8J//ABlTcQlFY93EOwSsfCECmEf2+BbuDI1lxfRMhvkJ2Ij5Qhy0tcpBkQ6MSrYJsCOsk3whA1hZjepNSbXWWXSb7LP7oaJkkN6gA7v/nJxbSAslYPsxrJN8YwBnAqAyspJok1OHIgICmEf2+BbuDI1lxfRMhvkJ2Ij5Qhy0tcpBkQ6MSrYJsCMMqMWiOQEAAAABAAAAIgIDRKw0XW+7Q+lxieEI8mjMwAlG8J//ABlTcQlFY93EOwQc9azC/TAAAIABAACAAAAAgAIAAIABAAAAAQAAACICA1hZjepNSbXWWXSb7LP7oaJkkN6gA7v/nJxbSAslYPsxDGYCRCIBAAAAAQAAAAA=\
       --policy "wsh(thresh(3,pk(@0/**),s:pk(@1/**),s:pk(@2/**),sln:older(12960)))"\
       --name "Decaying 3of3"\
       --keys "[\"[f5acc2fd/48'/1'/0'/2']tpubDFAqEGNyad35aBCKUAXbQGDjdVhNueno5ZZVEn3sQbW5ci457gLR7HyTmHBg93oourBssgUxuWz1jX5uhc1qaqFo9VsybY1J5FuedLfm4dK\",\"tpubDCsD8geGfXgcBhxuvqqEGSmCR5P56f2rwxvcg51h9PL39zYXS4k4Ryn5eNdxN9H9umPbezhKZjpzS6Bjv6WbRQZqtvoHtQ29pkn1VZ3GA7k\",\"tpubDD1dWr4oGX2148MJ3WBGTCfC8i2H5juMExoSzE5nHdzRNJeVcxY1qT1WFBASTubBQpbW6Tt2KBbmy8rZNiC4oXZhEnc9BW6x33yPYizRjpc\"]"\
       --extra "{\"proof_of_registration\": \"bac398f60b85214815051bc89bd7f6d94097f0b53ae61a18acad6c7bc3e9f80b\"}"

Device screen:
03-spend

Output:

{"psbt": "cHNidP8BAH0CAAAAAUN7Z9JlC6y6LtlwbTIVzEtWHw6AiBgWuDRIkxoZCKMpAQAAAAD9////AkBCDwAAAAAAFgAUYE60U6z6Rpo5RK6oC+g6RUkxu7usTIkAAAAAACIAIESrl1+a21z6n3pLozjP4AHIQOofzJHNgz3NwDxBwASBAAAAAAABAIkCAAAAAa15z+lMT/YZ0sRDAkaL5A5tBBPIAmil+V/5AePextPvAAAAAAD+////AttabSkBAAAAIlEg0VQ1MNBHwNuDbYWtzEaEV1yANsJurWNqvZxlikhKbbKAlpgAAAAAACIAIESyacRc1GKFR/8RdvMWQ0hcAleGITHMJP6A4Kn5YBy7aQAAAAEBK4CWmAAAAAAAIgAgRLJpxFzUYoVH/xF28xZDSFwCV4YhMcwk/oDgqflgHLsiAgKeZG+54EUkYJROSfiGn5q52pCCDaXVOEGvnhJxo7z5zkcwRAIgTbB7mkwLeNWNMZ8KGkhAfQPlAEpDNMsMjvsgsmxX/h0CIE7q1xBjQufpIozPXcUBhR4twriYwziY5fpHvOF0SF4YAQEFeiECnmRvueBFJGCUTkn4hp+audqQgg2l1ThBr54ScaO8+c6sfCECjPhjrF4ODva0C5a4TGhtzXw1csjNdXHbaa+RosQTc0isk3whAg5e3aT7sUOTPQ5g8FaYHXwsinGrBji3wL+RGftLKi6+rJN8YwBnAqAyspJok1OHIgYCDl7dpPuxQ5M9DmDwVpgdfCyKcasGOLfAv5EZ+0sqLr4MZgJEIgAAAAADAAAAIgYCjPhjrF4ODva0C5a4TGhtzXw1csjNdXHbaa+RosQTc0gMqMWiOQAAAAADAAAAIgYCnmRvueBFJGCUTkn4hp+audqQgg2l1ThBr54ScaO8+c4c9azC/TAAAIABAACAAAAAgAIAAIAAAAAAAwAAAAAAAQF6IQNErDRdb7tD6XGJ4QjyaMzACUbwn/8AGVNxCUVj3cQ7BKx8IQKYR/b4Fu4MjWXF9EyG+QnYiPlCHLS1ykGRDoxKtgmwI6yTfCEDWFmN6k1JtdZZdJvss/uhomSQ3qADu/+cnFtICyVg+zGsk3xjAGcCoDKykmiTU4ciAgKYR/b4Fu4MjWXF9EyG+QnYiPlCHLS1ykGRDoxKtgmwIwyoxaI5AQAAAAEAAAAiAgNErDRdb7tD6XGJ4QjyaMzACUbwn/8AGVNxCUVj3cQ7BBz1rML9MAAAgAEAAIAAAACAAgAAgAEAAAABAAAAIgIDWFmN6k1JtdZZdJvss/uhomSQ3qADu/+cnFtICyVg+zEMZgJEIgEAAAABAAAAAA==", "signed": true}

Conclusions

I hope this is interesting and I look forward to hearing your comments about whether (and how) wallet policies could be added to hwi.

@pythcoiner
Copy link

Hi Salvatore, I successfully used this PR with simples scripts from Liana, but getting some issue with some more complex one:

$ python3 -m hwi --debug --device-type ledger registerpolicy --policy "wsh(or_i(and_v(v:thresh(1,pkh(@0/<8;9>/*),a:pkh(@1/<4;5>/*),a:pkh(@2/<4;5>/*)),older(65535)),or_i(and_v(v:thresh(2,pkh(@0/<6;7>/*),a:pkh(@1/<2;3>*)),older(15001)),or_i(and_v(v:thresh(2,pkh(@0/<4;5>/*),a:pkh(@2/<2;3>/*)),older(15000)),or_d(multi(2,@0/**,@3/**),and_v(v:thresh(3,pkh(@1/**),a:pkh(@2/**),a:pkh(@0/<2;3>/*)),older(1)))))))#lnc99art" --name "Liana" --keys "[\"[9978d14e/84h/0h/0h]zpub6s7PH15YtcVFyEPJjjdNhEjA4n1D77DUhZyU4JZMXsWQ4C8kssYGDrne6jcDTXHRXajxFNTTiCbqpVtqZAhfV37Zm6wcDj4reSujMH3AFgC\",\"[0063c8e2/84h/0h/0h]zpub6rj3eaikqs5UF3gDggHC8inmnYcEFCfSNB3Sja3NkC4bNDURbmGequcC8uPa9GMbcUs7WSBbernhxHgoctjNvmveT5vYQGHQSvSA12g1UwW\",\"[945d917c/84h/0h/0h]zpub6rWPeMxpZS9xpwBadedssZ71UzeutatXnegqqrWkrrSim4BiFrcUdTPtLxtPGpUtBzbiM1ZPaXXVcrhb9Su1ettffQ6B1y5JHcyd4P516rm\",\"[8a491f24/84h/0h/0h]zpub6qaBba3PS8R8k61SueSazVotxKP7iwQ3Gp3c42DTSaWKP5qt6fcSqRjGxw7hRHLP7XaFiEQXDHcKHoZ9rurD9n1SkPFSoYsfP2H7Ch9vbmQ\"]"

(keys have been generated for this example)

output:

DEBUG:ledgercomm:=> b001000000
DEBUG:ledgercomm:<= 0107426974636f696e05322e312e320102 9000
DEBUG:ledgercomm:=> e105000100
DEBUG:ledgercomm:<= a5c6b76e 9000
WARNING:jade:No module named 'hwilib.devices.jadepy.jade_ble'
WARNING:jade:BLE scanning/connectivity will not be available
INFO:jade.tcp:Connecting to tcp:127.0.0.1:2222
DEBUG:root:Failed to connect to Jade simulator at tcp:127.0.0.1:2222
DEBUG:root:[Errno 111] Connection refused
DEBUG:ledgercomm:=> b001000000
DEBUG:ledgercomm:<= 0107426974636f696e05322e312e320102 9000
DEBUG:ledgercomm:=> e10200014c4b02054c69616e61fd5701a0bc52da5e91b136121dcaf5ab9f8124c36bd7b1781e40c0dd8018d1931c18ef043b14c61425ea5a4195b20cef010767a32cc7755e394c1bb063609ab83e7e45d9
DEBUG:ledgercomm:<= 4000a0bc52da5e91b136121dcaf5ab9f8124c36bd7b1781e40c0dd8018d1931c18ef e000
DEBUG:ledgercomm:=> f8010001fffd5701fb777368286f725f6928616e645f7628763a74687265736828312c706b682840302f3c383b393e2f2a292c613a706b682840312f3c343b353e2f2a292c613a706b682840322f3c343b353e2f2a29292c6f6c64657228363535333529292c6f725f6928616e645f7628763a74687265736828322c706b682840302f3c363b373e2f2a292c613a706b682840312f3c323b333e2a29292c6f6c64657228313530303129292c6f725f6928616e645f7628763a74687265736828322c706b682840302f3c343b353e2f2a292c613a706b682840322f3c323b333e2f2a29292c6f6c64657228313530303029292c6f725f64286d756c746928322c40302f2a
DEBUG:ledgercomm:<= a0 e000
DEBUG:ledgercomm:=> f80100015e5c012a2c40332f2a2a292c616e645f7628763a74687265736828332c706b682840312f2a2a292c613a706b682840322f2a2a292c613a706b682840302f3c323b333e2f2a29292c6f6c646572283129292929292929236c6e633939617274
DEBUG:ledgercomm:<=  6a80
Traceback (most recent call last):
  File "/home/pyth/python/HWI/hwilib/errors.py", line 231, in handle_errors
    yield
  File "/home/pyth/python/HWI/hwilib/_cli.py", line 318, in process_commands
    result = args.func(args, client)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pyth/python/HWI/hwilib/_cli.py", line 79, in registerpolicy_handler
    return registerpolicy(client, name=args.name, policy=args.policy, keys=args.keys, extra=args.extra)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pyth/python/HWI/hwilib/commands.py", line 499, in registerpolicy
    return {"proof_of_registration": client.register_wallet_policy(wp, parsed_extra).hex()}
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pyth/python/HWI/hwilib/devices/ledger.py", line 123, in func
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/home/pyth/python/HWI/hwilib/devices/ledger.py", line 580, in register_wallet_policy
    _, hmac = self.client.register_wallet(wallet_policy)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pyth/python/HWI/hwilib/devices/ledger_bitcoin/client.py", line 112, in register_wallet
    raise DeviceException(error_code=sw, ins=BitcoinInsType.REGISTER_WALLET)
hwilib.devices.ledger_bitcoin.exception.errors.IncorrectDataError: ('0x6a80', 'Error in <BitcoinInsType.REGISTER_WALLET: 2> command', '')
{"error": "('0x6a80', 'Error in <BitcoinInsType.REGISTER_WALLET: 2> command', '')", "code": -13}

note: i firstly fail to register this policy from Liana before trying with this PR

@bigspider
Copy link
Contributor Author

@pythcoiner: most likely the reason is that zpubs are not standard and unsupported; they need to be xpub on mainnet, or tpub on any testnet/regtest/signet.

@pythcoiner
Copy link

@pythcoiner: most likely the reason is that zpubs are not standard and unsupported; they need to be xpub on mainnet, or tpub on any testnet/regtest/signet.

i just checked the original keys that throw the errow were xpub as well, i generated from another source new keys for this example(and not notice that they are zpub), but i'll try reproduce with xpubs

@bigspider
Copy link
Contributor Author

  1. Not sure if the checksum #lnc99art is handled, my examples above are without
  2. There's a pkh(@1/<2;3>*) that should be pkh(@1/<2;3>/*)
  3. The policy is too long for Nano S

Fixing those, I was able to register the policy on local tests on NanoS+, so I think it should also work with hwi from this PR.

@pythcoiner
Copy link

  1. Not sure if the checksum #lnc99art is handled, my examples above are without
  2. There's a pkh(@1/<2;3>*) that should be pkh(@1/<2;3>/*)
  3. The policy is too long for Nano S

Fixing those, I was able to register the policy on local tests on NanoS+, so I think it should also work with hwi from this PR.

1 + 2 solved my issue, thanks @bigspider!

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

Successfully merging this pull request may close these issues.

2 participants