0

I'm trying to get the balance of a specific address in my PHP session, I currently have this:

<?php
  require 'header.php';
  include 'Includes/Bitcoin/easybitcoin.php';
  $bitcoin = new Bitcoin('user', 'password', 'localhost', '8332');
  $wallet = $_SESSION['UserWallet'];
  $balance = $bitcoin->getbalance($wallet);
?>
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
</head>
<body style="font-family: sans-serif;">
  <b>Wallet address: <?php print_r($wallet); ?></b>
  <br />
  <b>Account balance: ฿<?php print_r($balance); ?></b>
</body>
</html>

Where the $_SESSION['UserWallet'] contains the bitcoin address, when I run this it returns an error, how does it work?

3
  • That is not how the getbalance RPC works. Commented Apr 7, 2019 at 23:02
  • Perhaps read the documentation before trying to make a product that handles other people's money.
    – Claris
    Commented Apr 8, 2019 at 1:09
  • @PieterWuille What parameters are used? Can they be variables in any way?
    – frogman578
    Commented Apr 8, 2019 at 7:28

1 Answer 1

0

To get the balance of something you need an account, which is best created dynamically with PHP. You would use the getnewaddress("echo uniqid()"); in PHP as an example of generating a new account for every user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.