Git Product home page Git Product logo

bsvbip32's Introduction

bsvbip32

BIP32 Hierarchical Deterministic wallet functions - extends bitsv

Noticeboard

This project is still in alpha. Expect lots to change - pin your versions if you are using this code!

I will post a road map here in due course.

  • I essentially want to have the "leaves of the BIP32 tree" inheriting all of the functionality of a bitsv.PrivateKey to make building prototype applications in Python a breeze.

Examples

  1. Create master node.
>>> from bsvbip32 import Bip32
>>> xprv = Bip32("xprv9s21ZrQH143K4Un4SHjdvXpzzdQjpm7vVhQ79BMi5V58nptUo4NGqytwH68XAVj5LkDxjSqdVjdDinFCT8WqfBT7zigdtaGcrffTmBdwFH5")
  1. Get receiving address for given derivation path (defaults to Electrum SV / Handcash path)
>>> # Get receiving addresses
>>> xprv.get_child_addresses(derivation_path='0', index_start=0, index_end=5)
['1PPro3nLxMB7A1BJXfZkRDHCRugj8z4d7R',
 '169YSZGMvtHvKbRHTpYCQZWx1phfJp2DCe',
 '1PhGu2V5T5g26bHi6qKg2KmxpUQLuNwyKT',
 '16WGTyMx578ghUzKbuvSsg2BnRAorm7bhm',
 '168A5g1AeLvkRHekEDRKXzDDqHPLkr2yHD']

>>> # Change addresses
>>> xprv.get_child_addresses(derivation_path='1', index_start=0, index_end=5)
['1FUT1Yn7RcsXADpkfweiVrfkPurkFBDfuU',
 '1M126MVQst5XGGqV6gVuXxCAwTGkwwgspk',
 '1BX2BzUhuWCod14BMLYUFyMiXX2qhJbNX5',
 '1KyeAK4q2sc6bcZ9nem878oFcNo59dmr1c',
 '1EEAjPDQwoBzQmXoy89BZKX4wyGpELQTc5']
  1. Master nodes (generated with an extended private key can generate child private keys).
>>> xprv.get_child_private_keys(derivation_path='0', index_start=0, index_end=5)
[private_for <xpub6AJDyEAwA8V7aVsF4dU3Kfdp9dH7W85F8iaWqgXqoeXEGWKBP3e7PeW2s76FM4krswNPkuHHUxaDPLD8aYG3CGyYU539MpHUsWCXk2W4pfV>,
 private_for <xpub6AJDyEAwA8V7ec7QFow54ssKpgtys6JY2gUzmpKQnDGvs6UoqYbpuu1a9JYxWJZ4UkWoZLAsRF2w8QA2pxDpMjyuzHDmYMTB7mpuPk5bpM5>,
 private_for <xpub6AJDyEAwA8V7ho8mZJyWFcz9kWzb8QcCSizGLsHgjKZj4eFT9LeuhUFyRXNzCzZJCPfmR2fXG9VXhHKVWJa9ZPUWK89rmjdkhTbQDUTTLfA>,
 private_for <xpub6AJDyEAwA8V7kRxmXXwCp6v49KAHxdcpXpQe7YZn6YuNrte4CxbeN8aYm7F3EZQgVpHCHX6yFnjK9Xt6pG6YBE67PefKPizpCYn2H33XCE7>,
 private_for <xpub6AJDyEAwA8V7nuwxUYCspcTEK99e2JosDFoMs47ZiRt9zNpjsBTvjD9zvFrmTj8Xt5seR7mYh4BMad2DVuqC49BeeKuP6Fgkj3XxHQv8f5Y>]
  1. Can also return WIF format:
>>> xprv.get_child_private_keys(derivation_path='0', index_start=0, index_end=5, wif_format=True)
['KykMGuukAqeEnMonWptccpfKpoBfQj7GYQ5wRkktW1Tg2PsK7c4P',
 'KwsnyDdzyggMnR5YwYPL7BytrBDXfVUTJUryF5dqjnqC67cDCkDU',
 'L5L11cqdt8wzssLa5PHxYEYakrQ6NwKgHMVE1DB5uVc3VNjetwZG',
 'L1oYZqnBCUD84qxnatAERsYVa213VCf8ko2Qgr7BbnpMhhMho9qP',
 'L2t4vZE5vHamUcw9knCC97pF7LbqVgAhjAueqGbZVGxyn2ASTaEW']


>>> # If you only have xpub key you can still generate the addresses to "view only"
>>> # Use the BitIndex api to query the network directly for xpub total balance etc.
>>> # xpub queries on BitIndex require an API key from https://www.bitindex.network/#get-api-key
  1. A view-only master node (with an xpub key)
>>> # This is how e.g. handcash, moneybutton, paymail servers generate addresses without ever seeing your private key.
>>> # First, lets use the xprv master node (from above) to get the xpub!
>>> xprv.get_xpub()

TODO

Complete examples for view-only wallet + ECDSA signatures.

bsvbip32's People

Contributors

austecon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bsvbip32's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.