Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: 687_2 on December 16, 2014, 01:40:19 AM



Title: How to create a new public address using Python for an HD wallet?
Post by: 687_2 on December 16, 2014, 01:40:19 AM
I searched but could not find a clear answer. Sorry in advance for terminology errors. This seems useful:

https://github.com/richardkiss/pycoin

However I'm not sure I understand how to do the following with that library:

1. Create a HD wallet (i.e. create a new Electrum wallet with seed and all that)
2. Create a new public key that is derived from that HD wallet, or from an existing wallet

My goal is to create a public address that can be presented to a customer on a website. The code will live on a remote server; I would like the public keys created to relate back to a private (offline) HD wallet.



Title: Re: How to create a new public address using Python for an HD wallet?
Post by: jonald_fyookball on December 16, 2014, 03:13:57 AM
here's a script you can look at which is similar to what you're trying to do. it's based off electrum.

https://bitcointalk.org/index.php?topic=694521.0


Title: Re: How to create a new public address using Python for an HD wallet?
Post by: luv2drnkbr on December 16, 2014, 10:02:21 AM
You'll need to keep the master public key on the online machine, and then use the get_address() function the script jonald linked to.  Then on your offline machine, you can get the private keys for it with the get_private_key() function.

That being said, I'd recommend using BIP0032 HD wallets instead of Electrum.  Bip32 is becoming the standard for exactly that type of use case, and there are more tools and information about it.


Title: Re: How to create a new public address using Python for an HD wallet?
Post by: 687_2 on December 16, 2014, 04:24:54 PM
here's a script you can look at which is similar to what you're trying to do. it's based off electrum.

https://bitcointalk.org/index.php?topic=694521.0

Very useful, thanks.


Title: Re: How to create a new public address using Python for an HD wallet?
Post by: 687_2 on December 16, 2014, 04:35:28 PM
You'll need to keep the master public key on the online machine, and then use the get_address() function the script jonald linked to.  Then on your offline machine, you can get the private keys for it with the get_private_key() function.

That being said, I'd recommend using BIP0032 HD wallets instead of Electrum.  Bip32 is becoming the standard for exactly that type of use case, and there are more tools and information about it.

Thanks for the clarification; after looking into BIP0032 I found this library which I think will be perfect for this application:
https://github.com/jmcorgan/bip32utils



Title: Re: How to create a new public address using Python for an HD wallet?
Post by: Abdussamad on December 20, 2014, 12:26:51 PM
I searched but could not find a clear answer. Sorry in advance for terminology errors. This seems useful:

https://github.com/richardkiss/pycoin

However I'm not sure I understand how to do the following with that library:

1. Create a HD wallet (i.e. create a new Electrum wallet with seed and all that)
2. Create a new public key that is derived from that HD wallet, or from an existing wallet

My goal is to create a public address that can be presented to a customer on a website. The code will live on a remote server; I would like the public keys created to relate back to a private (offline) HD wallet.



Try this WP plugin that I released recently:

https://bitcointalk.org/index.php?topic=900327.0

It's not bip32 compatible but will work with an Electrum MPK

You can use the shortcode or, if you know how to code php, call the get_address() function in your own plugin:

Code:
global $AbdBitcoinAddress;
$address = $AbdBitcoinAddress->get_address();