Bitcoin Forum
November 17, 2017, 06:24:08 PM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Bitcoind RPC - create a new address for every payment?  (Read 559 times)
Xayan
Newbie
*
Offline Offline

Activity: 5


View Profile
May 02, 2014, 04:14:55 PM
 #1

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?
1510943048
Hero Member
*
Offline Offline

Posts: 1510943048

View Profile Personal Message (Offline)

Ignore
1510943048
Reply with quote  #2

1510943048
Report to moderator
1510943048
Hero Member
*
Offline Offline

Posts: 1510943048

View Profile Personal Message (Offline)

Ignore
1510943048
Reply with quote  #2

1510943048
Report to moderator
Coinlancer is Disrupting the Freelance marketplace!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1510943048
Hero Member
*
Offline Offline

Posts: 1510943048

View Profile Personal Message (Offline)

Ignore
1510943048
Reply with quote  #2

1510943048
Report to moderator
1510943048
Hero Member
*
Offline Offline

Posts: 1510943048

View Profile Personal Message (Offline)

Ignore
1510943048
Reply with quote  #2

1510943048
Report to moderator
1510943048
Hero Member
*
Offline Offline

Posts: 1510943048

View Profile Personal Message (Offline)

Ignore
1510943048
Reply with quote  #2

1510943048
Report to moderator
telepatheic
Jr. Member
*
Offline Offline

Activity: 56

Get off the web. Go do something in meatspace!


View Profile
May 02, 2014, 04:40:46 PM
 #2

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?
Xayan
Newbie
*
Offline Offline

Activity: 5


View Profile
May 02, 2014, 05:24:29 PM
 #3

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...
telepatheic
Jr. Member
*
Offline Offline

Activity: 56

Get off the web. Go do something in meatspace!


View Profile
May 02, 2014, 06:10:53 PM
 #4

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)?
Xayan
Newbie
*
Offline Offline

Activity: 5


View Profile
May 02, 2014, 06:13:31 PM
 #5

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?
telepatheic
Jr. Member
*
Offline Offline

Activity: 56

Get off the web. Go do something in meatspace!


View Profile
May 02, 2014, 06:52:31 PM
 #6

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).
Xayan
Newbie
*
Offline Offline

Activity: 5


View Profile
May 02, 2014, 07:19:36 PM
 #7

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?
telepatheic
Jr. Member
*
Offline Offline

Activity: 56

Get off the web. Go do something in meatspace!


View Profile
May 02, 2014, 07:30:18 PM
 #8

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.
Xayan
Newbie
*
Offline Offline

Activity: 5


View Profile
May 02, 2014, 07:44:23 PM
 #9

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
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!