local req='"method":"Chain33.ConvertExectoAddr","params":[{"execname":"'"${exector}"'"}]'
resok='(.error|not)'
echo"#request: $req"
http_req "$req"${MAIN_HTTP}"$resok""$FUNCNAME"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
echo"#response: $resp"
# local exector=$1
# local req='"method":"Chain33.ConvertExectoAddr","params":[{"execname":"'"${exector}"'"}]'
# echo "#request: $req"
# resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
# echo "#response: $resp"
# GAME_ADDR=$(echo "${res}" | jq -r ".result")
# GAME_ADDR=$(echo "${res}" | jq -r ".result")
echo_rst "$FUNCNAME""$?"
# 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}"'"}}]}'
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}}]}'
echo"#request: $req"
http_req "$req"${MAIN_HTTP}'(.error|not) and (.result != "")'"MatchGame createRawTx"
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}}]}'
echo"#request: $req"
http_req "$req"${MAIN_HTTP}'(.error|not) and (.result != "")'"CloseGame createRawTx"
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"
http_req "$req"${MAIN_HTTP}'(.error|not) and (.result != "")'"CancleGame createRawTx"
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":""}}]}'
echo"#request: $req"
http_req "$req"${MAIN_HTTP}'(.error|not) and (.result.games != "")'"$FUNCNAME"
resp=$(curl -ksd"{$req}""${MAIN_HTTP}")
# echo "#request: $req"
echo"#response: $resp"
# resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
GAMES=$(echo"${resp}" | jq -r".result.games")
# echo "#response: $resp"
echo"${GAMES}"
# GAMES=$(echo "${resp}" | jq -r ".result.games")
echo_rst "$FUNCNAME""$?"
# echo "${GAMES}"
# echo_rst "$FUNCNAME" "$?"
}
}
function QueryGameByGameId(){
function QueryGameByGameId(){
local gameId=$1
local gameId=$1
local status=$2
local status=$2
local req='"method":"Chain33.Query","params":[{"execer":"'"${EXECTOR}"'","funcName":"QueryGameById","payload":{"gameId":"'"${gameId}"'"}}]'
local req='{"method":"Chain33.Query","params":[{"execer":"'"${EXECTOR}"'","funcName":"QueryGameById","payload":{"gameId":"'"${gameId}"'"}}]}'
echo"#request: $req"
resok='(.error|not) and (.result.game.status = "'"${status}"'")'
resok='(.error|not) and (.result.records | length == '"$count"') and (.result.records[0].addr == "'"$addr"'") and (.result.records[0].buyAmount == "'"$amount"'")'
ok=$(jq '(.error|not) and (.result| [has("key","value"),true])'<<<"$resp")
# ok=$(jq '(.error|not) and (.result| [has("key","value"),true])' <<<"$resp")
["$ok"==true]
# [ "$ok" == true ]
local rst=$?
# local rst=$?
echo_rst "$FUNCNAME""$rst"
# echo_rst "$FUNCNAME" "$rst"
http_req '{"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("status"),true])'<<<"$resp")
# ok=$(jq '(.error|not) and (.result| [has("status"),true])' <<<"$resp")
["$ok"==true]
# [ "$ok" == true ]
local rst=$?
# local rst=$?
echo_rst "$FUNCNAME""$rst"
# echo_rst "$FUNCNAME" "$rst"
http_req '{"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=$(jq '(.error|not) and (.result| [has("status"),true])' <<<"$resp")
["$ok"==true]
# [ "$ok" == true ]
local rst=$?
# local rst=$?
echo_rst "$FUNCNAME""$rst"
# echo_rst "$FUNCNAME" "$rst"
http_req '{"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=$(jq '(.error|not) and (.result| [has("status"),true])' <<<"$resp")
["$ok"==true]
# [ "$ok" == true ]
local rst=$?
# local rst=$?
echo_rst "$FUNCNAME""$rst"
# echo_rst "$FUNCNAME" "$rst"
http_req '{"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")
http_req '{"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"
http_req "$req"${MAIN_HTTP}'(.error|not) and (.result != "")'"$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"
http_req "$req"${MAIN_HTTP}'(.error|not) and (.result != "")'"$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"
http_req "$req"${MAIN_HTTP}'(.error|not) and (.result != "")'"$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"
http_req "$req"${MAIN_HTTP}'(.error|not) and (.result != "")'"$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"
http_req "$req"${MAIN_HTTP}'(.error|not) and (.result.relayorders[0].id != "")'"$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 != "")'
resp=$(curl -ksd"{$req}"${MAIN_HTTP})
http_req "$req"${MAIN_HTTP}"$resok""$FUNCNAME"
# echo "#response: $resp"
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"
http_req "$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"
http_req "$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"
http_req "$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")
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'"}}]}'
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"'")'
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")
# 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")
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"')'