Commit f6e7b46b authored by 张振华's avatar 张振华

update

parent 8687a4d2
......@@ -106,7 +106,7 @@ chain33_ImportPrivkey() {
local req='"method":"Chain33.ImportPrivkey", "params":[{"privkey":"'"$pri"'", "label":"'"$label"'"}]'
resp=$(curl -ksd "{$req}" "$MAIN_HTTP")
ok=$(jq '(.error|not) and (.result.label=="'"$label"'") and (.result.acc.addr == "'"$acc"'")' <<<"$resp")
ok=$(jq '(((.error|not) and (.result.label=="'"$label"'") and (.result.acc.addr == "'"$acc"'")) or (.error=="ErrPrivkeyExist"))' <<<"$resp")
[ "$ok" == true ]
}
......@@ -125,3 +125,29 @@ chain33_SignRawTx() {
echo "signedTx null error"
fi
}
chain33_QueryBalance() {
local addr=$1
local MAIN_HTTP=$2
req='"method":"Chain33.GetAllExecBalance","params":[{"addr":"'"${addr}"'"}]'
#echo "#request: $req"
resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
echo "#response: $resp"
ok=$(jq '(.error|not) and (.result != "")' <<<"$resp")
[ "$ok" == true ]
echo "$resp" | jq -r ".result"
}
chain33_QueryExecBalance() {
local addr=$1
local exec=$2
local MAIN_HTTP=$3
req='{"method":"Chain33.GetBalance", "params":[{"addresses" : ["'"${addr}"'"], "execer" : "'"${exec}"'"}]}'
resp=$(curl -ksd "$req" "${MAIN_HTTP}")
echo "#response: $resp"
ok=$(jq '(.error|not) and (.result[0] | [has("balance", "frozen"), true] | unique | length == 1)' <<<"$resp")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
}
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment