Bitcoin Forum
May 22, 2024, 03:35:48 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: PHP Only Partially Reading Bitcoind  (Read 748 times)
Bungeebones (OP)
Full Member
***
Offline Offline

Activity: 178
Merit: 100



View Profile
April 08, 2014, 01:12:33 AM
 #1

I've got two different PHP scripts (listed below) accessing Bitcoind via jsonRPC and neither one is working properly. And the command line reports are acting weird too.

I have both Bitcoind and Bitcoin-QT installed. I made a spend to one of its wallets and at Blockchain it reported 37 confirmations. I got the transaction id from the cl using bitcoind listtransactions but it reported NO confirmations there. Then, when I repeated the command a couple minutes later from the cl there was no longer any mention of the transaction.

The two php scripts never have shown the transaction at all.

One simple script -
 
Code:
require_once 'jsonRPCClient.php';
 
  $bitcoin = new jsonRPCClient('http://user:password@127.0.0.1:8332/');
 
  echo "<pre>\n";
  print_r($bitcoin->getinfo()); echo "\n";
  echo "Received: ".$bitcoin->getreceivedbylabel("Your Address")."\n";
  echo "</pre>";

While the second is a more elaborate class from http://www.phpclasses.org/package/6739-PHP-Manage-Bitcoin-virtual-currency-accounts.html. I've tried from both the test_bitcoin.php page and the test_bitcoin_rpc.php page. Apart from not reporting the proper balance everything appears ok in them.

So, in summary, the php pages don't report the proper balance (the script doesn't report confirmations) and the command line reports the proper balance but not the correct confirmations and then disappears altogether.  

Any help will be greatly appreciated.
gwlloyd
Newbie
*
Offline Offline

Activity: 50
Merit: 0


View Profile
April 08, 2014, 02:55:32 PM
 #2

Is the blockchain on bitcoind up-to-date? i.e. on getinfo does it show the same number of blocks as blockchain.info .. a confirm is a block so if it hasn't caught up to all blocks then it wont show the confirms.
Bungeebones (OP)
Full Member
***
Offline Offline

Activity: 178
Merit: 100



View Profile
April 08, 2014, 03:40:59 PM
Last edit: April 08, 2014, 05:44:42 PM by Bungeebones
 #3

Hi,

Thanks for the reply and the help.

I haven't quite figured out what is all available from the command line. I can't tell when it has completed updating after I start bitcoind from the command line so what I do is I'll start the Bitcoin client from the GUI and let it update the blockchain. So I would guess that the blockchain is up to date because I updated for sure with the GUI client, then I shut it down and started bitcoind from the cl. Also I noticed that when I open the Bitcoin QT GUI it reports it is "rescanning". That seems odd to me. Is that an indication something is wrong and the two aren't compatible?

Also, it did see the transaction at the cl once, then the report disappeared. I also tried every command to find it recorded as a balance and it only reported a zero balance. It is only a small token test amount so that loss is not important. I'm trying to figure it all out and what I am doing wrong.

Here is what I have found out so far ...

At the CL I found I have two wallets in the account. The account's name is "TEST" and I didn't create it that I know of. I would assume it is somewhere created in that script or does bitcoind create TEST at install?

Of those two wallets I know I created one of them with the Gui client. That is the one I sent the transaction to and the GUI is reporting the correct balance.

So either I am misunderstanding the relationship between bitcoind and bitcoin qt (I thought they use the same accounts, wallets etc) or something is wrong with the scripts. Another possibility is that I'm entering the wrong commands on the CL but I've tried everything, I believe, and am using commands from what I think are reliable and up to date sources.


EDIT: I just had severe problem loading QT. It crashed 3 times without being able to load the wallet. I renamed the wallet.bak file and it is now loaded and updating. Am I messing it up going back and forth between QT and the Bitcoind CL?



fbueller
Sr. Member
****
Offline Offline

Activity: 412
Merit: 275


View Profile
April 09, 2014, 01:49:39 AM
 #4

It was probably still reindexing when you ran this. You can check the progress of the reindex by doing bitcoind getinfo and checking the current height.

Bitwasp Developer.
gweedo
Legendary
*
Offline Offline

Activity: 1498
Merit: 1000


View Profile
April 09, 2014, 01:52:57 AM
 #5

Code:
tail -f ~/.bitcoin/debug.log

That is going to be your friend in SSH. It will tell you what block and the progress of completion.
DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
April 09, 2014, 02:06:50 AM
 #6

As a general rule before you start messing around with custom applications just try executing the command from the command line
bitcoind <command> <arguments>
if you get nothing there then it isn't a PHP issue it means the bitcoind is broken or behind.

bitcoind getinfo

should give you some basic info like connections to the network and blockheight.
someguy123
Sr. Member
****
Offline Offline

Activity: 336
Merit: 254


CEO of Privex Inc. (www.privex.io)


View Profile WWW
April 09, 2014, 11:03:05 PM
 #7

As a general rule before you start messing around with custom applications just try executing the command from the command line
bitcoind <command> <arguments>
if you get nothing there then it isn't a PHP issue it means the bitcoind is broken or behind.

bitcoind getinfo

should give you some basic info like connections to the network and blockheight.
This ^^

Bitcoin and other coin daemons are VERY SLOW and can return odd results when they're behind on blocks. If you notice long load-times, that's one of the reasons most likely.

Bungeebones (OP)
Full Member
***
Offline Offline

Activity: 178
Merit: 100



View Profile
April 09, 2014, 11:58:23 PM
 #8

Thanks everyone. It was all helpful and am getting to understand it a little better now. Yes, the issue was that the blockchain hadn't finished loading yet. The next morning the transaction and balance were correct.

Gosh the documentation is sporadic. Maybe I'll attempt writing a how-to when I'm done (I've gotten enough practice :-)
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!