Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Feb 27, 2022

Adds some helper methods to make using urtypes easier and cleaner

  • Adds a urtype() classmethod to all registry items so that you can access the UR type name through the class:
> HDKey.urtype()
'crypto-hdkey'
  • Adds a from_script classmethod to ScriptExpression so that premade script expressions can be loaded by their script name rather than UR ID
> ScriptExpression.from_script('wpkh')
ScriptExpression(404, 'wpkh')
  • Adds a from_descriptor_key classmethod to HDKey that acts as the inverse of the existing descriptor_key method, enabling you to convert a bip32 key expression into an instance of HDKey
> HDKey.from_descriptor_key('[55f8fc5d/84h/1h/0h]tpubDCDuqu5HtBX2aD7wxvnHcj1DgFN1UVgzLkA1Ms4Va4P7TpJ3jDknkPLwWT2SqrKXNNAtJBCPcbJ8Tcpm6nLxgFapCZyhKgqwcEGv1BVpD7s')
HDKey(...)

@github-actions
Copy link

github-actions bot commented Feb 27, 2022

✅ Result of Pytest Coverage

---------- coverage: platform linux, python 3.9.10-final-0 -----------

Name Stmts Miss Cover
src/urtypes/init.py 2 0 100%
src/urtypes/bytes.py 16 1 94%
src/urtypes/cbor/init.py 3 0 100%
src/urtypes/cbor/data.py 30 4 87%
src/urtypes/cbor/decoder.py 132 58 56%
src/urtypes/cbor/encoder.py 94 20 79%
src/urtypes/crypto/init.py 9 0 100%
src/urtypes/crypto/account.py 26 1 96%
src/urtypes/crypto/bip39.py 23 1 96%
src/urtypes/crypto/coin_info.py 25 1 96%
src/urtypes/crypto/ec_key.py 31 1 97%
src/urtypes/crypto/hd_key.py 208 10 95%
src/urtypes/crypto/keypath.py 55 1 98%
src/urtypes/crypto/multi_key.py 37 0 100%
src/urtypes/crypto/output.py 127 17 87%
src/urtypes/crypto/psbt.py 6 1 83%
src/urtypes/registry.py 35 4 89%
TOTAL 859 120 86%

~ 15 passed in 0.25s ~

@ghost ghost force-pushed the descriptor-key-parsing branch from 38ed14e to b830952 Compare March 5, 2022 04:12
@ghost ghost force-pushed the descriptor-key-parsing branch from b830952 to 986c650 Compare March 5, 2022 04:15
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.

0 participants