sudo apt-get install -y nodejs
sudo ln -s /usr/bin/nodejs /usr/sbin/node
sudo apt-get install npm
npm install -g n
n lts
npm install -g pm2
sudo apt-get install sqlite3
更改node需要调用的接口地址路径和端口参数为本地java接口的路径和端口
play/rpc_service.js中的function notifyserver(unit, data)
./setinfo.sh devicename passphrase
node start.js
pm2 start start.js
运行后控制台会打印一个地址 记下此地址(云牛币将转到此地址,后期转币使用)
Witness SingleAddress -------------->
接口协议:rpc
以post方式发送json串
{"jsonrpc":"2.0","id":1,"method":"methodname","params":[]}
返回格式
{
"jsonrpc": "2.0",
"result": true,
"id": 1
}
//错误
{
"jsonrpc": "2.0",
"error": {
"code": -32700,
"message": "Invalid Request"
},
"id": null
}
参数address为商品地址
{"jsonrpc":"2.0","id":1,"method":"listtransactions","params":{"address": "VXA5Q27TPFZAO4DGKRR3W2D62YIM7GPD"}}
返回:
{
"jsonrpc": "2.0",
"result": [{
"action": "received",
"amount": 100000,//金额
"my_address": "VXA5Q27TPFZAO4DGKRR3W2D62YIM7GPD",//商品地址
"arrPayerAddresses": [
null
],
"confirmations": 1,
"unit": "DKEqxD6E93TEm+6P088U+0g2eCh7PRp/xLC55YfVohc=",
"fee": 954,//手续费
"time": "1536807729",
"level": null,
"mci": 977739,
"asset": "jH12XQGk0JJxYAO7j/lK0jrRjKVuEFc9mfTUc14mx1g="//资产
}],
"id": 1
}
{"jsonrpc":"2.0","id":1,"method":"getnewaddress","params":[]}
返回:
{
"jsonrpc": "2.0",
"result": "",
"id": 0
}
#####生成地址后等待付款
第一个参数为商品地址,第二个参数为商品金额
{"jsonrpc":"2.0","id":1,"method":"waitstable","params":[ "VXA5Q27TPFZAO4DGKRR3W2D62YIM7GPD",100]}
返回:
{
"jsonrpc": "2.0",
"result": true,
"id": 1
}
第一个参数为商品地址,第二个参数为商品金额
{"jsonrpc":"2.0","id":1,"method":"getpaycode","params":[ "VXA5Q27TPFZAO4DGKRR3W2D62YIM7GPD",100]}
返回:
{
"jsonrpc": "2.0",
"result": "byteball:VXA5Q27TPFZAO4DGKRR3W2D62YIM7GPD?amount=100&asset=jH12XQGk0JJxYAO7j%2FlK0jrRjKVuEFc9mfTUc14mx1g%3D",
"id": 1
}
第一个参数为用户地址,第二个参数为金额,第三个参数为资产
{"jsonrpc":"2.0","id":1,"method":"sendtoaddress","params":["LDLIJOWMGJVLPCVXKZ6KP7JILQHYVEI6",100,"jH12XQGk0JJxYAO7j/lK0jrRjKVuEFc9mfTUc14mx1g="]}
只传2个参数即可 同上
{"jsonrpc":"2.0","id":1,"method":"sendtoaddress","params":["LDLIJOWMGJVLPCVXKZ6KP7JILQHYVEI6",100]}
返回:
{
"jsonrpc": "2.0",
"result": "7tf3+cH+A3bL9T9SCA2E/oZJzK+kUDekxFM50RbuCrI=",
"id": 1
}