Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get details from transaction differences in getrawmempool #6035

Merged
merged 8 commits into from
Feb 1, 2023
42 changes: 38 additions & 4 deletions zebra-utils/zcash-rpc-diff
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function usage()

# Override the commands used by this script using these environmental variables:
ZCASH_CLI="${ZCASH_CLI:-zcash-cli}"
ZCASH_RPC_COOKIE_FILE="${ZCASH_RPC_COOKIE_FILE:-.cookie}"
teor2345 marked this conversation as resolved.
Show resolved Hide resolved
DIFF="${DIFF:-diff --unified --color=always}"
JQ="${JQ:-jq}"

Expand All @@ -41,7 +42,7 @@ ZEBRAD=$(cat "$ZEBRAD_RELEASE_INFO" | grep '"subversion"' | cut -d: -f2 | cut -d
tr 'A-Z' 'a-z' | sed 's/magicbean/zcashd/ ; s/zebra$/zebrad/')

echo "Checking second node release info..."
$ZCASH_CLI getinfo > "$ZCASHD_RELEASE_INFO"
$ZCASH_CLI -rpccookiefile="$ZCASH_RPC_COOKIE_FILE" getinfo > "$ZCASHD_RELEASE_INFO"

ZCASHD=$(cat "$ZCASHD_RELEASE_INFO" | grep '"subversion"' | cut -d: -f2 | cut -d/ -f2 | \
tr 'A-Z' 'a-z' | sed 's/magicbean/zcashd/ ; s/zebra$/zebrad/')
Expand All @@ -60,7 +61,7 @@ ZEBRAD_NET=$(cat "$ZEBRAD_BLOCKCHAIN_INFO" | grep '"chain"' | cut -d: -f2 | tr -
ZEBRAD_HEIGHT=$(cat "$ZEBRAD_BLOCKCHAIN_INFO" | grep '"blocks"' | cut -d: -f2 | tr -d ' ,"')

echo "Checking $ZCASHD network and tip height..."
$ZCASH_CLI getblockchaininfo > "$ZCASHD_BLOCKCHAIN_INFO"
$ZCASH_CLI -rpccookiefile="$ZCASH_RPC_COOKIE_FILE" getblockchaininfo > "$ZCASHD_BLOCKCHAIN_INFO"

ZCASHD_NET=$(cat "$ZCASHD_BLOCKCHAIN_INFO" | grep '"chain"' | cut -d: -f2 | tr -d ' ,"')
ZCASHD_HEIGHT=$(cat "$ZCASHD_BLOCKCHAIN_INFO" | grep '"blocks"' | cut -d: -f2 | tr -d ' ,"')
Expand Down Expand Up @@ -93,7 +94,7 @@ time $ZCASH_CLI -rpcport="$ZEBRAD_RPC_PORT" "$@" > "$ZEBRAD_RESPONSE"
echo

echo "Querying $ZCASHD $ZCASHD_NET chain at height >=$ZCASHD_HEIGHT..."
time $ZCASH_CLI "$@" > "$ZCASHD_RESPONSE"
time $ZCASH_CLI -rpccookiefile="$ZCASH_RPC_COOKIE_FILE" "$@" > "$ZCASHD_RESPONSE"
echo

echo
Expand All @@ -119,6 +120,8 @@ EXIT_STATUS=$?

if [ "$1" == "getaddressutxos" ]; then
set "getaddressbalance" "$2"
elif [ "$1" == "getrawmempool" ]; then
set "getrawmempool"
oxarbitrage marked this conversation as resolved.
Show resolved Hide resolved
else
exit $EXIT_STATUS
fi
Expand All @@ -136,7 +139,7 @@ echo "Querying $ZEBRAD $ZEBRAD_NET chain at height >=$ZEBRAD_HEIGHT..."
$ZCASH_CLI -rpcport="$ZEBRAD_RPC_PORT" "$@" > "$ZEBRAD_CHECK_RESPONSE"

echo "Querying $ZCASHD $ZCASHD_NET chain at height >=$ZCASHD_HEIGHT..."
$ZCASH_CLI "$@" > "$ZCASHD_CHECK_RESPONSE"
$ZCASH_CLI -rpccookiefile="$ZCASH_RPC_COOKIE_FILE" "$@" > "$ZCASHD_CHECK_RESPONSE"

echo

Expand Down Expand Up @@ -192,6 +195,37 @@ if [ "$1" == "getaddressbalance" ]; then
fi
fi

if [ "$1" == "getrawmempool" ] && [ $CHECK_EXIT_STATUS != 0 ]; then
echo
echo "Obtaining transaction details"
echo

set TRANSACTION_ID
set TRANSACTION_HEX
set TRANSACTION_DECODED

while IFS= read -r line
do
if [ "$line" != "[" ] && [ "$line" != "]" ]; then
teor2345 marked this conversation as resolved.
Show resolved Hide resolved
if [[ "${line:0-1}" == "," ]]; then
TRANSACTION_ID="${line:3:-2}"
else
TRANSACTION_ID="${line:3:-1}"
fi

TRANSACTION_HEX=`$ZCASH_CLI -rpcport="$ZEBRAD_RPC_PORT" getrawtransaction $TRANSACTION_ID 0`
teor2345 marked this conversation as resolved.
Show resolved Hide resolved

echo "## Displaying transaction $TRANSACTION_ID"
echo

TRANSACTION_DECODED=`$ZCASH_CLI -rpccookiefile="$ZCASH_RPC_COOKIE_FILE" decoderawtransaction $TRANSACTION_HEX`

echo $TRANSACTION_DECODED | $JQ
echo
fi
done < "$ZEBRAD_RESPONSE"
fi

oxarbitrage marked this conversation as resolved.
Show resolved Hide resolved
if [ $EXIT_STATUS -ne 0 ]; then
exit $EXIT_STATUS
else
Expand Down