Author

Topic: blockchain.com api | How generate "Legacy" & "Nested SegWit" & "Native SegWit"? (Read 152 times)

jr. member
Activity: 47
Merit: 11
https://bitcointalk.org is the best & people around here are really pro.
Thanks for the answers.
legendary
Activity: 3472
Merit: 10611
I have a web site and i want create a unique "Legacy" & "Nested SegWit" & "Native SegWit" address for every customer to send & receive bitcoin.
So i need a free api to handle this!
Using a third party like this is very risky specially when you are using one that is known to have many bugs. They could end up creating an invalid address for you and any coins sent to that address would be lost.

It is best that you handle everything on your own. Generating an address from a public key is a pretty easy task too (it is a matter of computing a hash and doing a simple encoding).
You can also watch those addresses using the Electrum protocol (https://electrumx-spesmilo.readthedocs.io/en/latest/protocol.html). You can hire someone to code this all for you.
hero member
Activity: 910
Merit: 5935
not your keys, not your coins!
So i need a free api to handle this!
You do not; you do this locally on your own machine / server using the xpub. You will have one xpub per customer and derive as many addresses as you want fro that.

Unlimited addresses!
You can do that directly with the xpub.

No Expiration of those addresses!
Bitcoin addresses don't expire.

I don't want use some third party sites
Then don't use an API to derive addresses from xpub; just do it locally yourself, as I and BlackHatCoiner suggested.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
I do n't want use some third party sites like https://www.coinpayments.net for payment method because i need unique address for every customer for another purpose than payment.
Yes, but this way you still have a third party called blockchain dot com which is responsible for serving you the correct addresses. They may not have access to your money, but they are part of your business one way or another.

Anyway, you can't achieve having all three types of addresses from that API, which brings me the next question. I understand that you may want to have a different address for each client as you should, but why to serve them three addresses? That makes things more difficult and less practical.
jr. member
Activity: 47
Merit: 11
Quote
Would you mind telling us what you are trying to accomplish? You may get yourself satisfied with a response that doesn't have to do with this API.
I have a web site and i want create a unique "Legacy" & "Nested SegWit" & "Native SegWit" address for every customer to send & receive bitcoin.
So i need a free api to handle this!
Unlimited addresses!
No Expiration of those addresses!
I do n't want use some third party sites like https://www.coinpayments.net for payment method because i need unique address for every customer for another purpose than payment.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
Would you mind telling us what you are trying to accomplish? You may get yourself satisfied with a response that doesn't have to do with this API.

For instance, are you a merchant who wants to receive bitcoin payments in their site? You don't need to trust a third party for deriving you the correct addresses of your xpub key, you can do it yourself. Check btcpayserver.

"Legacy" or "Nested SegWit" or "Native SegWit"?
Legacy starts with 1.
Nested SegWit starts with 3.
Native SegWit starts with bc1.

My other question is : is there a way to generate "Legacy" & "Nested SegWit" & "Native SegWit" addresses for receive separately?
For nested segwit you'd need a ypub key and for native segwit a zpub key.
hero member
Activity: 910
Merit: 5935
not your keys, not your coins!
It seems they generate PKPKH addresses.

Have your customer send bitcoin to the address contained in the response:
Response:200 OK, application/json

{
  "address": "19jJyiC6DnKyKvPg38eBE8R6yCSXLLEjqw",
  "index": 23,
  "callback": "https://mystore.com?invoice_id=058921123"
}

But to be honest, I wouldn't send peoples' xPubs over the internet. You can easily calculate any kind of public key (and any number) locally if you already have their xPub. Should be possible with any Bitcoin- or more generic cryptography library.
jr. member
Activity: 47
Merit: 11
Please check out this link :
https://www.blockchain.com/api/api_receive
As you see we can generate receiving addresses for our customers using this api.

My first question is : what is the type of that generated address?
"Legacy" or "Nested SegWit" or "Native SegWit"?

My other question is : is there a way to generate "Legacy" & "Nested SegWit" & "Native SegWit" addresses for receive separately?
Jump to: