Bitcoin JSON RPC API - blockchain.info

来源:互联网 发布:淘宝卖家账号已被冻结 编辑:程序博客网 时间:2024/05/21 09:54
经查,P2Pool使用的原始的Bitcoind RPC的方式调用,Eloipool已经改为使用新的JSON PRC方式(jgarzik写的有相应的python包)。

JSON RPC API Bitcoind compatible RPC api


My Wallet users can interact with their wallet using our JSON RPC api. It is intended to be fully compatible with the original Bitcoind RPC protocol however some method calls are not supported.
My Wallet可以使用JSON RPC api和钱包交互。它的目的是要与原来的Bitcoind RPC协议完全兼容,但不支持某些方法调用。

  • No Blockchain Download - Save on bandwidth and disk space.
  • No Need to run Bitcoind - Some VPS and shared hosting plans do not allow you to run custom processes
  • Use Existing software - Most existing software that uses the bitcoind rpc calls will work transparently using blockhain.info
  • Payment notifications
  • Live synchronization with the web interface
     没有Blockchain下载 - 节省带宽和磁盘空间
     不需要运行Bitcoind - 一些VPS和共享主机计划不允许您运行自定义进程
     利用现有的软件 - 调用bitcoind RPC的现有的大多数软件将工作透明使用blockhain.info
     付款通知
     与Web接口实时同步


Original Documentation available at https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list
原Bitcoind RPC接口文档参见...

Authentication


-rpcuser Should be set to your wallet identifier. This is a 36 character random string which can be found on your wallet login page.
-rpcpassword Should be set to your main wallet password. If double encryption is enabled your second password will need to be set using walletpassphrase
-rpcport
 Should be set to 443 for https:// (when the -rpcssl is provided) or 80 for plain text http://
-rpcssl Set to use a secure connection (Recommended)
-rpcuser应设置为你的钱包标识符。这是一个36字符的随机字符串,在你的钱包的登录页面可以看到。
-rpcpassword应设置为您的主钱包密码。如果启用了双重加密你的第二个密码将需要使用walletpassphrase设置
-rpcport https方式请设置为443(同时需要设置-rpcssl),http方式设置为80
-rpcssl设置为使用安全连接(推荐)

Security


This api is currently incompatible with two factor authentication and it must therefore be disabled. We HIGHLY recommend you enable double encryption which can be found on the My Wallet account details page.
这个API和目前authentication认证不兼容,因此它必须被禁用。我们强烈建议您启用双重加密,可以在My Wallet帐户详情页上找到。


If you will be accessing this API from a server with a static ip address is recommended you enable the IP Lock found in the Security Section of your My Wallet account.
如果你从一个静态IP地址的服务器调用这个API,建议您启用IP锁定(在My Wallet的Security Section)。


Unlike when using the javascript wallet transaction signing is conducted server side which means your private keys are shared with the server. However many operations such as fetching a balance and viewing transactions are possible without needing to decrypt the private keys. The is possible through the use of double encryption only when the second password is provided does the server have ability to access the funds in a wallet. For merchants who need to only receive transactions it maybe possible to never provide a second password.
这和使用javascript的钱包时交易签名不大一样,javascript版的私钥会传到server,等于是和服务器共享的。
然而,许多操作,如查看账户余额和查看交易是不需要解密私钥的。如果server需要第二密码才可以访问钱包的资金,可以使用双重加密。
对商家而言只需要接收tnx,所以永远也不需要提供第二密码。


If transactions can be delayed and are able to be manually reviewed we highly recommend you do this. Have your server construct a list of transactions which need to be made and every so often an admin can login and review the list - if the transactions look ok they can manually supply the second password with a short timeout (don't store the second password on your server if possible). When the admin provides a second password you can start a job to call sendmany.
如果交易可以被延迟,并能进行人工审查,我们强烈建议您这样做。如果服务器创建的有tnx的列表,管理员可以经常登陆查看列表。如果tnx看起来OK可以手工输入第二密码(如果可能不要把第二密码保存在服务器上)。当管理员提供了第二个密码,您就可以启动一个job调用sendmany

Notes

  • An account is analogous for a label
  • A label and bitcoin address are interchangeable i.e. any command which you can supply a bitcoin address you can substitute a label and visa versa
  • Any parameters with default value e.g. (minConfirmations = 1) are optional
  • 账户类似个label。
    label和比特币地址是可以互换的,任何提供BTC地址的命令都可以被替换为一个label,反之亦然。
    参数的默认值可选。
HTTP callbacks can be enabled in the notifications section of [Account Settings] in the web interface.

Host


The rpc host is rpc.blockchain.info. Plain http and SSL https are supported.
rpc主机地址是rpc.blockchain.info 普通http和https方式都可以

Connecting using Bitcoind


Bitcoind can be used as an RPC client for testing and debugging.
Bitcoind 可以作为RPC客户端使用,可用来测试或调试.
调用getinfo命令如下:

$ ./bitcoind -rpcconnect=rpc.blockchain.info -rpcport=443 -rpcssl -rpcuser=YourWalletIdentifier -rpcpassword=YourPassword getinfo

Wrapper Libraries

已封装好的lib
  • Python
  • Ruby
  • Ruby
  • Node js
  • .Net
  • For more information consult the bitcoin wiki

Shopping Cart Interfaces

购物车接口
  • Wordpress
  • osCommerce
  • Ubercart
  • WHMCS
  • ZenCart
  • Magento
  • VirtueMart

Bitcoind Commands Not Available

Bitcoind命令不可用

  • getwork setgenerate getmininginfo getmemorypool Not intended for bitcoin mining
  • help Read this instead
  • keypoolrefill blockchain.info wallets have no keypool
  • stop
  • walletpassphrasechange Disabled for security reasons
  • dumpprivkey Disabled for security reasons
  • encryptwallet All blockchain.info wallets are encrypted by default. Password change is disabled for security reasons

Methods

  • Method: 方法
  • Parameters: 入参
  • Description: 描述信息
  • Returns: JSONObject
  • Method: getinfo
  • Parameters: None
  • Description: Returns an object containing various state info.
  • Returns: JSONObject
  • 返回一个包含各种状态信息的对象。
{    "balance" : 43.50100000,    "errors" : "",    "paytxfee" : 0.005,    "proxy" : "",    "connected" : 0,    "testnet" : false,    "difficulty" : 1733207.51384839,    "blocks" : 179602}
  • Method: backupwallet
  • Parameters: None
  • Description: Uploads the wallet to Google Drive, Dropbox or Email. Must login through the web interface first.
  • Returns: boolean
  • 上传wallet到Google Drive, Dropbox or Email。前提是先通过web接口登陆。
  • Method: walletlock
  • Parameters: None
  • Description: Remove second password from memory.
  • Returns: JSONObject
  • 从内存中删除第二密码。
  • Method: settxfee
  • Parameters: (double amount)
  • Description: Sets the default transaction fee for 24 hours (must be called every 24 hours).
  • Returns: boolean
  • 设置24小时内的默认的tnx费率(必须每24小调用一次)
  • Method: walletpassphrase
  • Parameters: (String password, int timeout)
  • Description: Stores the wallet second password in cache for timeout in seconds. Only requred for double encrypted wallets.
  • Returns: boolean
  • 存储第二密码到内存。只针对双重加密的钱包。
  • Method: setaccount
  • Parameters: (String bitcoinAddress, String label)
  • Description: Set the label for a bitcoin address.
  • Returns: boolean
  • 设置address的label
  • Method: getaccount
  • Parameters: (String bitcoinAddress)
  • Description: Get the label for a bitcoin address.
  • Returns: String
  • 获取address的label
  • Method: getaccountaddress
  • Parameters: (String label)
  • Description: Get the first bitcoin address matching label.
  • Returns: String
  • 获取address匹配上的第一个label
  • Method: getaddressesbyaccount
  • Parameters: (String label)
  • Description: Get the an array of bitcoin addresses matching label.
  • Returns: JSONArray
  • 获取匹配label的address数组
  • Method: getbalance
  • Parameters: (String account = null, int minimumConfirmations = 1)
  • Description: If [account] is not specified, returns the server's total available balance. If [account] is specified, returns the balance in the account.
  • Returns: JSONArray
  • 如果没有提供account,返回服务器总的余额。否则如果指定了account,返回account的余额
0.001
  • Method: getblock
  • Parameters: (String blockHash)
  • Description: Returns information about the given block hash.
  • Returns: JSONObject
  • 根据block的hash获取block信息
{    "tx" : [        "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"    ],    "time" : 1231006505,    "height" : 0,    "nonce" : 2083236893,    "hash" : "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",    "bits" : 486604799,    "difficulty" : 1,    "merkleroot" : "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",    "version" : 1,    "size" : 285}
  • Method: getblockcount
  • Parameters: None
  • Description: Returns the number of blocks in the longest block chain.
  • Returns: int
  • 获取blockchain上的block数量。
179729
  • Method: getblockhash
  • Alias: getblocknumber
  • Parameters: (blockHeight)
  • Description: Returns hash of block in best-block-chain at height.
  • Returns: String
  • 根据height获取best-block-chain上的block的hash
000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
  • Method: getconnectioncount
  • Parameters: None
  • Description: Returns the number of connections to other nodes.
  • Returns: int
    返回节点连接数
2000
  • Method: getdifficulty
  • Parameters: None
  • Description: Returns the proof-of-work difficulty as a multiple of the minimum difficulty.
  • Returns: double
  • 返回POW的难度系数
  • Method: getgenerate
  • Parameters: None
  • Description: Returns true or false whether bitcoind is currently generating hashes.
  • Returns: boolean (false)
  • 返回bitcoind是否在生成hash
  • Method: gethashespersec
  • Parameters: None
  • Description: Returns a recent hashes per second performance measurement while generating.
  • Returns: int (0)
  • Method: getinfo
  • Parameters: None
  • Description: Returns an object containing various state info.
  • Returns: JSONObject
  • 返回一个包含各种状态信息的对象。
{    "balance" : 43.29300000,    "errors" : "",    "paytxfee" : 0.005,    "proxy" : "",    "connected" : 3943,    "testnet" : false,    "difficulty" : 1733207.51384839,    "blocks" : 179729}
  • Method: gettransaction
  • Parameters: (String hash)
  • Description: Returns an object about the given transaction hash.
  • Returns: JSONObject
  • 根据hash返回tnx
{    "amount" : 0,    "fee" : 0,    "blockindex" : 179123,    "details" : [        {            "fee" : 0,            "amount" : 0.01000000,            "blockindex" : 179123,            "category" : "receive",            "confirmations" : 0,            "address" : "1APSgU92VV77GB2YMNNMMYz7Sock5gMgV1",            "txid" : "5031738bc1f797e5e0f8b782989111d75106496c5dedea50d96e2ed1dc88190d",            "block" : 1327599863,            "blockhash" : "000000000000079bae4b877ad3810f03db249a6f239c2b69c18d44c141c470ee"        },        {            "fee" : 0,            "amount" : 0.00100000,            "blockindex" : 179123,            "category" : "receive",            "confirmations" : 0,            "address" : "15CDCKBLsvX3nZ3krMYNse6FkRcuMD1rmU",            "txid" : "5031738bc1f797e5e0f8b782989111d75106496c5dedea50d96e2ed1dc88190d",            "block" : 1327599863,            "blockhash" : "000000000000079bae4b877ad3810f03db249a6f239c2b69c18d44c141c470ee"        }    ],    "confirmations" : 15767,    "txid" : "5031738bc1f797e5e0f8b782989111d75106496c5dedea50d96e2ed1dc88190d",    "block" : 1327599863,    "blockhash" : "000000000000079bae4b877ad3810f03db249a6f239c2b69c18d44c141c470ee"}
  • Method: listaccounts
  • Parameters: (int confirmations = 1)
  • Description: Returns Object that has account names as keys, account balances as values.
  • Returns: JSONArray
  • 返回账户信息对象,键为账户名,值为余额
{    "1JArS6jzE3AJ9sZ3aFij1BmTcpFGgN86hA" : 0,    "1NW6nextdRXhKZWxLB4KaU6e9WjBQ1LVrW" : 0.2}
  • Method: listreceivedbyaccount
  • Parameters: (int minConfirmations = 1, boolean includeempty = false)
  • Description: Returns An array of accounts with the the total received and more info.
  • Returns: JSONArray
  • 返回接收账户的接收金额等信息。
[    {        "amount" : 2558.40200000,        "confirmations" : 55,        "account" : "Savings",        "label" : "Savings"    }]
  • Method: listreceivedbyaddress
  • Parameters: (int minConfirmations = 1, boolean includeempty = false)
  • Description: Returns An array of addresses with the the total received and more info.
  • Returns: JSONArray
  • 根据address返回接收账户的接收金额等信息。
[    {        "amount" : 255840224456,        "confirmations" : 55,        "address" : "145YPBBWRj4aquewvx59SAWNrSZFT5rvxr",        "account" : "Savings"    }]
  • Method: listsinceblock
  • Parameters: (String blockHash, int minConfirmations = 1)
  • Description: Get all transactions in blocks since block [blockhash] (not inclusive), or all transactions if omitted. Max 25 at a time.
  • Returns: JSONObject
  • 根据block的hash返回block中的交易信息,如果
    [blockhash]
    省略的话返回所有交易。每次最多25个。
{    "lastblock" : "00000000000009133d70c6282279bfc5fadfea07e27543445a199fe6ef84b51b",    "transactions" : [        {            "fee" : 0.01000000,            "amount" : 1,            "blockindex" : 171984,            "category" : "receive",            "confirmations" : 0,            "address" : "1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq",            "txid" : "90992bc8ebff9774cfc91738863602010dab9ab2f5b0841cc4922786a2029725",            "block" : 1323486876,            "blockhash" : "00000000000003438e8c67500f34dd32bb1bf0d251a5c230c407641961c85b41",            "account" : "My Wallet"        }        ]}
  • Method: listtransactions
  • Parameters: (String account = null, int count = 25, int offset = 0)
  • Description: Returns up to [count] most recent transactions skipping the first [from] transactions for account [account]. If [account] not provided will return recent transaction from all accounts.
  • Returns: JSONArray
  • 根据account返回从第一个交易开始的count数量的交易信息,如果不指定 [account],返回所有账户的最近交易信息。???对不对
{    "lastblock" : "00000000000009133d70c6282279bfc5fadfea07e27543445a199fe6ef84b51b",    "transactions" : [        {            "fee" : 0.01000000,            "amount" : 1,            "blockindex" : 171984,            "category" : "receive",            "confirmations" : 0,            "address" : "1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq",            "txid" : "90992bc8ebff9774cfc91738863602010dab9ab2f5b0841cc4922786a2029725",            "block" : 1323486876,            "blockhash" : "00000000000003438e8c67500f34dd32bb1bf0d251a5c230c407641961c85b41",            "account" : "My Wallet"        }        ]}
  • Method: importprivkey
  • Parameters: (String privateKey)
  • Description: Import a private key into your bitcoin wallet. Private key must be in wallet import format (Sipa) beginning with a '5'.
  • Returns: boolean
  • Second Password Required
  • 导入私钥到钱包。私钥必须是Sipa格式(以 '5'开头)
  • Method: move
  • Parameters: (String fromAccount, String toAccount, long amount)
  • Description: Move funds from one account in your wallet to another.
  • Returns: String
  • Second Password Required
  • 从钱包里的某个账户上转移资金到另一个钱包账户。
608e3bf3113aa195b21dd52e5389693117e263458ef10b151ab73c91b815470a
  • Method: sendfrom
  • Parameters: (String fromAccount, String bitcoinAddress, long amount)
  • Description: amount is a real and is rounded to 8 decimal places. Will send the given amount to the given address, ensuring the account has a valid balance using [minconf] confirmations. Returns the transaction ID if successful (not in JSON object).
  • Returns: String
  • Second Password Required
  • amount是个精度为8的数字。将会转出amount数量的钱到指定address,此操作要确保账户上有足够的余额,通过 [minconf] 确认。如果转出成功返回交易ID。???是这样吧?
608e3bf3113aa195b21dd52e5389693117e263458ef10b151ab73c91b815470a
  • Method: sendmany
  • Parameters: (String fromAccount, JSONObject addressAmountPairs)
  • Address Amount Pairs: {address:amount,...} e.g. {"1yeTWjh876opYp6R5VRj8rzkLFPE4dP3Uw":10,"1yeTWjh876opYp6R5VRj8rzkLFPE4dP3Uw":15}
  • Description: amounts are double-precision floating point numbers.
  • Returns: String
  • Second Password Required
  • 向多人付款:金额为双精度浮点数。
608e3bf3113aa195b21dd52e5389693117e263458ef10b151ab73c91b815470a
  • Method: sendtoaddress
  • Parameters: (String bitcoinAddress, long amount)
  • Description: amount is a real and is rounded to 8 decimal places. Returns the transaction hash if successful. .
  • Returns: String
  • Second Password Required
  • 根据address转出,amount四舍五入到8位小数。如果成功返回交易的hash。
608e3bf3113aa195b21dd52e5389693117e263458ef10b151ab73c91b815470a
  • Method: validateaddress
  • Parameters: (String bitcoinAddress)
  • Description: Return information about bitcoinaddress.
  • Returns: JSONObject
  • Second Password Required
  • 校验address,根据address返回账户信息。???
{    "address" : "1BZZnJG6q95aJqPZweSCGnno2rxcXyfaLo",    "iscompressed" : false,    "account" : "Test",    "pubkey" : "04572e60ecaa1dd7cb435dc8e04bb6c1729d69bb3916e3f4849b3ffcb02f01f5d94a03c266507245ff30c04dee99ceb711050003b6282ea72634d8f610878885e6",    "ismine" : true,    "isvalid" : true}
  • Method: getnewaddress
  • Parameters: (String label = null)
  • Description: Returns a new bitcoin address for receiving payments. If [account] is specified (recommended), it is added to the address book so payments received with the address will be credited to [account].
  • Returns: String
  • Second Password Required
  • 设置新的收款地址,如果指定了account,将会把新地址加到地址簿中以便在该地址有收款时记录下来。
1BZZnJG6q95aJqPZweSCGnno2rxcXyfaLo
  • Method: signmessage
  • Parameters: (String bitcoinaddress, String message)
  • Description: Returns a Base64 encoded signature used to verify the provided message was signed by the owner of bitcoinaddress
  • Returns: String
  • Second Password Required
  • 返回一个Base64编码的签名,用于验证提供的消息是否是由bitcoinaddress属主签署。????是这意思?
GyLL9ps957O7gLGEWH4Q42WVDADXeHWeLhAQQIsI5m0pjGVDuEJLnK5RgI/7TwPU4UCzwo2BDVXyadBAMW0JKgc=
  • Method: verifymessage
  • Parameters: (String bitcoinaddress, String signature, String message)
  • Description: Verifies the signature and message matches the bitcoin address provided (See signmessage)
  • Returns: Boolean
  • 验证消息和签名是否匹配
true

0 0
原创粉丝点击