local req='"method":"Chain33.ConvertExectoAddr","params":[{"execname":"'"${exector}"'"}]'
chain33_Http "$req"${MAIN_HTTP}'(.error|not) and (.result != null)'"$FUNCNAME"
echo"#request: $req"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
# GAME_ADDR=$(echo "${res}" | jq -r ".result")
echo_rst "$FUNCNAME""$?"
}
}
function CreateGameTx(){
function CreateGameTx(){
local amount=$1
local amount=$1
local hash_value=$2
local hash_value=$2
local req='"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"createGame", "payload":{"amount": '"${amount}"',"hashType":"sha256","hashValue":"'"${hash_value}"'"}}]'
local req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"createGame", "payload":{"amount": '"${amount}"',"hashType":"sha256","hashValue":"'"${hash_value}"'"}}]}'
echo"#request: $req"
chain33_Http "$req"${MAIN_HTTP}'(.error|not) and (.result != null)'"$FUNCNAME"".result"
local req='"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"matchGame", "payload":{"gameId": "'"${gameId}"'","guess":2}}]'
local req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"matchGame", "payload":{"gameId": "'"${gameId}"'","guess":2}}]}'
chain33_Http "$req"${MAIN_HTTP}'(.error|not) and (.result != null)'"MatchGame createRawTx"".result"
local req='"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"closeGame", "payload":{"gameId": "'"${gameId}"'","secret":"'"${secret}"'","result":1}}]'
local req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"closeGame", "payload":{"gameId": "'"${gameId}"'","secret":"'"${secret}"'","result":1}}]}'
local req='"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"cancelGame", "payload":{"gameId": "'"${gameId}"'"}}]'
local req='{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${EXECTOR}"'", "actionName":"cancelGame", "payload":{"gameId": "'"${gameId}"'"}}]}'
echo"#request: $req"
chain33_Http "$req"${MAIN_HTTP}'(.error|not) and (.result != null)'"CancleGame createRawTx"".result"
local req='"method":"Chain33.Query","params":[{"execer":"'"${EXECTOR}"'","funcName":"QueryGameListByStatusAndAddr","payload":{"status":'"${status}"',"address":""}}]'
local req='{"method":"Chain33.Query","params":[{"execer":"'"${EXECTOR}"'","funcName":"QueryGameListByStatusAndAddr","payload":{"status":'"${status}"',"address":""}}]}'
resok='(.error|not) and (.result.records | length == '"$count"') and (.result.records[0].addr == "'"$addr"'") and (.result.records[0].buyAmount == "'"$amount"'")'
chain33_Http '{"method":"paracross.GetHeight","params":[]}'${UNIT_HTTP}'(.error|not) and (.result| [has("consensHeight"),true])'"$FUNCNAME"
#echo $resp
ok=$(jq '(.error|not) and (.result| [has("consensHeight"),true])'<<<"$resp")
["$ok"==true]
local rst=$?
echo_rst "$FUNCNAME""$rst"
fi
fi
}
}
function paracross_GetNodeGroupAddrs(){
function paracross_GetNodeGroupAddrs(){
local resp
chain33_Http '{"method":"paracross.GetNodeGroupAddrs","params":[{"title":"user.p.para."}]}'${UNIT_HTTP}'(.error|not) and (.result| [has("key","value"),true])'"$FUNCNAME"
ok=$(jq '(.error|not) and (.result| [has("key","value"),true])'<<<"$resp")
["$ok"==true]
local rst=$?
echo_rst "$FUNCNAME""$rst"
}
}
function paracross_GetNodeGroupStatus(){
function paracross_GetNodeGroupStatus(){
local resp
chain33_Http '{"method":"paracross.GetNodeGroupStatus","params":[{"title":"user.p.para."}]}'${UNIT_HTTP}'(.error|not) and (.result| [has("status"),true])'"$FUNCNAME"
ok=$(jq '(.error|not) and (.result| [has("status"),true])'<<<"$resp")
["$ok"==true]
local rst=$?
echo_rst "$FUNCNAME""$rst"
}
}
function paracross_ListNodeGroupStatus(){
function paracross_ListNodeGroupStatus(){
local resp
chain33_Http '{"method":"paracross.ListNodeGroupStatus","params":[{"title":"user.p.para.","status":2}]}'${UNIT_HTTP}'(.error|not) and (.result| [has("status"),true])'"$FUNCNAME"
ok=$(jq '(.error|not) and (.result| [has("status"),true])'<<<"$resp")
["$ok"==true]
local rst=$?
echo_rst "$FUNCNAME""$rst"
}
}
function paracross_ListNodeStatus(){
function paracross_ListNodeStatus(){
local resp
chain33_Http '{"method":"paracross.ListNodeStatus","params":[{"title":"user.p.para.","status":4}]}'${UNIT_HTTP}'(.error|not) and (.result| [has("status"),true])'"$FUNCNAME"
resok='(.error|not) and .result.showSuccessful and (.result.pubkeypair=="0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb")'
ok=$(jq '(.error|not) and .result.showSuccessful and (.result.pubkeypair=="0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb")'<<<"$resp")
chain33_Http '{"method":"privacy.EnablePrivacy", "params":[{"addrs":["12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"]}]}'${MAIN_HTTP}'(.error|not) and .result.results[0].IsOK'"$FUNCNAME"
local req='"method":"relay.CreateRawRelaySaveBTCHeadTx","params":[{"hash":"5e7d9c599cd040ec2ba53f4dee28028710be8c135e779f65c56feadaae34c3f2","height":10,"version":536870912,"merkleRoot":"ab91cd4160e1379c337eee6b7a4bdbb7399d70268d86045aba150743c00c90b6","time":1530862108,"nonce":0,"bits":545259519,"previousHash":"604efe53975ab06cad8748fd703ad5bc960e8b752b2aae98f0f871a4a05abfc7","isReset":true}]'
local req='{"method":"relay.CreateRawRelaySaveBTCHeadTx","params":[{"hash":"5e7d9c599cd040ec2ba53f4dee28028710be8c135e779f65c56feadaae34c3f2","height":10,"version":536870912,"merkleRoot":"ab91cd4160e1379c337eee6b7a4bdbb7399d70268d86045aba150743c00c90b6","time":1530862108,"nonce":0,"bits":545259519,"previousHash":"604efe53975ab06cad8748fd703ad5bc960e8b752b2aae98f0f871a4a05abfc7","isReset":true}]}'
# echo "#request: $req"
chain33_Http "$req"${MAIN_HTTP}'(.error|not) and (.result != null)'"$FUNCNAME"".result"
local req='"method":"relay.CreateRawRelaySaveBTCHeadTx","params":[{"hash":"7b7a4a9b49db5a1162be515d380cd186e98c2bf0bb90f1145485d7c43343fc7c","height":11,"version":536870912,"merkleRoot":"cfa9b66696aea63b7266ffaa1cb4b96c8dd6959eaabf2eb14173f4adaa551f6f","time":1530862108,"nonce":1,"bits":545259519,"previousHash":"5e7d9c599cd040ec2ba53f4dee28028710be8c135e779f65c56feadaae34c3f2","isReset":false}]'
local req='{"method":"relay.CreateRawRelaySaveBTCHeadTx","params":[{"hash":"7b7a4a9b49db5a1162be515d380cd186e98c2bf0bb90f1145485d7c43343fc7c","height":11,"version":536870912,"merkleRoot":"cfa9b66696aea63b7266ffaa1cb4b96c8dd6959eaabf2eb14173f4adaa551f6f","time":1530862108,"nonce":1,"bits":545259519,"previousHash":"5e7d9c599cd040ec2ba53f4dee28028710be8c135e779f65c56feadaae34c3f2","isReset":false}]}'
# echo "#request: $req"
chain33_Http "$req"${MAIN_HTTP}'(.error|not) and (.result != null)'"$FUNCNAME"".result"
local req='"method":"relay.CreateRawRelayOrderTx","params":[{"operation":0,"coin":"BTC","amount":299000000,"addr":"1Am9UTGfdnxabvcywYG2hvzr6qK8T3oUZT","btyAmount":1000000000,"coinWaits":6}]'
local req='{"method":"relay.CreateRawRelayOrderTx","params":[{"operation":0,"coin":"BTC","amount":299000000,"addr":"1Am9UTGfdnxabvcywYG2hvzr6qK8T3oUZT","btyAmount":1000000000,"coinWaits":6}]}'
# echo "#request: $req"
chain33_Http "$req"${MAIN_HTTP}'(.error|not) and (.result != null)'"$FUNCNAME"".result"
local req='"method":"relay.CreateRawRelayConfirmTx","params":[{"orderId":"'"$id"'","rawTx":"6359f0868171b1d194cbee1af2f16ea598ae8fad666d9b012c8ed2b79a236ec4"}]'
local req='{"method":"relay.CreateRawRelayConfirmTx","params":[{"orderId":"'"$id"'","rawTx":"6359f0868171b1d194cbee1af2f16ea598ae8fad666d9b012c8ed2b79a236ec4"}]}'
# echo "#request: $req"
chain33_Http "$req"${MAIN_HTTP}'(.error|not) and (.result != null)'"$FUNCNAME"".result"
local req='"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetRelayOrderByStatus","payload":{"addr":"","status":"'"$status"'","coins":["BTC"],"pageNumber":0,"pageSize":0}}]'
local req='{"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetRelayOrderByStatus","payload":{"addr":"","status":"'"$status"'","coins":["BTC"],"pageNumber":0,"pageSize":0}}]}'
# echo "#request: $req"
chain33_Http "$req"${MAIN_HTTP}'(.error|not) and (.result.relayorders[0].id != null)'"$FUNCNAME"
resp=$(curl -ksd"{$req}"${MAIN_HTTP})
# echo "#response: $resp"
ok=$(jq '(.error|not) and (.result.relayorders[0].id != "")'<<<"$resp")
["$ok"==true]
echo_rst "$FUNCNAME""$?"
}
}
query_GetSellRelayOrder(){
query_GetSellRelayOrder(){
local req='"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetSellRelayOrder","payload":{"addr":"1G5Cjy8LuQex2fuYv3gzb7B8MxAnxLEqt3","status":"pending","coins":["BTC"],"pageNumber":0,"pageSize":0}}]'
local req='{"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetSellRelayOrder","payload":{"addr":"1G5Cjy8LuQex2fuYv3gzb7B8MxAnxLEqt3","status":"pending","coins":["BTC"],"pageNumber":0,"pageSize":0}}]}'
# echo "#request: $req"
resok='(.error|not) and (.result.relayorders[0].status == "pending") and (.result.relayorders[0].coinOperation == 0) and (.result.relayorders[0].id != null)'
ok=$(jq '(.error|not) and (.result.relayorders[0].status == "pending") and (.result.relayorders[0].coinOperation == 0) and (.result.relayorders[0].id != "") '<<<"$resp")
["$ok"==true]
echo_rst "$FUNCNAME""$?"
}
}
query_GetBuyRelayOrder(){
query_GetBuyRelayOrder(){
local req='"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetBuyRelayOrder","payload":{"addr":"1EZKahMRfoMiKp1BewjWrQWoaJ9kmC4hum","status":"locking","coins":["BTC"],"pageNumber":0,"pageSize":0}}]'
local req='{"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetBuyRelayOrder","payload":{"addr":"1EZKahMRfoMiKp1BewjWrQWoaJ9kmC4hum","status":"locking","coins":["BTC"],"pageNumber":0,"pageSize":0}}]}'
# echo "#request: $req"
chain33_Http "$req"${MAIN_HTTP}'(.error|not) and (.result.relayorders[0].status == "locking")'"$FUNCNAME"
resp=$(curl -ksd"{$req}"${MAIN_HTTP})
# echo "#response: $resp"
ok=$(jq '(.error|not) and (.result.relayorders[0].status == "locking")'<<<"$resp")
["$ok"==true]
echo_rst "$FUNCNAME""$?"
}
}
query_GetBTCHeaderList(){
query_GetBTCHeaderList(){
local req='"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetBTCHeaderList","payload":{"reqHeight":"10","counts":10,"direction":0}}]'
local req='{"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetBTCHeaderList","payload":{"reqHeight":"10","counts":10,"direction":0}}]}'
# echo "#request: $req"
chain33_Http "$req"${MAIN_HTTP}'(.error|not) and (.result.heights|length == 2)'"$FUNCNAME"
resp=$(curl -ksd"{$req}"${MAIN_HTTP})
echo"#response: $resp"
ok=$(jq '(.error|not) and (.result.heights|length == 2)'<<<"$resp")
["$ok"==true]
echo_rst "$FUNCNAME""$?"
}
}
query_GetBTCHeaderCurHeight(){
query_GetBTCHeaderCurHeight(){
local req='"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetBTCHeaderCurHeight","payload":{"baseHeight":"0"}}]'
local req='{"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetBTCHeaderCurHeight","payload":{"baseHeight":"0"}}]}'
# echo "#request: $req"
chain33_Http "$req"${MAIN_HTTP}'(.error|not) and (.result.baseHeight == "10") and (.result.curHeight == "10")'"$FUNCNAME"
resp=$(curl -ksd"{$req}"${MAIN_HTTP})
echo"#response: $resp"
ok=$(jq '(.error|not) and (.result.baseHeight == "10") and (.result.curHeight == "10")'<<<"$resp")
echo"========== # retrieve perform end =========="
chain33_BlockWait 1 "${MAIN_HTTP}"
}
}
retrieve_Perform_Token(){
retrieve_Perform_Token(){
echo"========== # retrieve perform begin =========="
local req='{"method":"retrieve.CreateRawRetrievePerformTx","params":[{"backupAddr":"'$retrieve1'","defaultAddr":"'$retrieve2'","assets": [{"exec":"token","symbol":"'"$symbol"'"}] }]}'
local req='{"method":"retrieve.CreateRawRetrievePerformTx","params":[{"backupAddr":"'$retrieve1'","defaultAddr":"'$retrieve2'","assets": [{"exec":"token","symbol":"'"$symbol"'"}] }]}'
echo"========== # retrieve query result begin =========="
local status=$1
local status=$1
local req='{"method":"Chain33.Query","params":[{"execer":"retrieve","funcName":"GetRetrieveInfo","payload":{"backupAddress":"'$retrieve1'", "defaultAddress":"'$retrieve2'"}}]}'
local req='{"method":"Chain33.Query","params":[{"execer":"retrieve","funcName":"GetRetrieveInfo","payload":{"backupAddress":"'$retrieve1'", "defaultAddress":"'$retrieve2'"}}]}'
echo"========== # retrieve query result end =========="
}
}
retrieve_QueryAssetResult(){
retrieve_QueryAssetResult(){
echo"========== # retrieve query result begin =========="
local status=$1
local status=$1
local req='{"method":"Chain33.Query","params":[{"execer":"retrieve","funcName":"GetRetrieveInfo","payload":{"backupAddress":"'$retrieve1'", "defaultAddress":"'$retrieve2'","assetExec":"token", "assetSymbol":"'"$symbol"'"}}]}'
local req='{"method":"Chain33.Query","params":[{"execer":"retrieve","funcName":"GetRetrieveInfo","payload":{"backupAddress":"'$retrieve1'", "defaultAddress":"'$retrieve2'","assetExec":"token", "assetSymbol":"'"$symbol"'"}}]}'
resok='(.error|not) and (.result.tickets | length > 0) and (.result.tickets[0].minerAddress == "'"$minerAddr"'") and (.result.tickets[0].returnAddress == "'"$returnAddr"'")'
resok='(.error|not) and (.result.tickets | length > 0) and (.result.tickets[0].minerAddress == "'"$minerAddr"'") and (.result.tickets[0].returnAddress == "'"$returnAddr"'") and (.result.tickets[0].status == '"$status"')'
ok=$(jq '(.error|not) and (.result.tickets | length > 0) and (.result.tickets[0].minerAddress == "'"$minerAddr"'") and (.result.tickets[0].returnAddress == "'"$returnAddr"'") and (.result.tickets[0].status == '"$status"')'<<<"$resp")