Tech

ビットコイン bitcoind walletnotifyとは何か?

  • このエントリーをはてなブックマークに追加

以下の時に通知してくれる

  • BTCの受け取り
  • BTCの送信
  • 最初のconfirmationを得た時

Quote: wallet – How do I use walletnotify? – Bitcoin Stack Exchange

PHPのwalletnotify用スクリプト

スクリプトのサンプル

walletnotify=/home/btcdev/walletnotify.sh %s
blocknotify=/home/btcdev/blocknotify.sh %s
#!/bin/bash
F=/home/btcdev/wallet_transaction_log
D=`date +"%Y%m%d%H%M%S"`
echo ${D} - ${1} >> ${F}
#!/bin/sh
curl -d "txid=$1" http://127.0.0.1/some/route
<!--?php if(2==$argc){ require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://username:password@127.0.0.1:8332/'); $walletinfo = $bitcoin-&gt;getinfo();&lt;br ?--> $trxinfo = $bitcoin-&gt;gettransaction($argv[1]);

// Append data to the file
$new = "\n\nTransaction hash: ".$argv[1]."\nGetinfo balance: ".$walletinfo["balance"]
."\n Gettransaction amount: ".$trxinfo["amount"]
."\n Gettransaction confirmations: ".$trxinfo["confirmations"]
."\n Gettransaction blockhash: ".$trxinfo["blockhash"]
."\n Gettransaction blockindex: ".$trxinfo["blockindex"]
."\n Gettransaction blocktime: ".$trxinfo["blocktime"]
."\n Gettransaction txid: ".$trxinfo["txid"]
."\n Gettransaction time: ".$trxinfo["time"]
."\n Gettransaction timereceived: ".$trxinfo["timereceived"]
."\n Gettransaction account: ".$trxinfo["details"][0]["account"]
."\n Gettransaction address: ".$trxinfo["details"][0]["address"]
."\n Gettransaction category: ".$trxinfo["details"][0]["category"]
."\n Gettransaction amount: ".$trxinfo["details"][0]["amount"]
//."\n Gettransaction fee: ".$trxinfo["details"][0]["fee"] // According to https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list, fee is returned, but it doesn't seem that way here
;

$fp=fopen("/tmp/notify_wallet.txt","a");
fwrite($fp,$new);
}
?&gt;
  • このエントリーをはてなブックマークに追加