Reputation: 29
I'm writing a script that will send funds that have been wired into a certain bitcoin wallet to another address using PHP and the JSON RPC API.
So far I've got something like this:
$x = '0.1'; // <- just redirect coins when the wallet balance is higher 0.1
$fee = '0.0001'; // <- transaction fee for miners
$y = $x + $fee;
$balance = $bitcoin->getbalance(); // get wallet-balance, here's my problem
$transfer = $balance - $fee;
if($balance >= $y){
$bitcoin->sendtoaddress($address, floatval($transfer));
}else{
// nothing. idle until the script is executed again
}
This works great except that
$bitcoin->getbalance();
Does return the balance including transactions with less than 5 confirmations.
Using the commandline i can get what i want with a simple command:
bitcoin-cli getbalance '*' 5
Can I somehow send the parameters ('*' 5) via JSON RPC/PHP?
I appreciate any answer because if I cant' figure it out I'll just give sufficient rights to the webserver and use shell_exec(). :-/
Thanks.
Upvotes: 0
Views: 1523
Reputation: 29
Uhm... well.. I figured it out...
According to https://en.bitcoin.it/wiki/PHP_developer_intro
$bitcoin->getbalance("", 5);
Guess I should read the whole thing next time. -.-
Upvotes: 2