Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: maxus033 on November 26, 2020, 05:16:20 AM



Title: Generate Receive Code Via API
Post by: maxus033 on November 26, 2020, 05:16:20 AM
Hi,

What's the best API to create a wallet or a receive code and give users to send bitcoins?

I was working with BTC.com but their script is outdated and SDK files don't work on Laravel 8.0+

Need a secure API which allows creating a wallet using a API and generate a receive code to give to the user to submit bitcoins to.  

Then using API check the wallet's balance to see if any bitcoins has been sent.

* Also checked Blockchain API, the Registration form to get a API key doesn't even work there....


Title: Re: Generate Receive Code Via API
Post by: HCP on November 26, 2020, 06:22:23 AM
Do you need to create a separate wallet for each user and for them to be able to generate multiple addresses?  Or are you wanting to use one wallet that you control, and simply provide the users with a unique "deposit" address so they can send you bitcoins?

What exactly are you attempting to build? ???


Title: Re: Generate Receive Code Via API
Post by: mocacinno on November 26, 2020, 06:32:49 AM
Why don't you run your own node using bitcoin core and use the json-rpc api directly? You can even install nbxplorer on top of your node and then run btcpayserver (depending on your usecase)

Or, in case there are resource restrictions, run an electrum node and use it's json-rpc api....

Cut out the middle man, no restrictions, no limits: be in controll of your own funds!


Title: Re: Generate Receive Code Via API
Post by: NotATether on November 26, 2020, 11:58:08 AM
You want to send QR codes to your users via an API? You should be able to construct a bitcoin QR code from creating the underlying URI and query string defined in BIP21 (https://en.bitcoin.it/wiki/BIP_0021#ABNF_grammar), and then use a library to encode it into a QR code. Then return the image as base64.

I'm not fluent in PHP, but like mocacinno said, the JSON-RPC interface is always available. It will be helpful in checking if an address has had bitcoins sent to.


Title: Re: Generate Receive Code Via API
Post by: maxus033 on November 28, 2020, 06:38:00 PM
Do you need to create a separate wallet for each user and for them to be able to generate multiple addresses?  Or are you wanting to use one wallet that you control, and simply provide the users with a unique "deposit" address so they can send you bitcoins?

What exactly are you attempting to build? ???

In my platform users enter how much they want to pay as a donation and the system should give them a receive code to deposit the amount.

Basically just need to give the user an address to send money to. I wouldn't know who paid as they only get a wallet address to pay into. But I will only know if there's funds in the wallet as the wallet is new and only that end user has the address.


Thanks guys for the info.


Title: Re: Generate Receive Code Via API
Post by: HCP on December 04, 2020, 06:52:08 AM
Depending on how much you're expecting to receive... Mycelium Gear (https://gear.mycelium.com/) offers a "free" service for up to 0.1BTC/month... once you tick over 0.1btc/month, there is a service fee of 0.5% per transaction

Essentially, you plug in a Master Public Key, and it takes care of the rest, and provides code and/or widgets you can use to embed the "donate" button on your website.

So, if you're after a quick and easy solution and you expect to get less than 0.1btc/month, it might be worth checking out. If you're expecting more and don't want the fees, then I'd be inclined to run a node and use something like btcpayserver like mocacinno suggested.


Title: Re: Generate Receive Code Via API
Post by: bob123 on December 04, 2020, 02:15:20 PM
I wouldn't know who paid as they only get a wallet address to pay into.

If you don't need to know which user sent you the donation, simply just use a single static address.
If you want to know which user sent you the donation, use a new address for each user. Depending on how your website is constructed this can be done with multiple tools.

You could use core, electrum or a centralized service provider. That's up to you. Searching the internet with your favorite search engine or using this forum search will yield enough results.


Title: Re: Generate Receive Code Via API
Post by: PrimeNumber7 on December 05, 2020, 05:25:08 AM

If you don't need to know which user sent you the donation, simply just use a single static address.

Address reuse leads to a reduction in privacy for everyone, and incremental reduction in security (I am guilty of this sometimes, as are many other people).

Ideally, the OP should generate a new address each time he receives a transaction, but at a minimum, he should generate a new address each time he spends any coin he received.  


Title: Re: Generate Receive Code Via API
Post by: bob123 on December 05, 2020, 01:24:50 PM
Address reuse leads to a reduction in privacy for everyone,

If OP is planning to post his address on a website, he obviously doesn't care that the address is being associated with his website.
Just as you have your address posted on your profile.

If you (as a sender; e.g. as donator) care about your privacy, you should not rely on the receiver. That would be a huge mistake.
If you care about your privacy, make sure that you send mixed coins. But don't rely on the receiver to always generate a new address for everyone.



and incremental reduction in security

Calling address reuse a reduction in security is exaggerated.



Ideally, the OP should generate a new address each time he receives a transaction

In OP's case this might not be necessary. So there is literally no good reason for him to invest time and work into something he might not need at all.
If i understood him correctly, a single static address is absolutely fine for him.


Title: Re: Generate Receive Code Via API
Post by: HCP on December 07, 2020, 10:47:18 PM
I'm confused, if you just need to enter your Master Public Key, how Mycelium charge 0.5% service fee?
I have never gone over the 0.1 BTC threshold, but I suspect they will just "lock" your account so that the widgets no longer function and/or you are unable to log into your account if you refuse to pay up the service fee.

It seems to bill "in arrears"... mine says the next bill will be payable on Dec 9th... but is 0 BTC to pay as I have not received over the 0.1 BTC threshold.


Title: Re: Generate Receive Code Via API
Post by: blocksdk on December 08, 2020, 04:02:48 AM
Recommend BLOCKSDK
You can create a wallet using the API.


Website
https://blocksdk.com

API Docs
https://docs.blocksdk.com/bitcoin#createwallet

SDK Github
https://github.com/Block-Chen/blocksdk-php

Code:
use BlockSDK;

$blockSDK = new BlockSDK("YOU_TOKEN");
$btcClient = $blockSDK->createBitcoin();

$wallet = $btcClient->createWallet([
    "name" => "test"
]);

var_dump($wallet);


Title: Re: Generate Receive Code Via API
Post by: PrimeNumber7 on December 08, 2020, 06:09:55 AM
Address reuse leads to a reduction in privacy for everyone,

If OP is planning to post his address on a website, he obviously doesn't care that the address is being associated with his website.
Just as you have your address posted on your profile.
Address reuse leads to a reduction of privacy for everyone. Not just the sender and receiver.

Posting an address on a website that remains static means everyone will be able to trivially gain insight into the finances of the OP. Posting an address that changes means that everyone can closely watch the OP's website to gain insight into his finances, but the casual observer will be unable gain substantial insight to how much the OP is receiving, and an observer would be unable to know how much the OP received before they start watching his website.


Title: Re: Generate Receive Code Via API
Post by: bob123 on December 08, 2020, 09:54:52 AM
Address reuse leads to a reduction of privacy for everyone. Not just the sender and receiver.

If you care about your privacy, do something for it.
Don't rely on others.

It is absolutely irrelevant what someone else is doing if you want to preserve your privacy. If you rely on others, you already have lost.
There are multiple ways to increase the privacy with bitcoin. But relying on others to not reuse addresses definitely is not one of them.



Posting an address on a website that remains static means everyone will be able to trivially gain insight into the finances of the OP. Posting an address that changes means that everyone can closely watch the OP's website to gain insight into his finances, but the casual observer will be unable gain substantial insight to how much the OP is receiving, and an observer would be unable to know how much the OP received before they start watching his website.

So?
Again, if OP doesn't care and just wants to be able to receive donations.. then what is the problem with it?

If OP doesn't want this to be the case, that's absolutely fine. But if he doesn't care, there is no reason to change the address for each donation.