I'm trying to add bitcoin payment for my ecommerce website. I have installed bitcoind on the server and i've set the notify wallet parameter in bitcoin.conf. the issue i have now is how to know that the client have sent the exact needed amount for products they bought.

Actually, the client can send a lower amount to my wallet and notify wallet will be generated. Please help to handle this issue.

2 Answers 2


If you insist on using bitcoind directly, you could always use the gettransaction rpc call to get transaction info on that transaction.

Hopefully you're using xpubs or at least a list of pre-imported addresses, and not using that bitcoind to manage your wallet/generate new addresses itself though. You shouldn't keep your private key on the live bitcoind node connected to your public ecommerce site.

  • thank you for your answer! actually i'm working on a project for which i have to add bitcoin payment using rpc user and password! i though i can generate a new address using bitcoind node for each payment and i didn't know that it is dangerous... Dec 4, 2020 at 17:07
  • 1
    Yes, it's risky to have your private keys on a live production server because all someone needs to do is break into your ecommerce site and use RPC calls to empty out your wallet. Generally we like to use xpub keys to generate addresses and that way we can keep the private keys somewhere else.
    – ieatpizza
    Dec 4, 2020 at 17:14

Walletnotify needs to be defined in your bitcoin.conf file, example:

walletnotify = /usr/bin/php some/path/newdeposit.php?tx=%s    

In the above example every time there is a new transaction on your wallet, the newdeposit.php script will run and the transaction ID will be stored in a GET named "tx".

Then we can pull the transaction id from the tx GET and put it through a gettransaction command.

$tx = $_GET['tx'];
$getTrans = $bitcoin->gettransaction($tx);

From there we need to look through the API response, see if it has at least once confirmation, and how much was sent. We'll do this by running a loop, checking for the "receive" category. If there is a match you can do whatever you want in your database.

$confirmations = $getTrans["confirmations"];

if($confirmations < 1){

} else {
 $countDetails = count($getTrans['details']);
   $getAddress = $getTrans['details'][$i]['address'];
   $getReceive = $getTrans['details'][$i]['category'];
   if($getAddress == $myAddress && $getReceive == "receive"){
    $amount = $getTrans['details'][$i]['amount'];
    $amount = $amount * 100000000;
    //do something with $amount


Walletnotify only fires twice. Once when the transaction first appears on the network, and a second time after it has been included in a block(one confirmation).

Don't forget to multiply the amount by 100 million to turn it into satoshis so you're not working with floats.

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.