Bitcoin Forum
November 09, 2024, 11:28:31 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: formatting listtransactions bitcoind PHP  (Read 1864 times)
slimofftb (OP)
Newbie
*
Offline Offline

Activity: 47
Merit: 0



View Profile WWW
February 23, 2013, 06:58:56 AM
 #1

im trying to show transactions for a specific account in bitcoind. But with

 
Code:
<?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 Offline

Activity: 1498
Merit: 1000


View Profile
February 23, 2013, 07:13:33 AM
 #2

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...
Code:
<?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
Code:
<?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 Offline

Activity: 47
Merit: 0



View Profile WWW
February 23, 2013, 07:26:06 AM
 #3

code doesnt seem to work Sad
gweedo
Legendary
*
Offline Offline

Activity: 1498
Merit: 1000


View Profile
February 23, 2013, 07:33:17 AM
 #4

code doesnt seem to work Sad

Can you give me the error? just tested it and works for me
slimofftb (OP)
Newbie
*
Offline Offline

Activity: 47
Merit: 0



View Profile WWW
February 23, 2013, 05:29:58 PM
 #5

i got it lol there wasnt an issue with the code you posted. i was trying to do something like this.....


Code:
<?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 Offline

Activity: 47
Merit: 0



View Profile WWW
February 24, 2013, 05:36:07 AM
 #6

so if i was to want to send coins to an address i would use code like this?

Code:
<?php


  
require_once 'jsonRPCClient.php';
    
$bitcoin = new jsonRPCClient('http://xxxx:xxxx@10.0.0.2:8332/');
  
print_r($bitcoin->walletpassphrase(password3));

?>

<?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$amount1commentcomment));

?>

I have a feeling i have this all wrong  Huh  Huh
gweedo
Legendary
*
Offline Offline

Activity: 1498
Merit: 1000


View Profile
February 24, 2013, 05:50:04 AM
 #7

no that looks right
slimofftb (OP)
Newbie
*
Offline Offline

Activity: 47
Merit: 0



View Profile WWW
February 24, 2013, 06:04:56 AM
 #8

you sure...

i just tested it and it didnt work....  Huh Angry
gweedo
Legendary
*
Offline Offline

Activity: 1498
Merit: 1000


View Profile
February 24, 2013, 06:10:16 AM
 #9

so if i was to want to send coins to an address i would use code like this?

Code:
<?php


  
require_once 'jsonRPCClient.php';
    
$bitcoin = new jsonRPCClient('http://xxxx:xxxx@10.0.0.2:8332/');
  
print_r($bitcoin->walletpassphrase(password3));

?>

<?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$amount1commentcomment));

?>

I have a feeling i have this all wrong  Huh  Huh

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$amount1commentcomment));

?>

try that it should work now
slimofftb (OP)
Newbie
*
Offline Offline

Activity: 47
Merit: 0



View Profile WWW
February 24, 2013, 06:49:28 AM
 #10

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??


 Huh

Error msg shows that its null when i use a variable.....

Working code

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$amount1commentcomment));

?>

Not working code

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$amount1commentcomment));

?>
gweedo
Legendary
*
Offline Offline

Activity: 1498
Merit: 1000


View Profile
February 24, 2013, 06:55:23 AM
 #11

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 Offline

Activity: 47
Merit: 0



View Profile WWW
February 24, 2013, 07:37:50 AM
 #12

now its working with the variable but it is giving error now... idk why hmmm here is my code....


Code:
<?php
$password 
xxxx;
require_once 
'jsonRPCClient.php';
    
$bitcoin = new jsonRPCClient('http://xxx:xxx@xxx:8332/');
  
print_r($bitcoin->walletpassphrase($password3));
 
?>

<?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$amount1commentcomment));

 
?>


and i get an error
Code:
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  Huh  Wink
gweedo
Legendary
*
Offline Offline

Activity: 1498
Merit: 1000


View Profile
February 24, 2013, 07:52:42 AM
 #13

It can't connect to your bitcoind, or your username and password isn't correct.
slimofftb (OP)
Newbie
*
Offline Offline

Activity: 47
Merit: 0



View Profile WWW
February 24, 2013, 07:55:40 AM
 #14

everything else using bitcoind on the site works fine.... connects like it should.... like listing transactions for accounts and balances....
gweedo
Legendary
*
Offline Offline

Activity: 1498
Merit: 1000


View Profile
February 24, 2013, 07:58:37 AM
 #15

Do this
Code:
$bitcoin->walletpassphrase($password, 60)

then after the function

Code:
$bitcoin->walletlock();
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!