mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Fix bash syntax inconsistencies
Many unnecesary braces around ${VARIABLE} references were removed.
This commit is contained in:
parent
694f96806e
commit
30a0f99861
@ -34,57 +34,58 @@
|
||||
#
|
||||
# `$ apitest/scripts/limit-order-simulation.sh -l 40000 -d sell -c fr -m 0.00 -a 0.125`
|
||||
|
||||
APP_BASE_NAME=$(basename "$0")
|
||||
APP_HOME=$(pwd -P)
|
||||
APITEST_SCRIPTS_HOME="${APP_HOME}/apitest/scripts"
|
||||
APITEST_SCRIPTS_HOME="$APP_HOME/apitest/scripts"
|
||||
|
||||
source "${APITEST_SCRIPTS_HOME}/trade-simulation-env.sh"
|
||||
source "${APITEST_SCRIPTS_HOME}/trade-simulation-utils.sh"
|
||||
source "$APITEST_SCRIPTS_HOME/trade-simulation-env.sh"
|
||||
source "$APITEST_SCRIPTS_HOME/trade-simulation-utils.sh"
|
||||
|
||||
checksetup
|
||||
parselimitorderopts "$@"
|
||||
|
||||
printdate "Started ${APP_BASE_NAME} with parameters:"
|
||||
printdate "Started $APP_BASE_NAME with parameters:"
|
||||
printscriptparams
|
||||
printbreak
|
||||
|
||||
editpaymentaccountform "$COUNTRY_CODE"
|
||||
exitoncommandalert $?
|
||||
cat "${APITEST_SCRIPTS_HOME}/${F2F_ACCT_FORM}"
|
||||
cat "$APITEST_SCRIPTS_HOME/$F2F_ACCT_FORM"
|
||||
printbreak
|
||||
|
||||
# Create F2F payment accounts for $COUNTRY_CODE, and get the $CURRENCY_CODE.
|
||||
printdate "Creating Alice's face to face ${COUNTRY_CODE} payment account."
|
||||
CMD="${CLI_BASE} --port=${ALICE_PORT} createpaymentacct --payment-account-form=${APITEST_SCRIPTS_HOME}/${F2F_ACCT_FORM}"
|
||||
printdate "ALICE CLI: ${CMD}"
|
||||
CMD_OUTPUT=$(createpaymentacct "${CMD}")
|
||||
printdate "Creating Alice's face to face $COUNTRY_CODE payment account."
|
||||
CMD="$CLI_BASE --port=$ALICE_PORT createpaymentacct --payment-account-form=$APITEST_SCRIPTS_HOME/$F2F_ACCT_FORM"
|
||||
printdate "ALICE CLI: $CMD"
|
||||
CMD_OUTPUT=$(createpaymentacct "$CMD")
|
||||
exitoncommandalert $?
|
||||
echo "${CMD_OUTPUT}"
|
||||
ALICE_ACCT_ID=$(getnewpaymentacctid "${CMD_OUTPUT}")
|
||||
echo "$CMD_OUTPUT"
|
||||
ALICE_ACCT_ID=$(getnewpaymentacctid "$CMD_OUTPUT")
|
||||
exitoncommandalert $?
|
||||
CURRENCY_CODE=$(getnewpaymentacctcurrency "${CMD_OUTPUT}")
|
||||
CURRENCY_CODE=$(getnewpaymentacctcurrency "$CMD_OUTPUT")
|
||||
exitoncommandalert $?
|
||||
printdate "ALICE F2F payment-account-id = ${ALICE_ACCT_ID}, currency-code = ${CURRENCY_CODE}."
|
||||
printdate "ALICE F2F payment-account-id = $ALICE_ACCT_ID, currency-code = $CURRENCY_CODE."
|
||||
printbreak
|
||||
|
||||
printdate "Creating Bob's face to face ${COUNTRY_CODE} payment account."
|
||||
CMD="${CLI_BASE} --port=${BOB_PORT} createpaymentacct --payment-account-form=${APITEST_SCRIPTS_HOME}/${F2F_ACCT_FORM}"
|
||||
printdate "BOB CLI: ${CMD}"
|
||||
CMD_OUTPUT=$(createpaymentacct "${CMD}")
|
||||
printdate "Creating Bob's face to face $COUNTRY_CODE payment account."
|
||||
CMD="$CLI_BASE --port=$BOB_PORT createpaymentacct --payment-account-form=$APITEST_SCRIPTS_HOME/$F2F_ACCT_FORM"
|
||||
printdate "BOB CLI: $CMD"
|
||||
CMD_OUTPUT=$(createpaymentacct "$CMD")
|
||||
exitoncommandalert $?
|
||||
echo "${CMD_OUTPUT}"
|
||||
BOB_ACCT_ID=$(getnewpaymentacctid "${CMD_OUTPUT}")
|
||||
echo "$CMD_OUTPUT"
|
||||
BOB_ACCT_ID=$(getnewpaymentacctid "$CMD_OUTPUT")
|
||||
exitoncommandalert $?
|
||||
CURRENCY_CODE=$(getnewpaymentacctcurrency "${CMD_OUTPUT}")
|
||||
CURRENCY_CODE=$(getnewpaymentacctcurrency "$CMD_OUTPUT")
|
||||
exitoncommandalert $?
|
||||
printdate "BOB F2F payment-account-id = ${BOB_ACCT_ID}, currency-code = ${CURRENCY_CODE}."
|
||||
printdate "BOB F2F payment-account-id = $BOB_ACCT_ID, currency-code = $CURRENCY_CODE."
|
||||
printbreak
|
||||
|
||||
# Bob & Alice now have matching payment accounts, now loop until the price limit is reached, then create an offer.
|
||||
if [ "$DIRECTION" = "BUY" ]
|
||||
then
|
||||
printdate "Create a BUY / ${CURRENCY_CODE} offer when the market price falls to or below ${LIMIT_PRICE} ${CURRENCY_CODE}."
|
||||
printdate "Create a BUY / $CURRENCY_CODE offer when the market price falls to or below $LIMIT_PRICE $CURRENCY_CODE."
|
||||
else
|
||||
printdate "Create a SELL / ${CURRENCY_CODE} offer when the market price rises to or above ${LIMIT_PRICE} ${CURRENCY_CODE}."
|
||||
printdate "Create a SELL / $CURRENCY_CODE offer when the market price rises to or above $LIMIT_PRICE $CURRENCY_CODE."
|
||||
fi
|
||||
|
||||
DONE=0
|
||||
@ -112,33 +113,33 @@ while : ; do
|
||||
sleep "$WAIT"
|
||||
done
|
||||
|
||||
printdate "ALICE: Creating ${DIRECTION} ${CURRENCY_CODE} offer with payment acct ${ALICE_ACCT_ID}."
|
||||
CMD="$CLI_BASE --port=${ALICE_PORT} createoffer"
|
||||
CMD+=" --payment-account=${ALICE_ACCT_ID}"
|
||||
CMD+=" --direction=${DIRECTION}"
|
||||
CMD+=" --currency-code=${CURRENCY_CODE}"
|
||||
CMD+=" --amount=${AMOUNT}"
|
||||
if [ -z "${MKT_PRICE_MARGIN}" ]; then
|
||||
CMD+=" --fixed-price=${FIXED_PRICE}"
|
||||
printdate "ALICE: Creating $DIRECTION $CURRENCY_CODE offer with payment acct $ALICE_ACCT_ID."
|
||||
CMD="$CLI_BASE --port=$ALICE_PORT createoffer"
|
||||
CMD+=" --payment-account=$ALICE_ACCT_ID"
|
||||
CMD+=" --direction=$DIRECTION"
|
||||
CMD+=" --currency-code=$CURRENCY_CODE"
|
||||
CMD+=" --amount=$AMOUNT"
|
||||
if [ -z "$MKT_PRICE_MARGIN" ]; then
|
||||
CMD+=" --fixed-price=$FIXED_PRICE"
|
||||
else
|
||||
CMD+=" --market-price-margin=${MKT_PRICE_MARGIN}"
|
||||
CMD+=" --market-price-margin=$MKT_PRICE_MARGIN"
|
||||
fi
|
||||
CMD+=" --security-deposit=50.0"
|
||||
CMD+=" --fee-currency=BSQ"
|
||||
printdate "ALICE CLI: ${CMD}"
|
||||
OFFER_ID=$(createoffer "${CMD}")
|
||||
printdate "ALICE CLI: $CMD"
|
||||
OFFER_ID=$(createoffer "$CMD")
|
||||
exitoncommandalert $?
|
||||
printdate "ALICE: Created offer with id: ${OFFER_ID}."
|
||||
printdate "ALICE: Created offer with id: $OFFER_ID."
|
||||
printbreak
|
||||
sleeptraced 3
|
||||
|
||||
# Show Alice's new offer.
|
||||
printdate "ALICE: Looking at her new ${DIRECTION} ${CURRENCY_CODE} offer."
|
||||
CMD="$CLI_BASE --port=${ALICE_PORT} getmyoffer --offer-id=${OFFER_ID}"
|
||||
printdate "ALICE CLI: ${CMD}"
|
||||
printdate "ALICE: Looking at her new $DIRECTION $CURRENCY_CODE offer."
|
||||
CMD="$CLI_BASE --port=$ALICE_PORT getmyoffer --offer-id=$OFFER_ID"
|
||||
printdate "ALICE CLI: $CMD"
|
||||
OFFER=$($CMD)
|
||||
exitoncommandalert $?
|
||||
echo "${OFFER}"
|
||||
echo "$OFFER"
|
||||
printbreak
|
||||
sleeptraced 7
|
||||
|
||||
@ -149,11 +150,11 @@ printbreak
|
||||
sleeptraced 5
|
||||
|
||||
# Show Alice's offer in Bob's CLI.
|
||||
printdate "BOB: Looking at ${DIRECTION} ${CURRENCY_CODE} offers."
|
||||
CMD="$CLI_BASE --port=${BOB_PORT} getoffers --direction=${DIRECTION} --currency-code=${CURRENCY_CODE}"
|
||||
printdate "BOB CLI: ${CMD}"
|
||||
printdate "BOB: Looking at $DIRECTION $CURRENCY_CODE offers."
|
||||
CMD="$CLI_BASE --port=$BOB_PORT getoffers --direction=$DIRECTION --currency-code=$CURRENCY_CODE"
|
||||
printdate "BOB CLI: $CMD"
|
||||
OFFERS=$($CMD)
|
||||
exitoncommandalert $?
|
||||
echo "${OFFERS}"
|
||||
echo "$OFFERS"
|
||||
|
||||
exit 0
|
||||
|
@ -22,14 +22,14 @@ checksetup() {
|
||||
--registration-key=6ac43ea1df2a290c1c8391736aa42e4339c5cb4f110ff0257a13b63211977b7a"
|
||||
exit 1;
|
||||
}
|
||||
printdate "Checking ${APP_HOME} for some expected directories and files."
|
||||
if [ -d "${APP_HOME}/apitest" ]; then
|
||||
printdate "Checking $APP_HOME for some expected directories and files."
|
||||
if [ -d "$APP_HOME/apitest" ]; then
|
||||
printdate "Subproject apitest exists.";
|
||||
else
|
||||
printdate "Error: Subproject apitest not found, maybe because you are not running the script from the project root dir."
|
||||
exit 1
|
||||
fi
|
||||
if [ -f "${APP_HOME}/bisq-cli" ]; then
|
||||
if [ -f "$APP_HOME/bisq-cli" ]; then
|
||||
printdate "The bisq-cli script exists.";
|
||||
else
|
||||
printdate "Error: The bisq-cli script not found, maybe because you are not running the script from the project root dir."
|
||||
@ -181,12 +181,12 @@ parselimitorderopts() {
|
||||
|
||||
checkbitcoindrunning() {
|
||||
# There may be a '+' char in the path and we have to escape it for pgrep.
|
||||
if [[ ${APP_HOME} == *"+"* ]]; then
|
||||
ESCAPED_APP_HOME=$(escapepluschar "${APP_HOME}")
|
||||
if [[ $APP_HOME == *"+"* ]]; then
|
||||
ESCAPED_APP_HOME=$(escapepluschar "$APP_HOME")
|
||||
else
|
||||
ESCAPED_APP_HOME="${APP_HOME}"
|
||||
ESCAPED_APP_HOME="$APP_HOME"
|
||||
fi
|
||||
if pgrep -f "bitcoind -datadir=${ESCAPED_APP_HOME}/apitest/build/resources/main/Bitcoin-regtest" > /dev/null ; then
|
||||
if pgrep -f "bitcoind -datadir=$ESCAPED_APP_HOME/apitest/build/resources/main/Bitcoin-regtest" > /dev/null ; then
|
||||
printdate "The regtest bitcoind node is running on host."
|
||||
else
|
||||
printdate "Error: regtest bitcoind node is not running on host, exiting."
|
||||
@ -196,24 +196,24 @@ checkbitcoindrunning() {
|
||||
|
||||
printscriptparams() {
|
||||
if [ -n "${LIMIT_PRICE+1}" ]; then
|
||||
echo " LIMIT_PRICE = ${LIMIT_PRICE}"
|
||||
echo " LIMIT_PRICE = $LIMIT_PRICE"
|
||||
fi
|
||||
|
||||
echo " DIRECTION = ${DIRECTION}"
|
||||
echo " COUNTRY_CODE = ${COUNTRY_CODE}"
|
||||
echo " FIXED_PRICE = ${FIXED_PRICE}"
|
||||
echo " MKT_PRICE_MARGIN = ${MKT_PRICE_MARGIN}"
|
||||
echo " AMOUNT = ${AMOUNT}"
|
||||
echo " DIRECTION = $DIRECTION"
|
||||
echo " COUNTRY_CODE = $COUNTRY_CODE"
|
||||
echo " FIXED_PRICE = $FIXED_PRICE"
|
||||
echo " MKT_PRICE_MARGIN = $MKT_PRICE_MARGIN"
|
||||
echo " AMOUNT = $AMOUNT"
|
||||
|
||||
if [ -n "${BOB_ROLE+1}" ]; then
|
||||
echo " BOB_ROLE = ${BOB_ROLE}"
|
||||
echo " BOB_ROLE = $BOB_ROLE"
|
||||
fi
|
||||
|
||||
if [ -n "${ALICE_ROLE+1}" ]; then
|
||||
echo " ALICE_ROLE = ${ALICE_ROLE}"
|
||||
echo " ALICE_ROLE = $ALICE_ROLE"
|
||||
fi
|
||||
|
||||
if [ -n "${WAIT+1}" ]; then
|
||||
echo " WAIT = ${WAIT}"
|
||||
echo " WAIT = $WAIT"
|
||||
fi
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
# This file must be sourced by the main driver.
|
||||
|
||||
source "${APITEST_SCRIPTS_HOME}/trade-simulation-env.sh"
|
||||
source "$APITEST_SCRIPTS_HOME/trade-simulation-env.sh"
|
||||
|
||||
printdate() {
|
||||
echo "[$(date)] $@"
|
||||
@ -46,10 +46,10 @@ exitoncommandalert() {
|
||||
registerdisputeagents() {
|
||||
# Silently register dev dispute agents. It's easy to forget.
|
||||
REG_KEY="6ac43ea1df2a290c1c8391736aa42e4339c5cb4f110ff0257a13b63211977b7a"
|
||||
CMD="${CLI_BASE} --port=${ARBITRATOR_PORT} registerdisputeagent --dispute-agent-type=mediator --registration-key=${REG_KEY}"
|
||||
CMD="$CLI_BASE --port=$ARBITRATOR_PORT registerdisputeagent --dispute-agent-type=mediator --registration-key=$REG_KEY"
|
||||
SILENT=$($CMD)
|
||||
commandalert $? "Could not register dev/test mediator."
|
||||
CMD="${CLI_BASE} --port=${ARBITRATOR_PORT} registerdisputeagent --dispute-agent-type=refundagent --registration-key=${REG_KEY}"
|
||||
CMD="$CLI_BASE --port=$ARBITRATOR_PORT registerdisputeagent --dispute-agent-type=refundagent --registration-key=$REG_KEY"
|
||||
SILENT=$($CMD)
|
||||
commandalert $? "Could not register dev/test refundagent."
|
||||
# Do something with $SILENT to keep codacy happy.
|
||||
@ -59,7 +59,7 @@ registerdisputeagents() {
|
||||
getbtcoreaddress() {
|
||||
CMD="bitcoin-cli -regtest -rpcport=19443 -rpcuser=apitest -rpcpassword=apitest getnewaddress"
|
||||
NEW_ADDRESS=$($CMD)
|
||||
echo "${NEW_ADDRESS}"
|
||||
echo "$NEW_ADDRESS"
|
||||
}
|
||||
|
||||
genbtcblocks() {
|
||||
@ -74,7 +74,7 @@ genbtcblocks() {
|
||||
for i in $(seq -f "%02g" 1 "$NUM_BLOCKS")
|
||||
do
|
||||
NEW_BLOCK_HASH=$(genbtcblock "$CMD")
|
||||
printdate "Block Hash #$i:${NEW_BLOCK_HASH}"
|
||||
printdate "Block Hash #$i:$NEW_BLOCK_HASH"
|
||||
sleep "$SECONDS_BETWEEN_BLOCKS"
|
||||
done
|
||||
}
|
||||
@ -88,12 +88,12 @@ genbtcblock() {
|
||||
escapepluschar() {
|
||||
STRING="$1"
|
||||
NEW_STRING=$(echo "${STRING//+/\\+}")
|
||||
echo "${NEW_STRING}"
|
||||
echo "$NEW_STRING"
|
||||
}
|
||||
|
||||
printbalances() {
|
||||
PORT="$1"
|
||||
printcmd "${CLI_BASE} --port=${PORT} getbalance"
|
||||
printcmd "$CLI_BASE --port=$PORT getbalance"
|
||||
$CLI_BASE --port="$PORT" getbalance
|
||||
}
|
||||
|
||||
@ -102,54 +102,54 @@ getpaymentaccountmethods() {
|
||||
CMD_OUTPUT=$($CMD)
|
||||
commandalert $? "Could not get payment method ids."
|
||||
printdate "Payment Method IDs:"
|
||||
echo "${CMD_OUTPUT}"
|
||||
echo "$CMD_OUTPUT"
|
||||
}
|
||||
|
||||
getpaymentaccountform() {
|
||||
CMD="$1"
|
||||
CMD_OUTPUT=$($CMD)
|
||||
commandalert $? "Could not get new payment account form."
|
||||
echo "${CMD_OUTPUT}"
|
||||
echo "$CMD_OUTPUT"
|
||||
}
|
||||
|
||||
editpaymentaccountform() {
|
||||
COUNTRY_CODE="$1"
|
||||
CMD="python3 ${APITEST_SCRIPTS_HOME}/editf2faccountform.py $COUNTRY_CODE"
|
||||
CMD="python3 $APITEST_SCRIPTS_HOME/editf2faccountform.py $COUNTRY_CODE"
|
||||
CMD_OUTPUT=$($CMD)
|
||||
commandalert $? "Could not edit payment account form."
|
||||
printdate "Saved payment account form as ${F2F_ACCT_FORM}."
|
||||
printdate "Saved payment account form as $F2F_ACCT_FORM."
|
||||
}
|
||||
|
||||
getnewpaymentacctid() {
|
||||
CREATE_PAYMENT_ACCT_OUTPUT="$1"
|
||||
PAYMENT_ACCT_DETAIL=$(echo -e "${CREATE_PAYMENT_ACCT_OUTPUT}" | sed -n '3p')
|
||||
PAYMENT_ACCT_DETAIL=$(echo -e "$CREATE_PAYMENT_ACCT_OUTPUT" | sed -n '3p')
|
||||
ACCT_ID=$(echo -e "$PAYMENT_ACCT_DETAIL" | awk '{print $NF}')
|
||||
echo "${ACCT_ID}"
|
||||
echo "$ACCT_ID"
|
||||
}
|
||||
|
||||
getnewpaymentacctcurrency() {
|
||||
CREATE_PAYMENT_ACCT_OUTPUT="$1"
|
||||
PAYMENT_ACCT_DETAIL=$(echo -e "${CREATE_PAYMENT_ACCT_OUTPUT}" | sed -n '3p')
|
||||
PAYMENT_ACCT_DETAIL=$(echo -e "$CREATE_PAYMENT_ACCT_OUTPUT" | sed -n '3p')
|
||||
# This is brittle; it requires the account name field to have N words,
|
||||
# e.g, "Face to Face Payment Account" as defined in editf2faccountform.py.
|
||||
CURRENCY_CODE=$(echo -e "$PAYMENT_ACCT_DETAIL" | awk '{print $6}')
|
||||
echo "${CURRENCY_CODE}"
|
||||
echo "$CURRENCY_CODE"
|
||||
}
|
||||
|
||||
createpaymentacct() {
|
||||
CMD="$1"
|
||||
CMD_OUTPUT=$($CMD)
|
||||
commandalert $? "Could not create new payment account."
|
||||
echo "${CMD_OUTPUT}"
|
||||
echo "$CMD_OUTPUT"
|
||||
}
|
||||
|
||||
getpaymentaccounts() {
|
||||
PORT="$1"
|
||||
printcmd "${CLI_BASE} --port=${PORT} getpaymentaccts"
|
||||
printcmd "$CLI_BASE --port=$PORT getpaymentaccts"
|
||||
CMD="$CLI_BASE --port=$PORT getpaymentaccts"
|
||||
CMD_OUTPUT=$($CMD)
|
||||
commandalert $? "Could not get payment accounts."
|
||||
echo "${CMD_OUTPUT}"
|
||||
echo "$CMD_OUTPUT"
|
||||
}
|
||||
|
||||
createoffer() {
|
||||
@ -160,9 +160,9 @@ createoffer() {
|
||||
# return from this function now, passing the error status code to the caller.
|
||||
commandalert $? "Could not create offer."
|
||||
|
||||
OFFER_DETAIL=$(echo -e "${OFFER_DESC}" | sed -n '2p')
|
||||
NEW_OFFER_ID=$(echo -e "${OFFER_DETAIL}" | awk '{print $NF}')
|
||||
echo "${NEW_OFFER_ID}"
|
||||
OFFER_DETAIL=$(echo -e "$OFFER_DESC" | sed -n '2p')
|
||||
NEW_OFFER_ID=$(echo -e "$OFFER_DETAIL" | awk '{print $NF}')
|
||||
echo "$NEW_OFFER_ID"
|
||||
}
|
||||
|
||||
getcurrentprice() {
|
||||
|
@ -41,91 +41,91 @@
|
||||
|
||||
export APP_BASE_NAME=$(basename "$0")
|
||||
export APP_HOME=$(pwd -P)
|
||||
export APITEST_SCRIPTS_HOME="${APP_HOME}/apitest/scripts"
|
||||
export APITEST_SCRIPTS_HOME="$APP_HOME/apitest/scripts"
|
||||
|
||||
source "${APITEST_SCRIPTS_HOME}/trade-simulation-env.sh"
|
||||
source "${APITEST_SCRIPTS_HOME}/trade-simulation-utils.sh"
|
||||
source "$APITEST_SCRIPTS_HOME/trade-simulation-env.sh"
|
||||
source "$APITEST_SCRIPTS_HOME/trade-simulation-utils.sh"
|
||||
|
||||
checksetup
|
||||
parseopts "$@"
|
||||
|
||||
printdate "Started ${APP_BASE_NAME} with parameters:"
|
||||
printdate "Started $APP_BASE_NAME with parameters:"
|
||||
printscriptparams
|
||||
printbreak
|
||||
|
||||
registerdisputeagents
|
||||
|
||||
printdate "Alice looks for the ID of the face to face payment account method (Bob will use same payment method)."
|
||||
CMD="${CLI_BASE} --port=${ALICE_PORT} getpaymentmethods"
|
||||
printdate "ALICE CLI: ${CMD}"
|
||||
CMD="$CLI_BASE --port=$ALICE_PORT getpaymentmethods"
|
||||
printdate "ALICE CLI: $CMD"
|
||||
getpaymentaccountmethods "$CMD"
|
||||
printbreak
|
||||
|
||||
printdate "Alice uses the F2F payment method id to create a face to face payment account in country ${COUNTRY_CODE}."
|
||||
CMD="${CLI_BASE} --port=${ALICE_PORT} getpaymentacctform --payment-method-id=F2F"
|
||||
printdate "ALICE CLI: ${CMD}"
|
||||
printdate "Alice uses the F2F payment method id to create a face to face payment account in country $COUNTRY_CODE."
|
||||
CMD="$CLI_BASE --port=$ALICE_PORT getpaymentacctform --payment-method-id=F2F"
|
||||
printdate "ALICE CLI: $CMD"
|
||||
getpaymentaccountform "$CMD"
|
||||
printbreak
|
||||
|
||||
printdate "Bob & Alice edit their ${COUNTRY_CODE} payment account forms, and renames them to ${F2F_ACCT_FORM}"
|
||||
printdate "Bob & Alice edit their $COUNTRY_CODE payment account forms, and renames them to $F2F_ACCT_FORM"
|
||||
editpaymentaccountform "$COUNTRY_CODE"
|
||||
cat "${APITEST_SCRIPTS_HOME}/${F2F_ACCT_FORM}"
|
||||
cat "$APITEST_SCRIPTS_HOME/$F2F_ACCT_FORM"
|
||||
|
||||
# Remove the autogenerated json template because we are going to use one created by a python script in the next step.
|
||||
CMD="rm -v ${APP_HOME}/f2f_*.json"
|
||||
CMD="rm -v $APP_HOME/f2f_*.json"
|
||||
DELETE_JSON_TEMPLATE=$($CMD)
|
||||
printdate "$DELETE_JSON_TEMPLATE"
|
||||
printbreak
|
||||
|
||||
printdate "Bob and Alice create their face to face ${COUNTRY_CODE} payment accounts."
|
||||
CMD="${CLI_BASE} --port=${BOB_PORT} createpaymentacct --payment-account-form=${APITEST_SCRIPTS_HOME}/${F2F_ACCT_FORM}"
|
||||
printdate "BOB CLI: ${CMD}"
|
||||
CMD_OUTPUT=$(createpaymentacct "${CMD}")
|
||||
echo "${CMD_OUTPUT}"
|
||||
BOB_ACCT_ID=$(getnewpaymentacctid "${CMD_OUTPUT}")
|
||||
BOB_ACCT_CURRENCY_CODE=$(getnewpaymentacctcurrency "${CMD_OUTPUT}")
|
||||
printdate "BOB F2F payment-account-id = ${BOB_ACCT_ID}, currency-code = ${BOB_ACCT_CURRENCY_CODE}."
|
||||
printdate "Bob and Alice create their face to face $COUNTRY_CODE payment accounts."
|
||||
CMD="$CLI_BASE --port=$BOB_PORT createpaymentacct --payment-account-form=$APITEST_SCRIPTS_HOME/$F2F_ACCT_FORM"
|
||||
printdate "BOB CLI: $CMD"
|
||||
CMD_OUTPUT=$(createpaymentacct "$CMD")
|
||||
echo "$CMD_OUTPUT"
|
||||
BOB_ACCT_ID=$(getnewpaymentacctid "$CMD_OUTPUT")
|
||||
BOB_ACCT_CURRENCY_CODE=$(getnewpaymentacctcurrency "$CMD_OUTPUT")
|
||||
printdate "BOB F2F payment-account-id = $BOB_ACCT_ID, currency-code = $BOB_ACCT_CURRENCY_CODE."
|
||||
printbreak
|
||||
|
||||
CMD="${CLI_BASE} --port=${ALICE_PORT} createpaymentacct --payment-account-form=${APITEST_SCRIPTS_HOME}/${F2F_ACCT_FORM}"
|
||||
printdate "ALICE CLI: ${CMD}"
|
||||
CMD_OUTPUT=$(createpaymentacct "${CMD}")
|
||||
echo "${CMD_OUTPUT}"
|
||||
ALICE_ACCT_ID=$(getnewpaymentacctid "${CMD_OUTPUT}")
|
||||
ALICE_ACCT_CURRENCY_CODE=$(getnewpaymentacctcurrency "${CMD_OUTPUT}")
|
||||
printdate "ALICE F2F payment-account-id = ${ALICE_ACCT_ID}, currency-code = ${ALICE_ACCT_CURRENCY_CODE}."
|
||||
CMD="$CLI_BASE --port=$ALICE_PORT createpaymentacct --payment-account-form=$APITEST_SCRIPTS_HOME/$F2F_ACCT_FORM"
|
||||
printdate "ALICE CLI: $CMD"
|
||||
CMD_OUTPUT=$(createpaymentacct "$CMD")
|
||||
echo "$CMD_OUTPUT"
|
||||
ALICE_ACCT_ID=$(getnewpaymentacctid "$CMD_OUTPUT")
|
||||
ALICE_ACCT_CURRENCY_CODE=$(getnewpaymentacctcurrency "$CMD_OUTPUT")
|
||||
printdate "ALICE F2F payment-account-id = $ALICE_ACCT_ID, currency-code = $ALICE_ACCT_CURRENCY_CODE."
|
||||
printbreak
|
||||
|
||||
printdate "ALICE ${ALICE_ROLE}: Creating ${DIRECTION} ${ALICE_ACCT_CURRENCY_CODE} offer with payment acct ${ALICE_ACCT_ID}."
|
||||
printdate "ALICE $ALICE_ROLE: Creating $DIRECTION $ALICE_ACCT_CURRENCY_CODE offer with payment acct $ALICE_ACCT_ID."
|
||||
CURRENT_PRICE=$(getcurrentprice "$ALICE_PORT" "$ALICE_ACCT_CURRENCY_CODE")
|
||||
exitoncommandalert $?
|
||||
printdate "Current Market Price: $CURRENT_PRICE"
|
||||
CMD="$CLI_BASE --port=${ALICE_PORT} createoffer"
|
||||
CMD+=" --payment-account=${ALICE_ACCT_ID}"
|
||||
CMD+=" --direction=${DIRECTION}"
|
||||
CMD+=" --currency-code=${ALICE_ACCT_CURRENCY_CODE}"
|
||||
CMD+=" --amount=${AMOUNT}"
|
||||
if [ -z "${MKT_PRICE_MARGIN}" ]; then
|
||||
CMD+=" --fixed-price=${FIXED_PRICE}"
|
||||
CMD="$CLI_BASE --port=$ALICE_PORT createoffer"
|
||||
CMD+=" --payment-account=$ALICE_ACCT_ID"
|
||||
CMD+=" --direction=$DIRECTION"
|
||||
CMD+=" --currency-code=$ALICE_ACCT_CURRENCY_CODE"
|
||||
CMD+=" --amount=$AMOUNT"
|
||||
if [ -z "$MKT_PRICE_MARGIN" ]; then
|
||||
CMD+=" --fixed-price=$FIXED_PRICE"
|
||||
else
|
||||
CMD+=" --market-price-margin=${MKT_PRICE_MARGIN}"
|
||||
CMD+=" --market-price-margin=$MKT_PRICE_MARGIN"
|
||||
fi
|
||||
CMD+=" --security-deposit=15.0"
|
||||
CMD+=" --fee-currency=BSQ"
|
||||
printdate "ALICE CLI: ${CMD}"
|
||||
OFFER_ID=$(createoffer "${CMD}")
|
||||
printdate "ALICE CLI: $CMD"
|
||||
OFFER_ID=$(createoffer "$CMD")
|
||||
exitoncommandalert $?
|
||||
printdate "ALICE ${ALICE_ROLE}: Created offer with id: ${OFFER_ID}."
|
||||
printdate "ALICE $ALICE_ROLE: Created offer with id: $OFFER_ID."
|
||||
printbreak
|
||||
sleeptraced 3
|
||||
|
||||
# Show Alice's new offer.
|
||||
printdate "ALICE ${ALICE_ROLE}: Looking at her new ${DIRECTION} ${CURRENCY_CODE} offer."
|
||||
CMD="$CLI_BASE --port=${ALICE_PORT} getmyoffer --offer-id=${OFFER_ID}"
|
||||
printdate "ALICE CLI: ${CMD}"
|
||||
printdate "ALICE $ALICE_ROLE: Looking at her new $DIRECTION $CURRENCY_CODE offer."
|
||||
CMD="$CLI_BASE --port=$ALICE_PORT getmyoffer --offer-id=$OFFER_ID"
|
||||
printdate "ALICE CLI: $CMD"
|
||||
OFFER=$($CMD)
|
||||
exitoncommandalert $?
|
||||
echo "${OFFER}"
|
||||
echo "$OFFER"
|
||||
printbreak
|
||||
sleeptraced 7
|
||||
|
||||
@ -136,23 +136,23 @@ printbreak
|
||||
sleeptraced 10
|
||||
|
||||
# List offers.
|
||||
printdate "BOB ${BOB_ROLE}: Looking at ${DIRECTION} ${BOB_ACCT_CURRENCY_CODE} offers."
|
||||
CMD="$CLI_BASE --port=${BOB_PORT} getoffers --direction=${DIRECTION} --currency-code=${BOB_ACCT_CURRENCY_CODE}"
|
||||
printdate "BOB CLI: ${CMD}"
|
||||
printdate "BOB $BOB_ROLE: Looking at $DIRECTION $BOB_ACCT_CURRENCY_CODE offers."
|
||||
CMD="$CLI_BASE --port=$BOB_PORT getoffers --direction=$DIRECTION --currency-code=$BOB_ACCT_CURRENCY_CODE"
|
||||
printdate "BOB CLI: $CMD"
|
||||
OFFERS=$($CMD)
|
||||
exitoncommandalert $?
|
||||
echo "${OFFERS}"
|
||||
echo "$OFFERS"
|
||||
printbreak
|
||||
sleeptraced 3
|
||||
|
||||
# Take offer.
|
||||
printdate "BOB ${BOB_ROLE}: Taking offer ${OFFER_ID} with payment acct ${BOB_ACCT_ID}."
|
||||
CMD="$CLI_BASE --port=${BOB_PORT} takeoffer --offer-id=${OFFER_ID} --payment-account=${BOB_ACCT_ID} --fee-currency=bsq"
|
||||
printdate "BOB CLI: ${CMD}"
|
||||
printdate "BOB $BOB_ROLE: Taking offer $OFFER_ID with payment acct $BOB_ACCT_ID."
|
||||
CMD="$CLI_BASE --port=$BOB_PORT takeoffer --offer-id=$OFFER_ID --payment-account=$BOB_ACCT_ID --fee-currency=bsq"
|
||||
printdate "BOB CLI: $CMD"
|
||||
TRADE=$($CMD)
|
||||
commandalert $? "Could not take offer."
|
||||
|
||||
echo "${TRADE}"
|
||||
echo "$TRADE"
|
||||
printbreak
|
||||
sleeptraced 10
|
||||
|
||||
@ -163,45 +163,46 @@ printbreak
|
||||
sleeptraced 6
|
||||
|
||||
# Send payment sent and received messages.
|
||||
if [ "${DIRECTION}" = "BUY" ]
|
||||
if [ "$DIRECTION" = "BUY" ]
|
||||
then
|
||||
PAYER="ALICE ${ALICE_ROLE}"
|
||||
PAYER_PORT=${ALICE_PORT}
|
||||
PAYER="ALICE $ALICE_ROLE"
|
||||
PAYER_PORT=$ALICE_PORT
|
||||
PAYER_CLI="ALICE CLI"
|
||||
PAYEE="BOB ${BOB_ROLE}"
|
||||
PAYEE_PORT=${BOB_PORT}
|
||||
PAYEE="BOB $BOB_ROLE"
|
||||
PAYEE_PORT=$BOB_PORT
|
||||
PAYEE_CLI="BOB CLI"
|
||||
else
|
||||
PAYER="BOB ${BOB_ROLE}"
|
||||
PAYER_PORT=${BOB_PORT}
|
||||
PAYER="BOB $BOB_ROLE"
|
||||
PAYER_PORT=$BOB_PORT
|
||||
PAYER_CLI="BOB CLI"
|
||||
PAYEE="ALICE ${ALICE_ROLE}"
|
||||
PAYEE_PORT=${ALICE_PORT}
|
||||
PAYEE="ALICE $ALICE_ROLE"
|
||||
PAYEE_PORT=$ALICE_PORT
|
||||
PAYEE_CLI="ALICE CLI"
|
||||
fi
|
||||
|
||||
# Confirm payment started.
|
||||
printdate "${PAYER}: Sending fiat payment sent msg."
|
||||
CMD="$CLI_BASE --port=${PAYER_PORT} confirmpaymentstarted --trade-id=${OFFER_ID}"
|
||||
printdate "${PAYER_CLI}: ${CMD}"
|
||||
printdate "$PAYER: Sending fiat payment sent msg."
|
||||
CMD="$CLI_BASE --port=$PAYER_PORT confirmpaymentstarted --trade-id=$OFFER_ID"
|
||||
printdate "$PAYER_CLI: $CMD"
|
||||
SENT_MSG=$($CMD)
|
||||
commandalert $? "Could not send confirmpaymentstarted message."
|
||||
|
||||
printdate "${SENT_MSG}"
|
||||
printdate "$SENT_MSG"
|
||||
printbreak
|
||||
|
||||
sleeptraced 2
|
||||
printdate "Generating btc blocks after fiat payment sent msg."
|
||||
genbtcblocks 3 5
|
||||
sleeptraced 2
|
||||
printbreak
|
||||
|
||||
# Confirm payment received.
|
||||
printdate "${PAYEE}: Sending fiat payment received msg."
|
||||
CMD="$CLI_BASE --port=${PAYEE_PORT} confirmpaymentreceived --trade-id=${OFFER_ID}"
|
||||
printdate "${PAYEE_CLI}: ${CMD}"
|
||||
printdate "$PAYEE: Sending fiat payment received msg."
|
||||
CMD="$CLI_BASE --port=$PAYEE_PORT confirmpaymentreceived --trade-id=$OFFER_ID"
|
||||
printdate "$PAYEE_CLI: $CMD"
|
||||
RCVD_MSG=$($CMD)
|
||||
commandalert $? "Could not send confirmpaymentreceived message."
|
||||
printdate "${RCVD_MSG}"
|
||||
printdate "$RCVD_MSG"
|
||||
printbreak
|
||||
sleeptraced 4
|
||||
|
||||
@ -212,19 +213,19 @@ printbreak
|
||||
sleeptraced 3
|
||||
|
||||
# Complete the trade on the seller side.
|
||||
if [ "${DIRECTION}" = "BUY" ]
|
||||
if [ "$DIRECTION" = "BUY" ]
|
||||
then
|
||||
printdate "BOB ${BOB_ROLE}: Closing trade by keeping funds in Bisq wallet."
|
||||
CMD="$CLI_BASE --port=${BOB_PORT} keepfunds --trade-id=${OFFER_ID}"
|
||||
printdate "BOB CLI: ${CMD}"
|
||||
printdate "BOB $BOB_ROLE: Closing trade by keeping funds in Bisq wallet."
|
||||
CMD="$CLI_BASE --port=$BOB_PORT keepfunds --trade-id=$OFFER_ID"
|
||||
printdate "BOB CLI: $CMD"
|
||||
else
|
||||
printdate "ALICE (taker): Closing trade by keeping funds in Bisq wallet."
|
||||
CMD="$CLI_BASE --port=${ALICE_PORT} keepfunds --trade-id=${OFFER_ID}"
|
||||
printdate "ALICE CLI: ${CMD}"
|
||||
CMD="$CLI_BASE --port=$ALICE_PORT keepfunds --trade-id=$OFFER_ID"
|
||||
printdate "ALICE CLI: $CMD"
|
||||
fi
|
||||
KEEP_FUNDS_MSG=$($CMD)
|
||||
commandalert $? "Could close trade with keepfunds command."
|
||||
printdate "${KEEP_FUNDS_MSG}"
|
||||
printdate "$KEEP_FUNDS_MSG"
|
||||
sleeptraced 5
|
||||
printbreak
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user