WIP: coupons
This commit is contained in:
parent
f2e23e987c
commit
4202f88322
85
stack-orchestrator/config/go-nitro/create-nitro-channel.sh
Executable file
85
stack-orchestrator/config/go-nitro/create-nitro-channel.sh
Executable file
|
@ -0,0 +1,85 @@
|
|||
#!/bin/bash
|
||||
|
||||
CERC_NITRO_RPC_HOST=${CERC_NITRO_RPC_HOST:-localhost}
|
||||
CERC_NITRO_RPC_PORT=${CERC_NITRO_RPC_PORT:-4006}
|
||||
CERC_NITRO_USE_TLS=${CERC_NITRO_USE_TLS:-false}
|
||||
|
||||
address_to_fund=$1
|
||||
amount=$2
|
||||
create_payment_channel=${3:-false}
|
||||
|
||||
# Wait till chain endpoint is available
|
||||
retry_interval=5
|
||||
while true; do
|
||||
nc -z -w 1 "$CERC_NITRO_RPC_HOST" "$CERC_NITRO_RPC_PORT"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Nitro endpoint is available"
|
||||
break
|
||||
fi
|
||||
|
||||
echo "Nitro endpoint not yet available, retrying in $retry_interval seconds..."
|
||||
sleep $retry_interval
|
||||
done
|
||||
|
||||
if [[ "$amount" -gt 0 ]]; then
|
||||
nitro-rpc-client -h $CERC_NITRO_RPC_HOST \
|
||||
-p $CERC_NITRO_RPC_PORT \
|
||||
-s=$CERC_NITRO_USE_TLS \
|
||||
get-all-ledger-channels | \
|
||||
jq "[.[] | select(.Status == \"Open\") | select(.Balance.Them == \"$address_to_fund\")] | first" > \
|
||||
/tmp/lc.json
|
||||
|
||||
ledger_channel=$(jq -r '.ID' /tmp/lc.json 2>/dev/null | sed 's/^null$//')
|
||||
|
||||
if [[ -z "${ledger_channel}" ]]; then
|
||||
echo "Creating new ledger channel ..."
|
||||
nitro-rpc-client -h $CERC_NITRO_RPC_HOST \
|
||||
-p $CERC_NITRO_RPC_PORT \
|
||||
-s=$CERC_NITRO_USE_TLS \
|
||||
-n \
|
||||
direct-fund --amount $amount $address_to_fund
|
||||
|
||||
nitro-rpc-client -h $CERC_NITRO_RPC_HOST \
|
||||
-p $CERC_NITRO_RPC_PORT \
|
||||
-s=$CERC_NITRO_USE_TLS \
|
||||
get-all-ledger-channels | \
|
||||
jq "[.[] | select(.Status == \"Open\") | select(.Balance.Them == \"$address_to_fund\")] | first" > \
|
||||
/tmp/lc.json
|
||||
|
||||
ledger_channel=$(jq -r '.ID' /tmp/lc.json)
|
||||
fi
|
||||
|
||||
echo "LEDGER: $ledger_channel"
|
||||
|
||||
if [ "true" == "$create_payment_channel" ]; then
|
||||
nitro-rpc-client -h $CERC_NITRO_RPC_HOST \
|
||||
-p $CERC_NITRO_RPC_PORT \
|
||||
-s=$CERC_NITRO_USE_TLS \
|
||||
get-payment-channels-by-ledger $ledger_channel > \
|
||||
/tmp/pc.json
|
||||
|
||||
first_open_channel=$(jq '[.[] | select(.Status == "Open")] | first' /tmp/lc.json | sed 's/^null$//')
|
||||
|
||||
if [[ -z "$first_open_channel" ]]; then
|
||||
echo "Creating new payment channel ..."
|
||||
nitro-rpc-client -h $CERC_NITRO_RPC_HOST \
|
||||
-p $CERC_NITRO_RPC_PORT \
|
||||
-s=$CERC_NITRO_USE_TLS \
|
||||
-n \
|
||||
virtual-fund --amount $((amount/2)) $address_to_fund
|
||||
|
||||
nitro-rpc-client -h $CERC_NITRO_RPC_HOST \
|
||||
-p $CERC_NITRO_RPC_PORT \
|
||||
-s=$CERC_NITRO_USE_TLS \
|
||||
get-payment-channels-by-ledger $ledger_channel > \
|
||||
/tmp/lc.json
|
||||
|
||||
first_open_channel=$(jq '[.[] | select(.Status == "Open")] | first' /tmp/lc.json | sed 's/^null$//')
|
||||
fi
|
||||
echo "PAYMENT: $first_open_channel"
|
||||
fi
|
||||
|
||||
rm -f /tmp/pc.json /tmp/lc.json
|
||||
|
||||
fi
|
26
stack-orchestrator/config/nitro-auth/dan.env
Normal file
26
stack-orchestrator/config/nitro-auth/dan.env
Normal file
|
@ -0,0 +1,26 @@
|
|||
# SET ME! Your on-chain private key.
|
||||
#CERC_NITRO_CHAIN_PK=<MY_PK_GOES_HERE>
|
||||
|
||||
# Default is CERC_NITRO_CHAIN_PK.
|
||||
#CERC_NITRO_PK=<MY_PK_GOES_HERE>
|
||||
|
||||
# SET ME! The WebSocket to connect to.
|
||||
#CERC_NITRO_CHAIN_URL=wss://linea-sepolia.infura.io/ws/v3/<MY_API_KEY_GOES_HERE>
|
||||
|
||||
CERC_NITRO_AUTH_ON=false
|
||||
CERC_NITRO_AUTH_RPC_PORT=4009
|
||||
CERC_NITRO_AUTH_UI_PORT=4209
|
||||
|
||||
CERC_NITRO_COUPON_ON=true
|
||||
CERC_NITRO_AUTO_CREATE_LEDGER_ADDRESS=${CERC_NITRO_CHAIN_BOB_ADDRESS:-0xe22ad83a0de117ba0d03d5e94eb4e0d80a69c62a}
|
||||
CERC_NITRO_AUTO_CREATE_LEDGER_AMOUNT=100000000
|
||||
|
||||
CERC_NITRO_BOOT_PEERS="/dns4/go-nitro-bootnode/tcp/3008/p2p/16Uiu2HAmFYz5YPf3GtkfQsAwYJfDsKSm34U9qAiTwxW7RJUVGMRK"
|
||||
CERC_NITRO_DURABLE_STORE_FOLDER=/app/data/nitro-store
|
||||
CERC_NITRO_MSG_PORT=3009
|
||||
CERC_NITRO_RPC_PORT=4009
|
||||
CERC_NITRO_UI_PORT=4109
|
||||
CERC_NITRO_USE_DURABLE_STORE=true
|
||||
CERC_NITRO_WS_MSG_PORT=5009
|
||||
CERC_NITRO_MSG_PUBLIC_IP=127.0.0.1
|
||||
CERC_NITRO_MSG_PUBLIC_PORT=5009
|
Loading…
Reference in New Issue
Block a user