slimofftb (OP)
Newbie
Offline
Activity: 47
Merit: 0
|
|
February 23, 2013, 06:58:56 AM |
|
im trying to show transactions for a specific account in bitcoind. But with <?php
require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://xxxx:xxxx@xx.x.x.x:8332/'); print_r($bitcoin->listtransactions(account)); ?> It appears all garbled on the webpage. Is there any way to fix that?
|
|
|
|
gweedo
Legendary
Offline
Activity: 1498
Merit: 1000
|
|
February 23, 2013, 07:13:33 AM |
|
well that is cause print_r will show it in a more of debug format with the type and stuff like that. If you want to do... <?php require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://xxxx:xxxx@xx.x.x.x:8332/'); $json=$bitcoin->listtransactions(account)); ?>
now with that you can do this <?php for($i=count($json)-1; $i>=0; $i--){ echo $json[$i]['address']."\n"; echo $json[$i]['category']."\n"; echo $json[$i]['amount']."\n"; echo $json[$i]['confirmations']."\n"; echo $json[$i]['txid']."\n"; } ?>
|
|
|
|
slimofftb (OP)
Newbie
Offline
Activity: 47
Merit: 0
|
|
February 23, 2013, 07:26:06 AM |
|
code doesnt seem to work
|
|
|
|
gweedo
Legendary
Offline
Activity: 1498
Merit: 1000
|
|
February 23, 2013, 07:33:17 AM |
|
code doesnt seem to work Can you give me the error? just tested it and works for me
|
|
|
|
slimofftb (OP)
Newbie
Offline
Activity: 47
Merit: 0
|
|
February 23, 2013, 05:29:58 PM |
|
i got it lol there wasnt an issue with the code you posted. i was trying to do something like this..... <?php $address = $_SESSION['user_name']; require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://XXXX:XXXX@XXXX:8332/'); $json=$bitcoin->listtransactions($address) ?>
<?php for($i=count($json)-1; $i>=0; $i--){ echo $json[$i]['address']."\n"; echo $json[$i]['category']."\n"; echo $json[$i]['amount']."\n"; echo $json[$i]['confirmations']."\n"; echo $json[$i]['txid']."\n"; } ?> $_SESSION['user_name']; is the account name .... just had a typo... thank you so much!!
|
|
|
|
slimofftb (OP)
Newbie
Offline
Activity: 47
Merit: 0
|
|
February 24, 2013, 05:36:07 AM |
|
so if i was to want to send coins to an address i would use code like this? <?php
require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://xxxx:xxxx@10.0.0.2:8332/'); print_r($bitcoin->walletpassphrase(password, 3));
?> <?php
require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://xxx:xxx@XXXXXX:8332/'); print_r($bitcoin->settxfee(0.0005));
?> <?php $address = $_POST['account']; $to = $_POST['toaddress']; $amount = $_POST['amount'];
require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://xxxx:xxxx@xxxx:8332/'); print_r($bitcoin->sendfrom($address, $to, $amount, 1, comment, comment));
?> I have a feeling i have this all wrong
|
|
|
|
gweedo
Legendary
Offline
Activity: 1498
Merit: 1000
|
|
February 24, 2013, 05:50:04 AM |
|
no that looks right
|
|
|
|
slimofftb (OP)
Newbie
Offline
Activity: 47
Merit: 0
|
|
February 24, 2013, 06:04:56 AM |
|
you sure... i just tested it and it didnt work....
|
|
|
|
gweedo
Legendary
Offline
Activity: 1498
Merit: 1000
|
|
February 24, 2013, 06:10:16 AM |
|
so if i was to want to send coins to an address i would use code like this? <?php
require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://xxxx:xxxx@10.0.0.2:8332/'); print_r($bitcoin->walletpassphrase(password, 3));
?> <?php
require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://xxx:xxx@XXXXXX:8332/'); print_r($bitcoin->settxfee(0.0005));
?> <?php $address = $_POST['account']; $to = $_POST['toaddress']; $amount = $_POST['amount'];
require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://xxxx:xxxx@xxxx:8332/'); print_r($bitcoin->sendfrom($address, $to, $amount, 1, comment, comment));
?> I have a feeling i have this all wrong <?php $address = $_POST['account']; $to = $_POST['toaddress']; $amount = floatval($_POST['amount']);
require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://xxxx:xxxx@xxxx:8332/'); print_r($bitcoin->sendfrom($address, $to, $amount, 1, comment, comment));
?> try that it should work now
|
|
|
|
slimofftb (OP)
Newbie
Offline
Activity: 47
Merit: 0
|
|
February 24, 2013, 06:49:28 AM |
|
when i use a variable like $address for the sendfrom it doesnt work. if i put just an account name there instead of using a variable it works.... hmmmmm... is there something i should be doing when i input the variable?? Error msg shows that its null when i use a variable..... Working code <?php $address = $_POST['account']; $to = $_POST['toaddress']; $amount = floatval($_POST['amount']);
require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://xxxx:xxxx@xxxx:8332/'); print_r($bitcoin->sendfrom(account, $to, $amount, 1, comment, comment));
?> Not working code <?php $address = $_POST['account']; $to = $_POST['toaddress']; $amount = floatval($_POST['amount']);
require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://xxxx:xxxx@xxxx:8332/'); print_r($bitcoin->sendfrom($address, $to, $amount, 1, comment, comment));
?>
|
|
|
|
gweedo
Legendary
Offline
Activity: 1498
Merit: 1000
|
|
February 24, 2013, 06:55:23 AM |
|
Then check where that post variable is coming from and make sure you have the correct input name in where the post name is coming from.
|
|
|
|
slimofftb (OP)
Newbie
Offline
Activity: 47
Merit: 0
|
|
February 24, 2013, 07:37:50 AM |
|
now its working with the variable but it is giving error now... idk why hmmm here is my code.... <?php $password = xxxx; require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://xxx:xxx@xxx:8332/'); print_r($bitcoin->walletpassphrase($password, 3)); ?> <?php require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://xxx:xxx@xxxx:8332/'); print_r($bitcoin->settxfee(0.0005)); ?> <?php
$address3 = $_POST['user_name']; $to = $_POST['fax']; $amount = floatval($_POST['web']);
require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://xxx:xxx@xxxx:8332/'); print_r($bitcoin->sendfrom($address3, $to, $amount, 1, comment, comment));
?>
and i get an error Warning: fopen(http://...@xxxx:8332/): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in /opt/lampp/htdocs/login1/jsonRPCClient.php on line 132
Fatal error: Uncaught exception 'Exception' with message 'Unable to connect to http://xxx:xxx@xxx:8332/' in /xxx/xxxxx/xxxxxxx/xxx/jsonRPCClient.php:140 Stack trace: #0 /opt/lampp/htdocs/login1/cashout2.php(25): jsonRPCClient->__call('sendfrom', Array) #1 /xxx/xxxx/xxxx/xxxx/xxxxx.php(25): jsonRPCClient->sendfrom('admin', '18rkzRh7VwArgoL...', 0.017, 1, 'comment', 'comment') #2 {main} thrown in /opt/lampp/htdocs/login1/jsonRPCClient.php on line 140 Alls i did was change the code.... hmmmm tip for you if this gets solved
|
|
|
|
gweedo
Legendary
Offline
Activity: 1498
Merit: 1000
|
|
February 24, 2013, 07:52:42 AM |
|
It can't connect to your bitcoind, or your username and password isn't correct.
|
|
|
|
slimofftb (OP)
Newbie
Offline
Activity: 47
Merit: 0
|
|
February 24, 2013, 07:55:40 AM |
|
everything else using bitcoind on the site works fine.... connects like it should.... like listing transactions for accounts and balances....
|
|
|
|
gweedo
Legendary
Offline
Activity: 1498
Merit: 1000
|
|
February 24, 2013, 07:58:37 AM |
|
Do this $bitcoin->walletpassphrase($password, 60)
then after the function
|
|
|
|
|