Skip to content

Commit

Permalink
harness: update per @JoeGruffins suggestions
Browse files Browse the repository at this point in the history
	- Rename monero_functions.inc -> monero_functions
	- Tidy extra whitespace at eol for harness.sh &
	  monero_functions.
  • Loading branch information
xorzero777 authored and JoeGruffins committed Jul 25, 2024
1 parent 858bcdf commit e446718
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 45 deletions.
74 changes: 37 additions & 37 deletions dex/testing/xmr/harness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Tmux script that sets up an XMR regtest harness with one node 'alpha' and 3
# wallets 'fred', 'bill' & 'charlie'. Charlie also has a View-Only sibling.

###############################################################################
################################################################################
# Development
################################################################################

Expand All @@ -12,7 +12,7 @@
# Monero RPC functions
################################################################################

source monero_functions.inc
source monero_functions

################################################################################
# Start up
Expand Down Expand Up @@ -78,8 +78,8 @@ mkdir -p "${HARNESS_CTL_DIR}"
mkdir -p "${ALPHA_DATA_DIR}"
touch "${ALPHA_REGTEST_CFG}" # currently empty

# make available from the harness-ctl dir
cp monero_functions.inc ${HARNESS_CTL_DIR}
# make available from the harness-ctl dir
cp monero_functions ${HARNESS_CTL_DIR}

# Background watch mining in window ??? by default:
# 'export NOMINER="1"' or uncomment this line to disable
Expand All @@ -93,7 +93,7 @@ echo "Writing ctl scripts"
# Daemon info
cat > "${HARNESS_CTL_DIR}/alpha_info" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
get_info ${ALPHA_NODE_RPC_PORT}
EOF
chmod +x "${HARNESS_CTL_DIR}/alpha_info"
Expand All @@ -105,7 +105,7 @@ chmod +x "${HARNESS_CTL_DIR}/alpha_info"
# - do_not_relay to other nodes - defaults to false
cat > "${HARNESS_CTL_DIR}/alpha_sendrawtransaction" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
sendrawtransaction ${ALPHA_NODE_RPC_PORT} \$1 \$2 2>/dev/null
EOF
chmod +x "${HARNESS_CTL_DIR}/alpha_sendrawtransaction"
Expand All @@ -117,7 +117,7 @@ chmod +x "${HARNESS_CTL_DIR}/alpha_sendrawtransaction"
# - decode_as_json - defaults to false
cat > "${HARNESS_CTL_DIR}/alpha_get_transactions" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
get_transactions ${ALPHA_NODE_RPC_PORT} \$1 \$2 2>/dev/null
EOF
chmod +x "${HARNESS_CTL_DIR}/alpha_get_transactions"
Expand All @@ -128,7 +128,7 @@ chmod +x "${HARNESS_CTL_DIR}/alpha_get_transactions"
# - txids as hex string - "hash1,hash2,hash3,..."
cat > "${HARNESS_CTL_DIR}/alpha_get_transactions_details" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
get_transactions ${ALPHA_NODE_RPC_PORT} \$1 true 2>/dev/null | jq '.txs[] | .as_json | fromjson'
EOF
chmod +x "${HARNESS_CTL_DIR}/alpha_get_transactions_details"
Expand All @@ -137,7 +137,7 @@ chmod +x "${HARNESS_CTL_DIR}/alpha_get_transactions_details"
# Mempool info
cat > "${HARNESS_CTL_DIR}/alpha_transaction_pool" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
get_transaction_pool ${ALPHA_NODE_RPC_PORT} 2>/dev/null
EOF
chmod +x "${HARNESS_CTL_DIR}/alpha_transaction_pool"
Expand All @@ -148,7 +148,7 @@ chmod +x "${HARNESS_CTL_DIR}/alpha_transaction_pool"
# - number of blocks to mine
cat > "${HARNESS_CTL_DIR}/mine-to-bill" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
generate ${BILL_WALLET_PRIMARY_ADDRESS} ${ALPHA_NODE_RPC_PORT} \$1
sleep 1
EOF
Expand All @@ -162,7 +162,7 @@ chmod +x "${HARNESS_CTL_DIR}/mine-to-bill"
# - lock time in blocks after which the money can be spent (defaults to 0; no locking)
cat > "${HARNESS_CTL_DIR}/fred_transfer_to" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
transfer_simple ${FRED_WALLET_RPC_PORT} \$1 \$2 \$3
sleep 0.5
EOF
Expand All @@ -176,7 +176,7 @@ chmod +x "${HARNESS_CTL_DIR}/fred_transfer_to"
# - lock time in blocks after which the money can be spent (defaults to 0; no locking)
cat > "${HARNESS_CTL_DIR}/bill_transfer_to" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
transfer_simple ${BILL_WALLET_RPC_PORT} \$1 \$2 \$3
sleep 0.5
EOF
Expand All @@ -190,7 +190,7 @@ chmod +x "${HARNESS_CTL_DIR}/bill_transfer_to"
# - lock time in blocks after which the money can be spent (defaults to 0; no locking)
cat > "${HARNESS_CTL_DIR}/charlie_transfer_to" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
transfer_simple ${CHARLIE_WALLET_RPC_PORT} \$1 \$2 \$3
sleep 0.5
EOF
Expand All @@ -202,7 +202,7 @@ chmod +x "${HARNESS_CTL_DIR}/charlie_transfer_to"
# - account number - defaults to account 0
cat > "${HARNESS_CTL_DIR}/fred_balance" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
get_balance ${FRED_WALLET_RPC_PORT} \$1
EOF
chmod +x "${HARNESS_CTL_DIR}/fred_balance"
Expand All @@ -213,7 +213,7 @@ chmod +x "${HARNESS_CTL_DIR}/fred_balance"
# - account number - defaults to account 0
cat > "${HARNESS_CTL_DIR}/bill_balance" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
get_balance ${BILL_WALLET_RPC_PORT} \$1
EOF
chmod +x "${HARNESS_CTL_DIR}/bill_balance"
Expand All @@ -224,7 +224,7 @@ chmod +x "${HARNESS_CTL_DIR}/bill_balance"
# - account number - defaults to account 0
cat > "${HARNESS_CTL_DIR}/charlie_balance" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
get_balance ${CHARLIE_WALLET_RPC_PORT} \$1
EOF
chmod +x "${HARNESS_CTL_DIR}/charlie_balance"
Expand All @@ -233,7 +233,7 @@ chmod +x "${HARNESS_CTL_DIR}/charlie_balance"
# Update fred's wallet from the daemon latest info
cat > "${HARNESS_CTL_DIR}/fred_refresh_wallet" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
refresh_wallet ${FRED_WALLET_RPC_PORT}
EOF
chmod +x "${HARNESS_CTL_DIR}/fred_refresh_wallet"
Expand All @@ -242,7 +242,7 @@ chmod +x "${HARNESS_CTL_DIR}/fred_refresh_wallet"
# Update bill's wallet from the daemon latest info
cat > "${HARNESS_CTL_DIR}/bill_refresh_wallet" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
refresh_wallet ${BILL_WALLET_RPC_PORT}
EOF
chmod +x "${HARNESS_CTL_DIR}/bill_refresh_wallet"
Expand All @@ -251,7 +251,7 @@ chmod +x "${HARNESS_CTL_DIR}/bill_refresh_wallet"
# Update charlie's wallet from the daemon latest info
cat > "${HARNESS_CTL_DIR}/charlie_refresh_wallet" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
refresh_wallet ${CHARLIE_WALLET_RPC_PORT}
EOF
chmod +x "${HARNESS_CTL_DIR}/charlie_refresh_wallet"
Expand All @@ -262,7 +262,7 @@ chmod +x "${HARNESS_CTL_DIR}/charlie_refresh_wallet"
# - transfer_type - defualts to "all"
cat > "${HARNESS_CTL_DIR}/fred_incoming_transfers" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
incoming_transfers ${FRED_WALLET_RPC_PORT} \$1
EOF
chmod +x "${HARNESS_CTL_DIR}/fred_incoming_transfers"
Expand All @@ -273,7 +273,7 @@ chmod +x "${HARNESS_CTL_DIR}/fred_incoming_transfers"
# - transfer_type - defaults to "all"
cat > "${HARNESS_CTL_DIR}/charlie_incoming_transfers" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
incoming_transfers ${CHARLIE_WALLET_RPC_PORT} \$1
EOF
chmod +x "${HARNESS_CTL_DIR}/charlie_incoming_transfers"
Expand All @@ -284,7 +284,7 @@ chmod +x "${HARNESS_CTL_DIR}/charlie_incoming_transfers"
# - all - defaults to true - otherwise only new outputs since the last call
cat > "${HARNESS_CTL_DIR}/fred_export_outputs" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
export_outputs ${FRED_WALLET_RPC_PORT} \$1
EOF
chmod +x "${HARNESS_CTL_DIR}/fred_export_outputs"
Expand All @@ -295,7 +295,7 @@ chmod +x "${HARNESS_CTL_DIR}/fred_export_outputs"
# - all - defaults to true - otherwise only new outputs since the last call
cat > "${HARNESS_CTL_DIR}/charlie_export_outputs" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
export_outputs ${CHARLIE_WALLET_RPC_PORT} \$1
EOF
chmod +x "${HARNESS_CTL_DIR}/charlie_export_outputs"
Expand All @@ -306,7 +306,7 @@ chmod +x "${HARNESS_CTL_DIR}/charlie_export_outputs"
# - all - defaults to true - otherwise only new outputs since the last call .. not useful for view wallet
cat > "${HARNESS_CTL_DIR}/charlie_view_export_outputs" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
export_outputs ${CHARLIE_VIEW_WALLET_RPC_PORT} \$1
EOF
chmod +x "${HARNESS_CTL_DIR}/charlie_view_export_outputs"
Expand All @@ -317,7 +317,7 @@ chmod +x "${HARNESS_CTL_DIR}/charlie_view_export_outputs"
# - all - defaults to true - otherwise only new outputs since the last call
cat > "${HARNESS_CTL_DIR}/fred_export_key_images" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
export_key_images ${FRED_WALLET_RPC_PORT} \$1
EOF
chmod +x "${HARNESS_CTL_DIR}/fred_export_key_images"
Expand All @@ -328,7 +328,7 @@ chmod +x "${HARNESS_CTL_DIR}/fred_export_key_images"
# - all - defaults to true - otherwise only new outputs since the last call
cat > "${HARNESS_CTL_DIR}/charlie_export_key_images" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
export_key_images ${CHARLIE_WALLET_RPC_PORT} \$1
EOF
chmod +x "${HARNESS_CTL_DIR}/charlie_export_key_images"
Expand All @@ -341,10 +341,10 @@ chmod +x "${HARNESS_CTL_DIR}/charlie_export_key_images"
# - lock time in blocks after which the money can be spent (defaults to 0; no locking)
# outputs:
# - tx_blob
# - tx_hash
# - tx_hash
cat > "${HARNESS_CTL_DIR}/fred_build_tx" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
transfer_no_relay ${FRED_WALLET_RPC_PORT} \$1 \$2 \$3 | jq -nr '[inputs] | add | .result.tx_blob, .result.tx_hash'
EOF
chmod +x "${HARNESS_CTL_DIR}/fred_build_tx"
Expand All @@ -357,10 +357,10 @@ chmod +x "${HARNESS_CTL_DIR}/fred_build_tx"
# - lock time in blocks after which the money can be spent (defaults to 0; no locking)
# outputs:
# - tx_blob
# - tx_hash
# - tx_hash
cat > "${HARNESS_CTL_DIR}/charlie_build_tx" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
transfer_no_relay ${CHARLIE_WALLET_RPC_PORT} \$1 \$2 \$3 | jq -nr '[inputs] | add | .result.tx_blob, .result.tx_hash'
EOF
chmod +x "${HARNESS_CTL_DIR}/charlie_build_tx"
Expand Down Expand Up @@ -403,7 +403,7 @@ chmod +x "${HARNESS_CTL_DIR}/quit"
# Commands help
cat > "${NODES_ROOT}/harness-ctl/help" <<EOF
#!/usr/bin/env bash
source monero_functions.inc
source monero_functions
cmd_help | less
EOF
chmod +x "${HARNESS_CTL_DIR}/help"
Expand Down Expand Up @@ -470,7 +470,7 @@ tmux send-keys -t $SESSION:2 "monero-wallet-rpc \
--rpc-bind-port ${FRED_WALLET_RPC_PORT} \
--wallet-dir ${FRED_WALLET_DIR} \
--disable-rpc-login \
--allow-mismatched-daemon-version; tmux wait-for -S fredxmr" C-m
--allow-mismatched-daemon-version; tmux wait-for -S fredxmr" C-m

sleep 2

Expand Down Expand Up @@ -568,12 +568,12 @@ get_balance ${BILL_WALLET_RPC_PORT}
# transfer some money from bill-the-miner to fred and charlie
for money in 10000000000000 18000000000000 5000000000000 7000000000000 1000000000000 15000000000000 3000000000000 25000000000000
do
transfer_simple ${BILL_WALLET_RPC_PORT} ${money} ${FRED_WALLET_PRIMARY_ADDRESS}
sleep 1
transfer_simple ${BILL_WALLET_RPC_PORT} ${money} ${FRED_WALLET_PRIMARY_ADDRESS}
sleep 1
transfer_simple ${BILL_WALLET_RPC_PORT} ${money} ${CHARLIE_WALLET_PRIMARY_ADDRESS}
sleep 1
generate ${BILL_WALLET_PRIMARY_ADDRESS} ${ALPHA_NODE_RPC_PORT} 1
sleep 1
sleep 1
generate ${BILL_WALLET_PRIMARY_ADDRESS} ${ALPHA_NODE_RPC_PORT} 1
sleep 1
done

# generate charlie view only wallet (no spend key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ restore_deterministic_wallet() {
local seed="${4:?input seed 25 words from English wordlist}"
params="{\"filename\":\"${wallet_name}\",\"password\":\"${pass}\",\"seed\":\"${seed}\"}"
monero-rpc-request "${port}" "restore_deterministic_wallet" "${params}" | jq '.'
}
}

generate_from_keys() {
local port="${1:?input a monero wallet port}"
Expand Down Expand Up @@ -207,15 +207,15 @@ export_key_images() {

import_key_images() {
local port="${1:?input a valid wallet rpc port}"
local signed_key_images="${2:?input a a set valid key images}" # json array of signed key images:
local signed_key_images="${2:?input a a set valid key images}" # json array of signed key images
params="{\"signed_key_images\":\"${signed_key_images}\"}"
monero-rpc-request "${port}" "import_key_images" "${params}"
}

# transfer monero to 1 recipient at their account 0, subaddress-indeces [0]
# but do not send. If called from a normal wallet with keys it generates a
# transfer monero to 1 recipient at their account 0, subaddress-indeces [0]
# but do not send. If called from a normal wallet with keys it generates a
# signed tx. Iff it is called for a view only wallet (like watch only) an
# unsigned_txset (an unsigned tx) will be also returned. This can then be
# unsigned_txset (an unsigned tx) will be also returned. This can then be
# signed by the parent full wallet proxy but offline (i.e. not connected to
# alpha node) using the interactive monero-wallet-cli.
#
Expand All @@ -238,10 +238,10 @@ transfer_no_relay() {
}

# sign a prepared unsigned txset -- offline manual experimental
#
#
# Note: can only be done by an offline cold wallet that has never been "online"
# use the monero-wallet-cli interactive tool instead in a manual process with
# an unconnected charlie_view wallet which holds the inputs but not any keys.
# an unconnected charlie_view wallet which holds the inputs but not any spend keys.
sign_transfer() {
local port="${1:?input a valid wallet rpc port for a cold wallet}"
local unsigned_txset="${2:?input an unsigned tx set}"
Expand Down Expand Up @@ -322,7 +322,7 @@ cmd_help() {
echo " - amount in in atomic units 1e12 - e.g. 1230000000000 = 1.23 XMR"
echo " - address - recipient primary address - account index 0, subaddr_indeces [0]"
echo " - unlock_time - unlock after n blocks and make spendable - defaults to 0 (no lock)"
echo ""
echo ""
echo "fred_export_outputs"
echo "- export fred outputs hex"
echo "- input:"
Expand Down

0 comments on commit e446718

Please sign in to comment.