Author

Topic: Bitcoind RPC - create a new address for every payment? (Read 716 times)

newbie
Activity: 5
Merit: 0
You can check the blockchain using bitcoind without having the private keys in the wallet. This blog post explains how.

Excellent, that's what I needed! Thank you so much! Smiley
jr. member
Activity: 56
Merit: 1
Sorry, but I don't want to involve any third-party apps.

Let's say I have generated random private key (256-bit number) and then its public address. All that in PHP only. I will still need a method to check in blockchain if there is required amount of BTC. Importing it into bitcoind won't solve the problem. Is there any way I can search blockchain? Maybe there is some open-source program that allows to filter transactions by public address or private key without importing it at all?

You can check the blockchain using bitcoind without having the private keys in the wallet. This blog post explains how.
newbie
Activity: 5
Merit: 0
Now you can use a bitcoin api like blockchain's to work out if a user has paid or not (and you can set how many confirmations)

Sorry, but I don't want to involve any third-party apps.

Let's say I have generated random private key (256-bit number) and then its public address. All that in PHP only. I will still need a method to check in blockchain if there is required amount of BTC. Importing it into bitcoind won't solve the problem. Is there any way I can search blockchain? Maybe there is some open-source program that allows to filter transactions by public address or private key without importing it at all?
jr. member
Activity: 56
Merit: 1
I want to make it customizable. However, I think at least 1 confirmation should be a requirement. But wait... is it even possible to detect a payment without any confirmations?

Yes it is possible in most cases to detect transactions as soon as they are sent to the network (that is how you can pay for things in less than 10 minutes with bitcoin).

What I would suggest is that you generate a master private key offline. You now have a private key P and a public key p.

With elliptic curve cryptography if you generate another private key Q with public key q. The public key formed by adding the private keys together will be equal to the public keys added together (in modular arithmetic). P+Q --> p+q

This means that you can use PHP to generate new public keys on the fly by setting Q = $payment.id

You can safely store p on the server (but never store P online) this means you can work out the public key the user has to pay to = p+q.

Now you can use a bitcoin api like blockchain's to work out if a user has paid or not (and you can set how many confirmations)

You can use this library to do the elliptic curve stuff (although you will have to add in the parameters for the secp256k1 curve).
newbie
Activity: 5
Merit: 0
Do you want payments to be detected as soon as they are sent (0-confirmations) or after they have been included in a block (1-confirmation)?

I want to make it customizable. However, I think at least 1 confirmation should be a requirement. But wait... is it even possible to detect a payment without any confirmations?
jr. member
Activity: 56
Merit: 1
Do you want payments to be detected as soon as they are sent (0-confirmations) or after they have been included in a block (1-confirmation)?
newbie
Activity: 5
Merit: 0
Is the idea that a developer would run a hot wallet and your PHP library on the server?

Exactly. My library is meant to be doing all the JSON-RPC-releated stuff to communicate with bitcoind to make receiving payments in various cryptocurrencies as simple as possible. Example code:

Code:
$client = new Client();
$payment = $client->createPayment();
$payment->setCurrency('BTC');
$payment->setAmount(0.01);
$payment->save();
print($payment->address);

Then, to check if user has paid:

Code:
$client = new Client();
$payment = $client->loadPayment($payment_id);
print($payment->status);

Maybe there is some way to modify wallet.dat file? I have found out that it's a Berkeley DB file. However, I'm afraid my script won't be able to edit it without root access. Additionally, modifying it while bitcoind is running may cause some troubles. And it HAS to be on all the time to update the blockchain...
jr. member
Activity: 56
Merit: 1
My question is - should it create a new address for every payment?

Yes, however if you plan on going over about 5000 addresses you might run into trouble with bitcoind.

Not knowing the architecture of your system, I can't tell you the best method to use. Is the idea that a developer would run a hot wallet and your PHP library on the server?
newbie
Activity: 5
Merit: 0
Hi!

I'm currently working on a PHP library that will help web developers receiving payments in BTC and other cryptocurrencies.

My question is - should it create a new address for every payment? As far as I know, bitcoind doesn't allow deleting addresses - can it cause troubles when numbers of addresses will go thousands? Or maybe there's a different way to do what I want to do?
Jump to: