fix: cause a transaction-broadcast to fail if we can't get the unconfirmed nonce for some reason, and log the commands we use to generate the transaction

This commit is contained in:
Jude Nelson
2021-05-25 19:46:18 -04:00
parent 880b283fcf
commit 1c9a458900

View File

@@ -195,12 +195,13 @@ easy_token_transfer() {
local ADDR="$(blockstack-cli --testnet addresses "$PRIVKEY" | jq -r '.STX')"
local NONCE="$(get_unconfirmed_account_nonce "$STACKS_NODE_URL" "$ADDR")"
local RC=$?
if [ $RC -ne 0 ]; then
logln "Failed to query unconfirmed account nonce: rc $RC"
if [ $RC -ne 0 ] || [ -z "$NONCE" ]; then
logln "Failed to query unconfirmed account nonce: rc '$RC' nonce '$NONCE'"
return 1
fi
local MEMO="test $NONCE"
logln "blockstack-cli --testnet token-transfer '$PRIVKEY' '$FEE_RATE' '$NONCE' '$DEST' '$AMOUNT' '$MEMO' '$OPTS'"
local TX="$(blockstack-cli --testnet token-transfer "$PRIVKEY" "$FEE_RATE" "$NONCE" "$DEST" "$AMOUNT" "$MEMO" "$OPTS" 2>&1)"
RC=$?
if [ $RC -ne 0 ]; then
@@ -208,6 +209,7 @@ easy_token_transfer() {
return 1
fi
logln "Generated tx: $TX"
printf "$TX"
return 0
}