<p>To spend any coins, you’ll need the private key corresponding to that bitcoin address. </p>

<p>In the case of an address derived from an xpub, you’ll need to use the xpriv that created the xpub to derive the child privkeys (they’ll be the same child pubkeys that the xpub derived, but this time you’ll have access to both child privkeys and pubkeys). As you know, it is not possible to derive the child privkeys from an xpub itself. </p>

CC BY-SA 3.0
2018-01-18T17:47:25.487Z
Thank you for your answer. When I create a HD wallet, I use my xpub. I have generated xpub somewhere and it generates addresses with pubKeys and privKeys too. But the address which has been generated  by the same xpub are not same with blockcypher's derivation. So how can I spend money in addresses in derived addresses in HD wallet? :(
Meysam Valueian
CC BY-SA 3.0
2018-01-18T19:37:26.110Z
I think you’ve mixed something up slightly, you cannot use an xpub to derive private keys, to do that you need the xpriv. I just took a look at BlockCypher’s wallet API docs (https://www.blockcypher.com/dev/bitcoin/#hierarchical-deterministic-hd-wallets), and it seems they use a different derivation scheme than the standard BIP32 layout. So you’ll need to find a way to derive the correct keys for the xpub you’ve provided to blockcypher, by following the blockcypher derivation scheme, from the xpub you provided.
chytrik
CC BY-SA 3.0
2018-01-18T15:32:23.150Z
2018-01-18T15:32:23.150Z
chytrik
<p>I am new in bitcoin. I want to implement a bitcoin payment system. I am using blockcypher's API. Suppose we have an hd wallet "myhdwallet" and we have driven 2 addresses using xpub for my hd wallet. (address A=> m/0/1 ,address B=>m/0/2,...). I want to create a transaction and send some bitcoins from my wallet's addresses to destination address C. How can I do that? I was successful in sending bitcoin using private keys. But here I do not have any private key for addresses. I just have wallet name and xpub. How can I do that using blockcypher's API?</p>

<transactions><bip32-hd-wallets>
Create Sign and send bitcoin transaction using HD wallet
Meysam Valueian
# Create Sign and send bitcoin transaction using HD wallet

(Asked by: username_0 on 2018-01-18)

I am new in bitcoin. I want to implement a bitcoin payment system. I am using blockcypher's API. Suppose we have an hd wallet "myhdwallet" and we have driven 2 addresses using xpub for my hd wallet. (address A=> m/0/1 ,address B=>m/0/2,...). I want to create a transaction and send some bitcoins from my wallet's addresses to destination address C. How can I do that? I was successful in sending bitcoin using private keys. But here I do not have any private key for addresses. I just have wallet name and xpub. How can I do that using blockcypher's API?

**Tags:** transactions, bip32-hd-wallets


---

## 1 answers

### Answer by username_1 on 2018-01-18. Score: 1

To spend any coins, you’ll need the private key corresponding to that bitcoin address.

In the case of an address derived from an xpub, you’ll need to use the xpriv that created the xpub to derive the child privkeys (they’ll be the same child pubkeys that the xpub derived, but this time you’ll have access to both child privkeys and pubkeys). As you know, it is not possible to derive the child privkeys from an xpub itself.

> **Comments:**
> **username_0**: Thank you for your answer. When I create a HD wallet, I use my xpub. I have generated xpub somewhere and it generates addresses with pubKeys and privKeys too. But the address which has been generated  by the same xpub are not same with blockcypher's derivation. So how can I spend money in addresses in derived addresses in HD wallet? :(  
> **username_1**: I think you’ve mixed something up slightly, you cannot use an xpub to derive private keys, to do that you need the xpriv. I just took a look at BlockCypher’s wallet API docs (https://www.blockcypher.com/dev/bitcoin/#hierarchical-deterministic-hd-wallets), and it seems they use a different derivation scheme than the standard BIP32 layout. So you’ll need to find a way to derive the correct keys for the xpub you’ve provided to blockcypher, by following the blockcypher derivation scheme, from the xpub you provided.  

---

