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?
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.