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?


1 Answer 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.

  • 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? :( Jan 18, 2018 at 17:47
  • 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 (blockcypher.com/dev/bitcoin/…), 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
    Jan 18, 2018 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.