読者です 読者をやめる 読者になる 読者になる

仮想通貨サービス BitCapitalZ の日記

仮想通貨関連のブログです Ripple, Ethereum 仮想通貨2.0に注目しています

bitcoin API (JSON-RPC) を account の最近の取引履歴を確認する (listtransactions)

今回は listtransactions の使い方です。


listtransactions [account] [count=10] [from=0] Returns up to [count] most recent transactions skipping the first [from] transactions for account [account]. If [account]

このような API となっていて account で account を指定し、 count で件数、 from で開始位置を指定できるようです。

例によって、monacoin_client を用いて説明します。

require 'monacoin_client' lt = MonacoinRPC.new('http://username:password@127.0.0.1:9332')
p lt. listtransactions("1")


これを実行すると以下のようなJSON配列を得ることができます。category は move, send, receive があるようです。

[
    {
        "account" : "1",
        "address" : "MVqKpSja29an169P3z6TphFk9sJJbhxYbF",
        "category" : "receive",
        "amount" : 5.00000000,
        "confirmations" : 4787,
        "blockhash" : "4b92e929722b80578dffdbd28c21334427d32d48fceb85cd8d9b23edc3dbb941",
        "blockindex" : 4,
        "blocktime" : 1405011139,
        "txid" : "bb4c1677b815a72c1cd536559b41750d0e09bd9240f576cbc184e29047f8d48d",
        "normtxid" : "e493268cb7b899fb6968f6de1ce03a8a7a19f67f05a1d7aaabf5142550f70383",
        "time" : 1405011072,
        "timereceived" : 1405011072
    },
    {
        "account" : "1",
        "address" : "MUzvktsVXY81eHkpKSH2ACqiUANZqt9dD3",
        "category" : "send",
        "amount" : -0.10000000,
        "fee" : -0.00100000,
        "confirmations" : 2190,
        "blockhash" : "54232ac1f8069551bac9a529a86e1001ec00a8150853d67a27ea1e12159fee9a",
        "blockindex" : 4,
        "blocktime" : 1405259476,
        "txid" : "3a220c9bb94839f9f937cd0a48067aacde603294c23b6712ff07478d204c03e0",
        "normtxid" : "f0f2d5d95bc3915490f29922847360b4e776818339f30b6f8a9738d02b66d168",
        "time" : 1405259420,
        "timereceived" : 1405259420
    },
    {
        "account" : "1",
        "address" : "MVGs5Dza2eoauqywfR5ZnKSibMTZJqUfN2",
        "category" : "send",
        "amount" : -1.00000000,
        "fee" : -0.00100000,
        "confirmations" : 2186,
        "blockhash" : "89a6eb33d92477decabe12460947a7e49d00027d2733127daaec56fbd0e50467",
        "blockindex" : 4,
        "blocktime" : 1405259734,
        "txid" : "e7698f15256b40e3990a4a7242c366396a3765710cedc0207fad3be93ca1d826",
        "normtxid" : "93c7f6e27a0cda1cc5deb0e6b84ab8b8e508f4c8cfd87168c8ad2f9378a13825",
        "time" : 1405259670,
        "timereceived" : 1405259670
    },
    {
        "account" : "1",
        "address" : "MPHHg8heBMo5AnBKpScEPEi6HqqGg5S2NH",
        "category" : "send",
        "amount" : -0.20000000,
        "fee" : -0.00100000,
        "confirmations" : 2148,
        "blockhash" : "d9db36cc32c39c0dceb74ca866cc6c3e72914d3aa69daeebf9e3cdafaf1baf4c",
        "blockindex" : 13,
        "blocktime" : 1405263460,
        "txid" : "8e84cedc4d945d1501d857cd2f0921aa5a5dbabfc08804e1acbd5bb7bbdf4237",
        "normtxid" : "8f93a7be310bf36c57d300378992b009ceb114ca38f862d7a4e852472a5126c6",
        "time" : 1405263207,
        "timereceived" : 1405263207
    },
    {
        "account" : "1",
        "category" : "move",
        "time" : 1405306680,
        "amount" : -0.00100000,
        "otheraccount" : "ja1",
        "comment" : ""
    },
    {
        "account" : "1",
        "address" : "MUzj3qsM8QLcaN65hCrNkwtZ2DbW3AQXjo",
        "category" : "send",
        "amount" : -1.50000000,
        "fee" : 0.00000000,
        "confirmations" : 517,
        "blockhash" : "164254da5c065ea41570a87035f258f616ebb4a36be08c6149f747b004f569a3",
        "blockindex" : 3,
        "blocktime" : 1405418281,
        "txid" : "d34805700bb65c4bb4b7983f31fdffc0fe61ff2db4de3b5a027d9850a152f222",
        "normtxid" : "53625edd486e1a274daa7cd9e3a9d37f44c879938e6e407adbe1b05acabcb353",
        "time" : 1405418182,
        "timereceived" : 1405418182
    }
]




仮想通貨技術研究会 へのご参加もお待ちしております。