Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

8

You really should not use floating point math for precision decimal values. It is a little-regarded truth of computer programming that when you're dealing with money you should avoid the usual IEEE floating-point math like the plague. This is the reason why Bitcoin transactions store values as 64-bit integers. Because storing them as floating point ...


8

Use BitWasp Bitcoin-php library https://github.com/Bit-Wasp/bitcoin-php <?php use BitWasp\Bitcoin\Bitcoin; use BitWasp\Bitcoin\Address; use BitWasp\Bitcoin\Key\PrivateKeyFactory; $network = Bitcoin::getNetwork(); $privateKey = PrivateKeyFactory::create(true); $publicKey = $privateKey->getPublicKey(); $address = $publicKey->getAddress(); If you ...


6

Not sure if you're still looking for an answer, but I just stumbled upon this myself and for the benefit of anyone running into this. Even though it's called cookie based authentication, you still authenticate via Basic HTTP. Let's say your cookie was __cookie__:somerandomlongstring then: Username __cookie__ Password somerandomlongstring I figured this ...


5

There is a step-by-step tutorial on the Bitcoin Wiki for converting Keys. For testing there is a very good website, where you can put in a private or public key and its show you the result of any step: http://gobittest.appspot.com/Address If you dont want to do those things on your own you could use Bitcore, a JavaScript API for Bitcoin. For a pure PHP ...


5

Since you say "sort of a BitPay system", I assume you don't want to use BitPay. You can start with dissecting some of the work people have done in the space on repositories such as bitwasp or bitcoin-php. This is probably more than you need, however the building blocks are there for what you want to do if you wanted all of the logic to live in php. If you ...


5

Bob can provide Alice with an extended public key (xpub). This will allow Alice to generate as many addresses as required, all of which will be accessible to Bob via the corresponding extended private key (xpriv), which only he has access to. There are many tools and libraries around that support address derivation from xpubs, such as BitcoinJS-lib. As far ...


4

You can find your answer here Snippet of code Example from bitcointalk <?php #Below is full list of available characters. #"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" $fp=fopen("/dev/urandom","r") or die; $available_chars="23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz"; do{ $minikey='S'; for($i=0;$i<...


4

Take a look at this, its the blockchain.info api. it gives a json feed for many things.


4

Your code is close to what you need: <?php $guid="xxxxxxxxx"; $main_password="xxxxxxxxx"; $json_url = "https://blockchain.info/merchant/$guid/balance?password=$main_password"; $json_data = file_get_contents($json_url); $json_feed = json_decode($json_data); $balance = $json_feed->balance; echo $balance; ?> The response looks like this (Wallet ...


4

I just read through the code that handles rpcallowip, and I can tell you that rpcallowip=0.0.0.0 won't work. If you want to allow from all addresses, you should use rpcallowip=0.0.0.0/0 (Weirdly, I can't find any code that handles wildcards. I'm going to open an issue on github about it. It looks like either the documentation or the code is wrong.) Edit:...


4

Cron Jobs and 3rd Party API: You could try with cron jobs, but I wouldn't run it every second, that's rather exhaustive. Maybe every 5 or 10 minutes, and then have it check the current total received vs the previous amount using a database. $addy = "1somebitcoinaddress"; $bcinfo = json_decode(file_get_contents("https://blockchain.info/address/".$addy."?...


3

I would highly discourage writing your own PHP Wallet App, in which without proper security, your wallet and your clients wallets might be compromised in the future. But if you insist on creating an online wallet, I would highly recommend Blockchain's Online Wallet. You can access the source code here The application is written in Javascript, which enables ...


3

you are trying to send amount as string. Sprintf returns string. You need to send amount as double (in PHP double == float). Try this way: $payment_tx = $ifc->sendtoaddress($account['address'], (double)$to_send); If it doesn't work, use move at first, because sending can fail under many circumstances, while move always works. Once you are done with ...


3

Yes, I have built exchanges with PHP and MySQL. I would also recommend Redis for caching.


3

You should use bcmath, because PHP's native calculations won't fit your needs.


3

You can use the command-line curl or any of the various JSON-RPC examples listed here. In particular, you can use curl like this: $ curl --user <username>:<password> --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getinfo", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/ For PHP, you can use this library and ...


3

This is likely implementation specific. Bitcoind is an intensive application to run on a basic server, especially if the webapp lives on the same machine. You should never directly connect a page's code with Bitcoin Core, for static information you should run a cronjob to update a cache every n seconds. If all you're showing is the last 10 blocks, maybe ...


3

You need to run a local nodejs service. From there you can then integrate with php. As of January 2016 Blockchain.info made changes to the wallet API service that now require you to run a local nodeJS service to handle the calls. This will require you to have root access to your webserver so you will need to use a VPS instead of a basic shared web host. ...


3

Here is the algorythm without the code: createrawtransaction with amount that you want to send assuming that fees are 0 fundrawtransaction to let your bitcoind construct final transaction, put your change address (on where you get change from unspent transaction - very important!) AND to caclulate fees that will be taken of your account for this transaction....


3

Hashes are big endian by standard, and most computers use little endian, so it's probably just for convenience. See Why does the Bitcoin protocol use the little-endian notation?


2

First, run bitcoind on your server. Set up bitcoin.conf to have the correct RPC port and a password and etc. Then, include the jsonRPCClient.php file: include('jsonRPCClient.php'); Then, instantiate an object like so: $bitcoind = new jsonRPCClient("http://$YOUR_RPC_USER:$YOUR_RPC_PASS@$YOUR_RPC_HOST:$YOUR_RPC_PORT/"); You can now run commands from the ...


2

If you are integrating with bitcoin directly, then you can use the bitcoin testnet (https://en.bitcoin.it/wiki/Testnet). If you are using a payment processor, Coinbase does not have sandbox feature like PayPal, although they have expressed interest in creating one based on bitcoin's testnet. Coinbase does allow sending test payment notifications (IPN) from ...


2

As @Bittylicious mentioned the JSON-RPC is a little bit buggy https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)#PHP Note: The jsonRPCClient library uses fopen() and will throw an exception saying "Unable to connect" if it receives a 404 or 500 error from bitcoind. This prevents you from being able to see error messages generated by bitcoind (as they are ...


2

Yes, Coinbase now supports using the Testnet.


2

https://en.bitcoin.it/wiki/PHP_developer_intro This site shows all you need to get going. You'll need to run a dedicated bitcoind wallet on a server, which can accept JSON-RPC to call the various functions of bitcoind, which will respond back with a JSON object.


2

The number of bitcoins in existence at any given time is predictable in advance. To get an approximate number, you just need to look it up in a table based on today's date. The Bitcoin wiki has one at Controlled supply. To get the precise number of mined bitcoins at any given moment, you would take the current block height (available from any of a number of ...


2

See bitcoin-prices.js library for JavaScript (front end, no server-side components needed) that uses free bitcoinaverage.com API.


2

The answer was to simply move bitcoin.conf in the correct directory, as described here: Where is the data folder for Bitcoin-Qt? Also, don't forget to set the correct file permissions as well; bitcoin.conf should be owner read-only!


2

blockchain.info's pushtx feature will reject transactions with OP_RETURN in it. You might want to try my tool https://github.com/kaykurokawa/pushtx


2

I think you have two options: 1) Patch bitcoin-core and make getrawmempoolentry return the mempool transaction sorted after entry_date. There is boost multi index that would be capable to fast sort the mempool transaction (https://github.com/bitcoin/bitcoin/blob/master/src/txmempool.h#L303) 2) You can try to improve your PHP sort speed. IMHO Arsort is not ...


Only top voted, non community-wiki answers of a minimum length are eligible