|
2 | 2 | #
|
3 | 3 | # Various bash helper fns which aren't used enough to move to just recipes.
|
4 | 4 |
|
5 |
| -# This can be used to simplify ssh sessions, rsync, ex: |
6 |
| -# ssh -o "$(ssm-proxy-cmd "$REGION")" "$INSTANCE_ID" |
7 |
| -ssm-proxy-cmd() { |
8 |
| - echo "ProxyCommand=sh -c 'aws --region $1 ssm start-session --target %h --document-name AWS-StartSSHSession --parameters portNumber=%p'" |
9 |
| -} |
10 |
| - |
11 |
| - |
12 | 5 | # A handy transaction submission function with mempool monitoring.
|
13 | 6 | # CARDANO_NODE_{NETWORK_ID,SOCKET_PATH}, TESTNET_MAGIC should already be exported.
|
14 | 7 | submit() (
|
@@ -206,3 +199,30 @@ return-utxo() (
|
206 | 199 |
|
207 | 200 | submit "$BASENAME.signed"
|
208 | 201 | )
|
| 202 | + |
| 203 | +# A handy faucet submission function with mempool monitoring, usable on custom networks. |
| 204 | +# CARDANO_NODE_{NETWORK_ID,SOCKET_PATH}, TESTNET_MAGIC should already be exported. |
| 205 | +# SEND_ADDR, LOVELACE, RICH_ADDR and RICH vars need to be provided. |
| 206 | +faucet() ( |
| 207 | + SEND_ADDR="$1" |
| 208 | + LOVELACE="$2" |
| 209 | + |
| 210 | + UTXOS=$(cardano-cli query utxo --address "$RICH_ADDR") |
| 211 | + UTXO=$(jq -r 'to_entries | max_by(.value.value.lovelace) | { (.key): .value }' <<< "$UTXOS") |
| 212 | + UTXO_TX=$(jq -r 'keys[0]' <<< "$UTXO") |
| 213 | + |
| 214 | + cardano-cli latest transaction build \ |
| 215 | + --tx-in "$UTXO_TX" \ |
| 216 | + --tx-out "$SEND_ADDR+$LOVELACE" \ |
| 217 | + --change-address "$RICH_ADDR" \ |
| 218 | + --testnet-magic "$TESTNET_MAGIC" \ |
| 219 | + --out-file faucet.txbody |
| 220 | + |
| 221 | + cardano-cli latest transaction sign \ |
| 222 | + --tx-body-file faucet.txbody \ |
| 223 | + --signing-key-file "$RICH.skey" \ |
| 224 | + --testnet-magic "$TESTNET_MAGIC" \ |
| 225 | + --out-file faucet.txsigned |
| 226 | + |
| 227 | + submit faucet.txsigned |
| 228 | +) |
0 commit comments