Skip to content

查看文档:https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)#Command_line_.28cURL.29

method:https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list

一、rpcapi

1.查看高度

root@/data/apps/omnicore-0.5.0# curl --user omn --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockcount", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:28832
Enter host password for user 'omn':
{"result":603447,"error":null,"id":"curltest"}

#不输入密码形式
root@usdtback-13:/data/apps/omnicore-0.11.0#curl --user omn:password --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockcount", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:28832
root@/data/apps/omnicore-0.5.0# curl --user omn --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockcount", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:28832
Enter host password for user 'omn':
{"result":603447,"error":null,"id":"curltest"}

#不输入密码形式
root@usdtback-13:/data/apps/omnicore-0.11.0#curl --user omn:password --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockcount", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:28832

2.查看usdt链信息

curl --user omn --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getinfo", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:28832
curl --user omn --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getinfo", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:28832

3.查看当前区块的高度

  • 如果没有同步完块,执行curl 命令很慢
root@data/apps/omnicore-0.5.0# curl --user omn --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockcount", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:28832
Enter host password for user 'omn':
{"result":603447,"error":null,"id":"curltest"}
root@data/apps/omnicore-0.5.0# curl --user omn --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockcount", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:28832
Enter host password for user 'omn':
{"result":603447,"error":null,"id":"curltest"}

4.命令

//bitcoind 命令通用格式

  bitcoind [选项]
  bitcoind [选项] <命令> [参数]  将命令发送到 -server 或 bitcoind
  bitcoind [选项] help           列出命令
  bitcoind [选项] help <命令>    获取该命令的帮助

 //bitcoind常见命令
  -conf=<文件名>     指定配置文件(默认:bitcoin.conf)
  -pid=<文件名>      指定 pid (进程 ID)文件(默认:bitcoind.pid)
  -gen               生成比特币
  -gen=0             不生成比特币
  -min               启动时最小化
  -splash            启动时显示启动屏幕(默认:1)
  -datadir=<目录名>  指定数据目录
  -dbcache=<n style="word-wrap: break-word;">       设置数据库缓存大小,单位为兆字节(MB)(默认:25)</n>
  -dblogsize=<n style="word-wrap: break-word;">     设置数据库磁盘日志大小,单位为兆字节(MB)(默认:100)</n>
  -timeout=<n style="word-wrap: break-word;">       设置连接超时,单位为毫秒</n>
  -proxy=<ip:端口 style="word-wrap: break-word;">   通过 Socks4 代理链接</ip:端口>
  -dns               addnode 允许查询 DNS 并连接
  -port=<端口>       监听 <端口> 上的连接(默认:8333,测试网络 testnet:18333)
  -maxconnections=<n style="word-wrap: break-word;">  最多维护 <n style="word-wrap: break-word;">个节点连接(默认:125)</n></n>
  -addnode=<ip style="word-wrap: break-word;">      添加一个节点以供连接,并尝试保持与该节点的连接</ip>
  -connect=<ip style="word-wrap: break-word;">      仅连接到这里指定的节点</ip>
  -irc               使用 IRC(因特网中继聊天)查找节点(默认:0)
  -listen            接受来自外部的连接(默认:1)
  -dnsseed           使用 DNS 查找节点(默认:1)
  -banscore=<n style="word-wrap: break-word;">      与行为异常节点断开连接的临界值(默认:100)</n>
  -bantime=<n style="word-wrap: break-word;">       重新允许行为异常节点连接所间隔的秒数(默认:86400)</n>
  -maxreceivebuffer=<n style="word-wrap: break-word;">  最大每连接接收缓存,<n style="word-wrap: break-word;">*1000 字节(默认:10000)</n></n>
  -maxsendbuffer=<n style="word-wrap: break-word;">  最大每连接发送缓存,<n style="word-wrap: break-word;">*1000 字节(默认:10000)</n></n>
  -upnp              使用全局即插即用(UPNP)映射监听端口(默认:0)
  -detachdb          分离货币块和地址数据库。会增加客户端关闭时间(默认:0)
  -paytxfee=<amt style="word-wrap: break-word;">    您发送的交易每 KB 字节的手续费</amt>
  -testnet           使用测试网络
  -debug             输出额外的调试信息
  -logtimestamps     调试信息前添加[时间戳](http://8btc.com/article-165-1.html)
  -printtoconsole    发送跟踪/调试信息到控制台而不是 debug.log 文件
  -printtodebugger   发送跟踪/调试信息到调试器
  -rpcuser=<用户名>  JSON-RPC 连接使用的用户名
  -rpcpassword=<密码>  JSON-RPC 连接使用的密码
  -rpcport=<port style="word-wrap: break-word;">    JSON-RPC 连接所监听的 <端口>(默认:8332)</port>
  -rpcallowip=<ip style="word-wrap: break-word;">   允许来自指定 <ip style="word-wrap: break-word;">地址的 JSON-RPC 连接</ip></ip>
  -rpcconnect=<ip style="word-wrap: break-word;">   发送命令到运行在 <ip style="word-wrap: break-word;">地址的节点(默认:127.0.0.1)</ip></ip>
  -blocknotify=<命令> 当最好的货币块改变时执行命令(命令中的 %s 会被替换为货币块哈希值)
  -upgradewallet     将钱包升级到最新的格式
  -keypool=<n style="word-wrap: break-word;">       将密匙池的尺寸设置为 <n style="word-wrap: break-word;">(默认:100)</n></n>
  -rescan            重新扫描货币块链以查找钱包丢失的交易
  -checkblocks=<n style="word-wrap: break-word;">   启动时检查多少货币块(默认:2500,0 表示全部)</n>
  -checklevel=<n style="word-wrap: break-word;">    货币块验证的级别(0-6,默认:1)</n>

**SSL 选项:**
  -rpcssl                                  使用 OpenSSL(https)JSON-RPC 连接
  -rpcsslcertificatechainfile=<文件.cert>  服务器证书文件(默认:server.cert)
  -rpcsslprivatekeyfile=<文件.pem>         服务器私匙文件(默认:server.pem)
  -rpcsslciphers=<密码>                    可接受的密码(默认:TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)
//bitcoind 命令通用格式

  bitcoind [选项]
  bitcoind [选项] <命令> [参数]  将命令发送到 -server 或 bitcoind
  bitcoind [选项] help           列出命令
  bitcoind [选项] help <命令>    获取该命令的帮助

 //bitcoind常见命令
  -conf=<文件名>     指定配置文件(默认:bitcoin.conf)
  -pid=<文件名>      指定 pid (进程 ID)文件(默认:bitcoind.pid)
  -gen               生成比特币
  -gen=0             不生成比特币
  -min               启动时最小化
  -splash            启动时显示启动屏幕(默认:1)
  -datadir=<目录名>  指定数据目录
  -dbcache=<n style="word-wrap: break-word;">       设置数据库缓存大小,单位为兆字节(MB)(默认:25)</n>
  -dblogsize=<n style="word-wrap: break-word;">     设置数据库磁盘日志大小,单位为兆字节(MB)(默认:100)</n>
  -timeout=<n style="word-wrap: break-word;">       设置连接超时,单位为毫秒</n>
  -proxy=<ip:端口 style="word-wrap: break-word;">   通过 Socks4 代理链接</ip:端口>
  -dns               addnode 允许查询 DNS 并连接
  -port=<端口>       监听 <端口> 上的连接(默认:8333,测试网络 testnet:18333)
  -maxconnections=<n style="word-wrap: break-word;">  最多维护 <n style="word-wrap: break-word;">个节点连接(默认:125)</n></n>
  -addnode=<ip style="word-wrap: break-word;">      添加一个节点以供连接,并尝试保持与该节点的连接</ip>
  -connect=<ip style="word-wrap: break-word;">      仅连接到这里指定的节点</ip>
  -irc               使用 IRC(因特网中继聊天)查找节点(默认:0)
  -listen            接受来自外部的连接(默认:1)
  -dnsseed           使用 DNS 查找节点(默认:1)
  -banscore=<n style="word-wrap: break-word;">      与行为异常节点断开连接的临界值(默认:100)</n>
  -bantime=<n style="word-wrap: break-word;">       重新允许行为异常节点连接所间隔的秒数(默认:86400)</n>
  -maxreceivebuffer=<n style="word-wrap: break-word;">  最大每连接接收缓存,<n style="word-wrap: break-word;">*1000 字节(默认:10000)</n></n>
  -maxsendbuffer=<n style="word-wrap: break-word;">  最大每连接发送缓存,<n style="word-wrap: break-word;">*1000 字节(默认:10000)</n></n>
  -upnp              使用全局即插即用(UPNP)映射监听端口(默认:0)
  -detachdb          分离货币块和地址数据库。会增加客户端关闭时间(默认:0)
  -paytxfee=<amt style="word-wrap: break-word;">    您发送的交易每 KB 字节的手续费</amt>
  -testnet           使用测试网络
  -debug             输出额外的调试信息
  -logtimestamps     调试信息前添加[时间戳](http://8btc.com/article-165-1.html)
  -printtoconsole    发送跟踪/调试信息到控制台而不是 debug.log 文件
  -printtodebugger   发送跟踪/调试信息到调试器
  -rpcuser=<用户名>  JSON-RPC 连接使用的用户名
  -rpcpassword=<密码>  JSON-RPC 连接使用的密码
  -rpcport=<port style="word-wrap: break-word;">    JSON-RPC 连接所监听的 <端口>(默认:8332)</port>
  -rpcallowip=<ip style="word-wrap: break-word;">   允许来自指定 <ip style="word-wrap: break-word;">地址的 JSON-RPC 连接</ip></ip>
  -rpcconnect=<ip style="word-wrap: break-word;">   发送命令到运行在 <ip style="word-wrap: break-word;">地址的节点(默认:127.0.0.1)</ip></ip>
  -blocknotify=<命令> 当最好的货币块改变时执行命令(命令中的 %s 会被替换为货币块哈希值)
  -upgradewallet     将钱包升级到最新的格式
  -keypool=<n style="word-wrap: break-word;">       将密匙池的尺寸设置为 <n style="word-wrap: break-word;">(默认:100)</n></n>
  -rescan            重新扫描货币块链以查找钱包丢失的交易
  -checkblocks=<n style="word-wrap: break-word;">   启动时检查多少货币块(默认:2500,0 表示全部)</n>
  -checklevel=<n style="word-wrap: break-word;">    货币块验证的级别(0-6,默认:1)</n>

**SSL 选项:**
  -rpcssl                                  使用 OpenSSL(https)JSON-RPC 连接
  -rpcsslcertificatechainfile=<文件.cert>  服务器证书文件(默认:server.cert)
  -rpcsslprivatekeyfile=<文件.pem>         服务器私匙文件(默认:server.pem)
  -rpcsslciphers=<密码>                    可接受的密码(默认:TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)

#FAQ

参考地址:

https://github.com/OmniLayer/omnicore/releases