Author

Topic: Any PHP script that would do this ? (Read 1229 times)

sr. member
Activity: 412
Merit: 266
July 17, 2014, 10:05:28 AM
#14

My library borrows some stuff from Mikes (Or else Mikes borrows from an upstream one).

https://github.com/Bit-Wasp/bitcoin-lib-php/blob/master/src/BitcoinLib.php#313-328 This function generates a key pair + address.

The library doesn't use RPC calls, it's up to you to know what to use it for! You'd need either blockchains API or else some sort of transaction scraper to identify payments your addresses. A scraper gets complicated, since you need to be prepared for reorgs.

In your code, as I can see, to get new private key, the following are being used...

Code:
\SECcurve::generator_secp256k1()
openssl_random_pseudo_bytes(32)

The second is in PHP lib, but is the first one ? If not, then how the first one is invoked ? I'm a little confused !!!

And, I'm not relying on a scraper to identify payment. Now, we have, multiple block explorers for bitcoin. We can check any address balance using their API and verify from multiple explorers.

Clone the project from Github, or download the zip file: https://github.com/Bit-Wasp/bitcoin-lib-php

You can use composer (https://github.com/Bit-Wasp/bitcoin-lib-php/blob/master/README.md#installation) to manage all this. Install, and then include "./vendor/autoload.php"

Check the examples folder on how to use it then!
newbie
Activity: 1
Merit: 0
July 17, 2014, 09:46:33 AM
#13
Can't you just use RPC with Bitcoind
https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list

Bitcoind also has a function that will run a command when a transaction has been made.
https://en.bitcoin.it/wiki/Running_Bitcoin
legendary
Activity: 2282
Merit: 1204
The revolution will be digital
July 17, 2014, 06:24:27 AM
#12

My library borrows some stuff from Mikes (Or else Mikes borrows from an upstream one).

https://github.com/Bit-Wasp/bitcoin-lib-php/blob/master/src/BitcoinLib.php#313-328 This function generates a key pair + address.

The library doesn't use RPC calls, it's up to you to know what to use it for! You'd need either blockchains API or else some sort of transaction scraper to identify payments your addresses. A scraper gets complicated, since you need to be prepared for reorgs.

In your code, as I can see, to get new private key, the following are being used...

Code:
\SECcurve::generator_secp256k1()
openssl_random_pseudo_bytes(32)

The second is in PHP lib, but is the first one ? If not, then how the first one is invoked ? I'm a little confused !!!

And, I'm not relying on a scraper to identify payment. Now, we have, multiple block explorers for bitcoin. We can check any address balance using their API and verify from multiple explorers.
legendary
Activity: 2282
Merit: 1204
The revolution will be digital
July 17, 2014, 06:23:48 AM
#11
I'm not sure about that, but it looks PHP can not generate BTC addresses itself:
https://github.com/bitcoin/bitcoin/blob/d3165ed35adde59bdfbe72928b51a039202fa21e/src/rpcwallet.cpp#L79

Before, I have seen a code by Theymos in Python that can independently generate an address. Moreover, given the fact that Bitcoin-QT is written in C++ and generating address independently, PHP should also be able to do the same. It is about taking a big random no. and doing some cryptographic transformation on it to generate private key and address.
sr. member
Activity: 412
Merit: 266
July 17, 2014, 04:01:02 AM
#10
My library borrows some stuff from Mikes (Or else Mikes borrows from an upstream one).

https://github.com/Bit-Wasp/bitcoin-lib-php/blob/master/src/BitcoinLib.php#313-328 This function generates a key pair + address.

The library doesn't use RPC calls, it's up to you to know what to use it for! You'd need either blockchains API or else some sort of transaction scraper to identify payments your addresses. A scraper gets complicated, since you need to be prepared for reorgs.
newbie
Activity: 14
Merit: 0
July 17, 2014, 03:40:22 AM
#9
I'm not sure about that, but it looks PHP can not generate BTC addresses itself:
https://github.com/bitcoin/bitcoin/blob/d3165ed35adde59bdfbe72928b51a039202fa21e/src/rpcwallet.cpp#L79
legendary
Activity: 2282
Merit: 1204
The revolution will be digital
July 16, 2014, 10:19:53 AM
#8
As in, a script that you can copy paste? probably not. but there's scripts for doing each of the steps you mentioned.

Can u please at least point me to the address generation and Tx creation PHP script ? For Tx creation function, the i/p will be address and private key.
Here ya go Smiley

https://github.com/mikegogulski/bitcoin-php/blob/master/src/bitcoin.inc#L567

Thank u for the link. From a quick look, what I understand that it relies on JSON-RPC call to a BitcoinD to generate a new address. I'm not looking for that. I am looking for a PHP code that can generate a Bitcoin address & Private key combination without relying on any external call.
newbie
Activity: 14
Merit: 0
July 16, 2014, 02:32:35 AM
#7
Yeah, this can be done quickly by daemon's JSON-RPC API nor with command-line interface. Also I prepared something like you want with nodejs and blockchain.info before, not so hard to do in my opinion.
full member
Activity: 210
Merit: 100
★☆★ 777Coin - The Exciting Bitco
July 16, 2014, 02:21:41 AM
#6
As in, a script that you can copy paste? probably not. but there's scripts for doing each of the steps you mentioned.

Can u please at least point me to the address generation and Tx creation PHP script ? For Tx creation function, the i/p will be address and private key.
Here ya go Smiley

https://github.com/mikegogulski/bitcoin-php/blob/master/src/bitcoin.inc#L567
legendary
Activity: 2282
Merit: 1204
The revolution will be digital
July 15, 2014, 12:16:06 PM
#5
This would be really simple to create, I'm sure someone with a few months of coding can whip this up quickly using Blockchain's JSON-RPC API.

The whole thing can be done using blockchain.info receive API in a single call. But, there are associated problems. Sometimes, when it takes more than 20 minutes to find a block, blockchain.info API takes looooooong time to forward the balance and does not make the callback at all !!! Hence, I'm trying to get rid of the blockchain.info dependency for receival purpose. If the code can be found or I can make it up by adding multiple snippets, it would probably help the community in general to partly move out of blockchain.info dependency for payment receival.
legendary
Activity: 2282
Merit: 1204
The revolution will be digital
July 15, 2014, 12:10:17 PM
#4
As in, a script that you can copy paste? probably not. but there's scripts for doing each of the steps you mentioned.

Can u please at least point me to the address generation and Tx creation PHP script ? For Tx creation function, the i/p will be address and private key.
hero member
Activity: 784
Merit: 500
July 15, 2014, 11:48:44 AM
#3
This would be really simple to create, I'm sure someone with a few months of coding can whip this up quickly using Blockchain's JSON-RPC API.
legendary
Activity: 2058
Merit: 1431
July 15, 2014, 11:46:04 AM
#2
As in, a script that you can copy paste? probably not. but there's scripts for doing each of the steps you mentioned.
legendary
Activity: 2282
Merit: 1204
The revolution will be digital
July 15, 2014, 11:23:45 AM
#1
1. Generate a random bitcoin address.

2. Will check it's own address balance and confirmation at some of the existing block explorer service at a certain time interval using API call.

3. When a balance is found on the address with n+ confirmation, it pushes a Tx in network forwarding the balance to a certain address.

4. Make a call to a function amountSent with amount in satoshi and Tx ID as input, i.e. amountSent(amount, txid).
Jump to: