Bitcoin Forum
May 11, 2024, 01:42:40 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Bitcoin Technical Support / sendtoaddress sending 0 amount every time PHP on: September 02, 2019, 07:52:37 PM
So using the easybitcoin.php library I'm making a test wallet controller for regtest. I have it working to generate blocks and new addresses but transactions arent working properly. I have a form that sends which address and which amount and the script is as follows for processing the transaction:

Code:
	$amount= (float) number_format($_POST['amount'], 8);
$bitcoin->settxfee(0.0004);
$txid = $bitcoin->sendtoaddress($_POST['sendTo'], $amount);

Doing that when I get txinfo I get a txid and all that but the amount is 0 every time. Same if I used the code like this:

Code:
	$amount= $_POST['amount'];
$bitcoin->settxfee(0.0004);
$txid = $bitcoin->sendtoaddress($_POST['sendTo'], (float) $amount);

This is very frustrating as it makes it difficult to test my app. I also hard coded 3.32 for example so it was a float to begin with and still the transaction is sent with a 0 amount. What is going on?


Code:
	$bitcoin->settxfee(0.0004);
$txid = $bitcoin->sendtoaddress($_POST['sendTo'], 3.32);

All of them I get a $txid and using $txinfo = gettransaction($txid) I can get the txid using $txinfo['txid'] but $txinfo['amount'] always returns as 0.
2  Bitcoin / Bitcoin Technical Support / Checking Address Balance with Bitcoin Core on: August 08, 2019, 11:04:08 AM
I have an online store and already accept CC payments and I want to start accepting crypto. I'm using the regtest to test the application and so I can't rely on third party APIs plus I feel doing that will hurt at scaling. I'm trying to set it up where each new order will have its own address and I'll have a cronjob periodically check if the address received the payment then send money to cold storage wallet as follows:

Generate address -> receive payment -> wait for confirmations -> send coins to cold storage and show confirmed payment

Currently I save the address in a database associated with the order and generate it using getnewaddress(). I'm stuck on checking the balance of said address and how many confirmations the payment has. I saw accounts looked kind of like what I was looking for but its deprecated so I cant use that. I looked into using blockchain.info JSON API but then with scaling I have to worry about request limits and if I'm trying to request information on too many addresses at once I think it will result in an error. For example, say I have like 4000 orders and the cronjob needs to check all 4000 addresses during the cronjob to get it done efficiently then the addresses that received enough confirmation switch order to paid in database and send coins to cold storage wallet off of server. Plus I'm trying to test it in regtest mode so obviously I cant use a 4rd party API. I saw listunspent() after manually adding addresses and rescanning the chain but I feel if you have thousands of orders and addresses it will be very inefficient every time the job is run and slow the server down.

What is a solution to what I'm trying to accomplish?

I'm very tech savvy and am interested in the be my own bank aspect so I'm not trying to use third party processors or use blockchain.info's wallet API.
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!