Bitcoin Forum
September 27, 2018, 10:25:39 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: PHP Only Partially Reading Bitcoind  (Read 659 times)
Bungeebones
Full Member
***
Offline Offline

Activity: 180
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.
1538087139
Hero Member
*
Offline Offline

Posts: 1538087139

View Profile Personal Message (Offline)

Ignore
1538087139
Reply with quote  #2

1538087139
Report to moderator
1538087139
Hero Member
*
Offline Offline

Posts: 1538087139

View Profile Personal Message (Offline)

Ignore
1538087139
Reply with quote  #2

1538087139
Report to moderator
1538087139
Hero Member
*
Offline Offline

Posts: 1538087139

View Profile Personal Message (Offline)

Ignore
1538087139
Reply with quote  #2

1538087139
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1538087139
Hero Member
*
Offline Offline

Posts: 1538087139

View Profile Personal Message (Offline)

Ignore
1538087139
Reply with quote  #2

1538087139
Report to moderator
1538087139
Hero Member
*
Offline Offline

Posts: 1538087139

View Profile Personal Message (Offline)

Ignore
1538087139
Reply with quote  #2

1538087139
Report to moderator
1538087139
Hero Member
*
Offline Offline

Posts: 1538087139

View Profile Personal Message (Offline)

Ignore
1538087139
Reply with quote  #2

1538087139
Report to moderator
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
Full Member
***
Offline Offline

Activity: 180
Merit: 100



View Profile
April 08, 2014, 03:40:59 PM
 #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: 250


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: 1246
Merit: 1000


Java, PHP, HTML/CSS Programmer for Hire!


View Profile WWW
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.

Want to earn 2500 SATOSHIS per hour? Come Chat and Chill in https://goseemybits.com/lobby
DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1005


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: 334
Merit: 250


PHP Coder, Bitcoin enthusiast, Litecointalk admin


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.

1SoMGuYknDgyYypJPVVKE2teHBN4HDAh3
Administrator/owner of LTC Forum | LTC Block Explorer | Someguy123 Web Development
Bungeebones
Full Member
***
Offline Offline

Activity: 180
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:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!