How to generate Electrum address with pybitcointools

0

I want to create a payment service where I want to be able to charge each client according to its invoice. I picked Electrum as my underlying wallet and pybitcontools as my Python interface.

I would like to assign for each invoice a separate address. However, using wallet GUI it requires a person doing so and would like to automate that. Sadly, I am unable to replicate the Electrum addresses and am a bit lost at what is going wrong

My current test code:

import bitcoin as btc

electrum_master_public_key = 'xpub67xegn2C1yS...'

for i in xrange( 5 ):
    print btc.pubkey_to_address( btc.bip32_descend( electrum_master_public_key, [0,i] ) )

All my generated addresses start with a 1 whereas Electrum's star with 3. Would appreciate if somebody would help me to link the two.

Sharapolas

Posted 2017-07-28T16:53:05.330

Reputation: 101

Answers

0

Electrum's addresses will only start with 3 if you are using some sort of Multisig (i.e. you either have a Multisig wallet or are using the TrustedCoin 2FA thing). With Multisig, you will need to get the master public keys for the other signers in order to create the right addresses. If you do have those keys, then you can use the bip32_hdm_addr function to create those addresses.

Non-multisig addresses will start with 1, and that is what most wallets will create by default as multisig requires multiple parties.

Andrew Chow

Posted 2017-07-28T16:53:05.330

Reputation: 40 910

I do have a 2FA account and I can get the master public keys for 3 cosigners, but how to merge them and then generate the keys for each n?Sharapolas 2017-07-30T15:41:13.647