Press "Enter" to skip to content

Blockchain Receive Payments API v2 HD BIP32 xpub

Blockchain Receive Payments API v2 HD BIP32 xpub

Blockchain Receive Payments API v2 HD BIP32 xpub hi welcome to another building Bitcoin websites article tutorial blockchain dot info recently changed their receive payments API they have now released version 2 and they are actually out phasing version 1 and the big difference between version 2 and version 1 is the hierarchal deterministic wallet also known as HD bit 32 so receive payments API is meant for merchants this new version creates more privacy for the merchants which well go over in just a bit it uses HD wallet so it can generate addresses deterministically so you only need one private key and it can then generate all the future private keys that will be used theres also no forwarding in this new version the previous version for did funds well go over that and it still provides callbacks or notifications you can also think of a callback similar to a cron job if youre familiar with the web development cron jobs it will run a certain file or a certain page every a certain amount of time that you set so you can have a cron job run once an hour once a day once every minute whatever you set and then its usually used to update a database or other things on your website and I can think of a callback similar to that except it will run when a payment is received on a designated Bitcoin address ok so the version 1 of the Bitcoin Im sorry the blockchain received payments API is being phased out on December December 7th theyre going to be getting rid of the version 1 and switching over to version 2 so lets explain how the version 1 worked and the differences so version 1 you would provide a Bitcoin address your Bitcoin address and when someone would visit your page it would generate a new address and then after that someone also visit your page and Ill generate yet another unique address and once these are generated it creates a callback URL so once funds are recei for one of these addresses so lets say someone sends funds to this one new address what its going to do is after I believe its one confirmation it kind of changed a bit as time went on during the spam attack that was happening in early 2015 but once this ad just received the funds blockchain dot info would then send the funds back to this address for no charge for free so it would create two transactions when it was only actually one transaction on the blockchain and so when someone would send a fund to this address once it was received it would forward the funds back over to the originating address now this created a lack of privacy for a merchant someone could follow these addresses if you say you sent funds to this address you could watch and see where it was sent to and then you can see the merchants main address here and see how many sales theyre doing and things like that also when it sent these funds it would send a callback URL to your website so you can update things and thats still the same the callback but the version two it uses an extended public key known as BIP 32 or hierarchical deterministic wallets you get an extended public key and this is what you provide the receive payments API when someone visits the page itll generate a new address when someone sends funds to this address it does not forward funds back because it doesnt need to because its an extended public key this address was generated based off of the public key the extent of publicly BIP 32 and it also has an extended private key so you have the key to this address and when it generates this address you have the key to this address as well and so on and so forth all the way through these addresses when I looked up on the wiki it said I believe two to the 32nd power so thats in the order of in the billions of addresses that can be created someone please correct me if Im wrong regarding the extent of public key and how many addresses can be derived but it looks like in the orders of billions so you should not really ever run out of these I know itll just keep generating addresses youll always have access to these and there is no forwarding back to the original address because it doesnt need to so this a it increases privacy for the user or for the merchant so they cant see where the funds are being forwarded because there are no funds being forwarded it also reduces stress and transactions on the blockchain now theres only one transaction going through there are no forwarding transactions going on those are the big differences between the to receive payment API is with blockchain again theyre going to phase out version 1 so if youre using version 1 you need to go update your code you can watch I have a article on the receive payments API the usage between version 1 and version 2 are very very similar the only difference is is instead of providing them with a unique Bitcoin address for receive youre providing them with an extended public key alright and youre also going to need to request a API key with blockchain info so head over to blockchain info go to their API section and then the API receive area and then just scroll down to the second paragraph and they have an area where you can request an API key it takes about well at least for me into about 24 hours and so youll need that with every request you send so with all so every request you send you will need an extended public key you can use one from an outside wallet your own or you can use a one from blockchain Don infos new wallet its currently an alpha you can sign up for it at alpha dot blockchain dot info heres one that I signed up with and Ive been sending some test payments to it and these are all two different addresses here that have been generated with receive payment API but youll notice it all shows under one wallet on my address and you can use that to build some pretty cool things so something that Ive put together is I created a shopping cart on my website so you can go here people can add things to their cart and then they can check out their card it will grab the current exchange rate and they can checkout and let me type in a fake info here so then it fills out all the info and then hit submit and it will go to review and confirm them itll tell them their address that was entered and their order line item total amount USD total mountain Bitcoin and then they can confirm and pay so Im going to bring up my wallet on my cell phone so then confirm and pay is going to pop up the amount that they owed and then a unique address using the receive payments API so let me go ahead and send some money use my cell phone so Ill take a picture of the QR code or Ill scan it and almost send just a little bit 0.002 because I dont have a lot in this particular wallet right now and then Im going to hit Send and youll notice the website received it and notice right away this is using blockchain dot infos web socket API I have a separate article on using that you can check it out if youd like to so now the person knows theyve received it Ive also created email notifications so at this point the person has received an email regarding their order and for the merchant lets go back and youll see the 0.02 has showed up and no payment forwarding is going on also with this since I was dabbling through this I decided to also create an admin panel so then it will show the recent orders here like how it it shows there and so you can click on the order itll show that I was supposed to seven zero point seven for what I ordered with Tom Jones but I only paid zero point zero two because I didnt have a lot my wallet so the admin panel will tell you that this particular person underpaid has a unique order number you can view the transaction on blockchain info thats right there the ship to address what theyõre by ID and amount and I have a mark an order complete the reason I do that is if somebody didnt pay you in full or maybe you just want to mark something complete once you ship the item so you can hit mark order complete and then you can go back and youll see that its marked under completed I also created a managed inventory so you can do that very easily go in and edit one of your products just change something so what if I change this to a Bitcoin funtime or just something stupid but then you can go back and see that the that the shop section now reflects the updated info that we put in there lets go back and I also maybe so you can add a product very easily so if you want to add a Bitcoin USB minor its 10 USD these are old but they work and they wont make much money or whatever it is and you can put in an image link so you dont have to upload anything to your server if you dont want to so lets look up a USB a ruptor image grab one here we go click view image copy that paste it in here click add product lets go back to our shop and it will be down here automatically resizes it and it has been added this project is opensource I have put it on github go to my github and its under blockchain receive payments API and you can use this exact thing that I created using the receive API this is just one of the implementations you can do but its very powerful because the callback so when someone sends a payment it automatically updates your web server so I have this one when a payments received as you saw it updated it in the ad panel you know it showed here with an order and this is all using the boxing receive payment API only thing that wasnt using the receive payment API was the thing that popped up when the payment came in that was using the WebSocket for realtime notifications thats pretty much it for this article if you liked it we want to subscribe like the article and head on over to my github and check out this latest project and thats it for today and Ill see you next time bye

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *