#!/usr/bin/env bash set -Eeuo pipefail trap cleanup SIGINT SIGTERM ERR EXIT cleanup() { trap - SIGINT SIGTERM ERR EXIT # script cleanup here } script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) . "$script_dir/common.sh" usage() { cat < wallet must be locked before we can exit msg_error "No address found - aborting." else msg_success "Successfully fetched new funding address $address" fi # -------------------------- # Lock wallet # -------------------------- msg "Locking wallet '$wallet_name'" lock_result=$(lock_wallet "$base_url" "$auth_header" "$wallet_name") msg_success "Successfully locked wallet '$wallet_name'." # In case an address could not be fetched, exit hard now. [ "$address" = "null" ] && die "No address found." # -------------------------- # Mine the actual blocks # -------------------------- # generate new blocks with rewards to wallet msg "Generating $blocks blocks with rewards to $address" . "$script_dir/mine-block.sh" "$blocks" "$address" &>/dev/null if [ "$unmatured" = true ]; then msg_warn "Block rewards are not yet matured and will not be immediately spendable" else msg "Generating another 100 blocks to make block rewards spendable.." # make the generated coinbase spendable (not mining the new coinbases to an address controlled by the wallet on purpose!) . "$script_dir/mine-block.sh" 100 &>/dev/null fi msg_success "Successfully generated $blocks blocks with rewards to $address"