Compare commits

...

4 Commits

Author SHA1 Message Date
Keyan
4675a2c29d
sndev cleanup (#1563)
* begin sndev cleanup

* cleanup sndev

* fix posix shell compliance

* add tests to sndev
2024-11-09 15:52:04 -06:00
Keyan
c31cf97288
fix precedence of op for not full hot sort (#1564) 2024-11-09 14:25:52 -06:00
ekzyis
d06f4ae70d
Fix offcanvas not closed before showing logout prompt (#1561) 2024-11-09 14:00:36 -06:00
ekzyis
afb71012af
Only send push notification if referrer was updated (#1562) 2024-11-09 14:00:07 -06:00
13 changed files with 236 additions and 282 deletions

View File

@ -138,13 +138,13 @@ LND_PUBKEY=02cb2e2d5a6c5b17fa67b1a883e2973c82e328fb9bd08b2b156a9e23820c87a490
# stacker lnd container stuff # stacker lnd container stuff
STACKER_LND_REST_PORT=8081 STACKER_LND_REST_PORT=8081
STACKER_LND_GRPC_PORT=10010 STACKER_LND_GRPC_PORT=10010
# docker exec -u lnd stacker_lnd lncli newaddress p2wkh --unused # docker exec -u lnd lnd lncli newaddress p2wkh --unused
STACKER_LND_ADDR=bcrt1qfqau4ug9e6rtrvxrgclg58e0r93wshucumm9vu STACKER_LND_ADDR=bcrt1qfqau4ug9e6rtrvxrgclg58e0r93wshucumm9vu
STACKER_LND_PUBKEY=028093ae52e011d45b3e67f2e0f2cb6c3a1d7f88d2920d408f3ac6db3a56dc4b35 STACKER_LND_PUBKEY=028093ae52e011d45b3e67f2e0f2cb6c3a1d7f88d2920d408f3ac6db3a56dc4b35
# stacker cln container stuff # stacker cln container stuff
STACKER_CLN_REST_PORT=9092 STACKER_CLN_REST_PORT=9092
# docker exec -u clightning stacker_cln lightning-cli newaddr bech32 # docker exec -u clightning cln lightning-cli newaddr bech32
STACKER_CLN_ADDR=bcrt1q02sqd74l4pxedy24fg0qtjz4y2jq7x4lxlgzrx STACKER_CLN_ADDR=bcrt1q02sqd74l4pxedy24fg0qtjz4y2jq7x4lxlgzrx
STACKER_CLN_PUBKEY=03ca7acec181dbf5e427c682c4261a46a0dd9ea5f35d97acb094e399f727835b90 STACKER_CLN_PUBKEY=03ca7acec181dbf5e427c682c4261a46a0dd9ea5f35d97acb094e399f727835b90

View File

@ -76,16 +76,12 @@ COMMANDS
sn: sn:
login login as a nym login login as a nym
fund_user fund a nym without using an LN invoice set_balance set the balance of a nym
lnd: lightning:
fund pay a bolt11 for funding fund pay a bolt11 for funding
withdraw create a bolt11 for withdrawal withdraw create a bolt11 for withdrawal
cln:
cln_fund pay a bolt11 for funding with CLN
cln_withdraw create a bolt11 for withdrawal with CLN
db: db:
psql open psql on db psql open psql on db
prisma run prisma commands prisma run prisma commands
@ -93,15 +89,14 @@ COMMANDS
dev: dev:
pr fetch and checkout a pr pr fetch and checkout a pr
lint run linters lint run linters
open open container url in browser test run tests
other: other:
cli service cli passthrough
open open service GUI in browser
onion service onion address
cert service tls cert
compose docker compose passthrough compose docker compose passthrough
sn_lndcli lncli passthrough on sn_lnd
stacker_lndcli lncli passthrough on stacker_lnd
stacker_clncli lightning-cli passthrough on stacker_cln
stacker_litcli litcli passthrough on litd
``` ```
### Modifying services ### Modifying services
@ -368,9 +363,11 @@ You can connect to the local database via `./sndev psql`. [psql](https://www.pos
<br> <br>
## Running lncli on the local lnd nodes ## Running cli on local lightning nodes
You can run `lncli` on the local lnd nodes via `./sndev sn_lncli` and `./sndev stacker_lncli`. The node for your local SN instance is `sn_lnd` and the node serving as any external node, like a stacker's node or external wallet, is `stacker_lnd`. You can run `lncli` on the local lnd nodes via `./sndev cli lnd` and `./sndev cli sn_lnd`. The node for your local SN instance is `sn_lnd` and the node serving as any external node, like a stacker's node or external wallet, is `lnd`.
You can run `lightning-cli` on the local cln node via `./sndev cli cln` which serves as an external node or wallet.
<br> <br>

View File

@ -115,11 +115,11 @@ const orderByClause = (by, me, models, type) => {
} }
export function orderByNumerator ({ models, commentScaler = 0.5, considerBoost = false }) { export function orderByNumerator ({ models, commentScaler = 0.5, considerBoost = false }) {
return `(CASE WHEN "Item"."weightedVotes" - "Item"."weightedDownVotes" > 0 THEN return `((CASE WHEN "Item"."weightedVotes" - "Item"."weightedDownVotes" > 0 THEN
GREATEST("Item"."weightedVotes" - "Item"."weightedDownVotes", POWER("Item"."weightedVotes" - "Item"."weightedDownVotes", 1.2)) GREATEST("Item"."weightedVotes" - "Item"."weightedDownVotes", POWER("Item"."weightedVotes" - "Item"."weightedDownVotes", 1.2))
ELSE ELSE
"Item"."weightedVotes" - "Item"."weightedDownVotes" "Item"."weightedVotes" - "Item"."weightedDownVotes"
END + "Item"."weightedComments"*${commentScaler}) + ${considerBoost ? `("Item".boost / ${BOOST_MULT})` : 0}` END + "Item"."weightedComments"*${commentScaler}) + ${considerBoost ? `("Item".boost / ${BOOST_MULT})` : 0})`
} }
export function joinZapRankPersonalView (me, models) { export function joinZapRankPersonalView (me, models) {

View File

@ -317,6 +317,7 @@ export function LogoutDropdownItem ({ handleClose }) {
</Dropdown.Item> </Dropdown.Item>
<Dropdown.Item <Dropdown.Item
onClick={async () => { onClick={async () => {
handleClose?.()
showModal(onClose => (<LogoutObstacle onClose={onClose} />)) showModal(onClose => (<LogoutObstacle onClose={onClose} />))
}} }}
>logout >logout

View File

@ -275,7 +275,7 @@ services:
echo "Creating wallet and address..." echo "Creating wallet and address..."
bitcoin-cli createwallet "" bitcoin-cli createwallet ""
nodes+=($$(bitcoin-cli getnewaddress)) nodes+=($$(bitcoin-cli getnewaddress))
echo "Mining 100 blocks to sn_lnd, stacker_lnd, stacker_cln..." echo "Mining 100 blocks to sn_lnd, lnd, cln..."
for addr in "$${nodes[@]}"; do for addr in "$${nodes[@]}"; do
bitcoin-cli generatetoaddress 100 $$addr bitcoin-cli generatetoaddress 100 $$addr
echo "Mining 100 blocks to a random address..." echo "Mining 100 blocks to a random address..."
@ -349,6 +349,8 @@ services:
volumes: volumes:
- sn_lnd:/home/lnd/.lnd - sn_lnd:/home/lnd/.lnd
labels: labels:
CLI: "lncli"
CLI_USER: "lnd"
ofelia.enabled: "true" ofelia.enabled: "true"
ofelia.job-exec.sn_channel_cron.schedule: "@every 1m" ofelia.job-exec.sn_channel_cron.schedule: "@every 1m"
ofelia.job-exec.sn_channel_cron.command: > ofelia.job-exec.sn_channel_cron.command: >
@ -356,17 +358,17 @@ services:
if [ $$(lncli getinfo | jq '.num_active_channels + .num_pending_channels') -ge 3 ]; then if [ $$(lncli getinfo | jq '.num_active_channels + .num_pending_channels') -ge 3 ]; then
exit 0 exit 0
else else
lncli openchannel --node_key=$STACKER_LND_PUBKEY --connect stacker_lnd:9735 --sat_per_vbyte 1 \\ lncli openchannel --node_key=$STACKER_LND_PUBKEY --connect lnd:9735 --sat_per_vbyte 1 \\
--min_confs 0 --local_amt=1000000000 --push_amt=500000000 --min_confs 0 --local_amt=1000000000 --push_amt=500000000
fi fi
" "
cpu_shares: "${CPU_SHARES_MODERATE}" cpu_shares: "${CPU_SHARES_MODERATE}"
stacker_lnd: lnd:
build: build:
context: ./docker/lnd context: ./docker/lnd
args: args:
- LN_NODE_FOR=stacker - LN_NODE_FOR=stacker
container_name: stacker_lnd container_name: lnd
restart: unless-stopped restart: unless-stopped
profiles: profiles:
- payments - payments
@ -384,9 +386,9 @@ services:
- 'lnd' - 'lnd'
- '--noseedbackup' - '--noseedbackup'
- '--trickledelay=5000' - '--trickledelay=5000'
- '--alias=stacker_lnd' - '--alias=lnd'
- '--externalip=stacker_lnd' - '--externalip=lnd'
- '--tlsextradomain=stacker_lnd' - '--tlsextradomain=lnd'
- '--tlsextradomain=host.docker.internal' - '--tlsextradomain=host.docker.internal'
- '--tlsextradomain=$${ONION_DOMAIN}' - '--tlsextradomain=$${ONION_DOMAIN}'
- '--listen=0.0.0.0:9735' - '--listen=0.0.0.0:9735'
@ -413,12 +415,16 @@ services:
- "${STACKER_LND_REST_PORT}:8080" - "${STACKER_LND_REST_PORT}:8080"
- "${STACKER_LND_GRPC_PORT}:10009" - "${STACKER_LND_GRPC_PORT}:10009"
volumes: volumes:
- stacker_lnd:/home/lnd/.lnd - lnd:/home/lnd/.lnd
- tordata:/home/lnd/.tor - tordata:/home/lnd/.tor
labels: labels:
TORDIR: "/home/lnd/.tor"
CERTDIR: "/home/lnd/.lnd"
CLI: "lncli"
CLI_USER: "lnd"
ofelia.enabled: "true" ofelia.enabled: "true"
ofelia.job-exec.stacker_lnd_channel_cron.schedule: "@every 1m" ofelia.job-exec.lnd_channel_cron.schedule: "@every 1m"
ofelia.job-exec.stacker_lnd_channel_cron.command: > ofelia.job-exec.lnd_channel_cron.command: >
su lnd -c bash -c " su lnd -c bash -c "
if [ $$(lncli getinfo | jq '.num_active_channels + .num_pending_channels') -ge 3 ]; then if [ $$(lncli getinfo | jq '.num_active_channels + .num_pending_channels') -ge 3 ]; then
exit 0 exit 0
@ -439,11 +445,11 @@ services:
<<: *healthcheck <<: *healthcheck
test: ["CMD", "curl", "-f", "http://localhost:8443"] test: ["CMD", "curl", "-f", "http://localhost:8443"]
depends_on: depends_on:
stacker_lnd: lnd:
condition: service_healthy condition: service_healthy
restart: true restart: true
volumes: volumes:
- stacker_lnd:/lnd - lnd:/lnd
ports: ports:
- "8443:8443" - "8443:8443"
command: command:
@ -454,7 +460,7 @@ services:
- '--lnd-mode=remote' - '--lnd-mode=remote'
- '--network=regtest' - '--network=regtest'
- '--remote.lit-debuglevel=debug' - '--remote.lit-debuglevel=debug'
- '--remote.lnd.rpcserver=stacker_lnd:10009' - '--remote.lnd.rpcserver=lnd:10009'
- '--remote.lnd.macaroonpath=/lnd/data/chain/bitcoin/regtest/admin.macaroon' - '--remote.lnd.macaroonpath=/lnd/data/chain/bitcoin/regtest/admin.macaroon'
- '--remote.lnd.tlscertpath=/lnd/tls.cert' - '--remote.lnd.tlscertpath=/lnd/tls.cert'
- '--autopilot.disable' - '--autopilot.disable'
@ -462,11 +468,13 @@ services:
- '--loop.server.host=test.swap.lightning.today:11010' - '--loop.server.host=test.swap.lightning.today:11010'
labels: labels:
CONNECT: "localhost:8443" CONNECT: "localhost:8443"
CLI: "litcli"
CLI_ARGS: "-n regtest --rpcserver localhost:8444"
cpu_shares: "${CPU_SHARES_MODERATE}" cpu_shares: "${CPU_SHARES_MODERATE}"
stacker_cln: cln:
build: build:
context: ./docker/cln context: ./docker/cln
container_name: stacker_cln container_name: cln
restart: unless-stopped restart: unless-stopped
profiles: profiles:
- payments - payments
@ -482,7 +490,7 @@ services:
command: command:
- 'lightningd' - 'lightningd'
- '--network=regtest' - '--network=regtest'
- '--alias=stacker_cln' - '--alias=cln'
- '--bitcoin-rpcconnect=bitcoin' - '--bitcoin-rpcconnect=bitcoin'
- '--bitcoin-rpcuser=${RPC_USER}' - '--bitcoin-rpcuser=${RPC_USER}'
- '--bitcoin-rpcpassword=${RPC_PASS}' - '--bitcoin-rpcpassword=${RPC_PASS}'
@ -495,12 +503,16 @@ services:
ports: ports:
- "${STACKER_CLN_REST_PORT}:3010" - "${STACKER_CLN_REST_PORT}:3010"
volumes: volumes:
- stacker_cln:/home/clightning/.lightning - cln:/home/clightning/.lightning
- tordata:/home/clightning/.tor - tordata:/home/clightning/.tor
labels: labels:
TORDIR: "/home/clightning/.tor"
CLI: "lightning-cli"
CLI_USER: "clightning"
CLI_ARGS: "--regtest"
ofelia.enabled: "true" ofelia.enabled: "true"
ofelia.job-exec.stacker_cln_channel_cron.schedule: "@every 1m" ofelia.job-exec.cln_channel_cron.schedule: "@every 1m"
ofelia.job-exec.stacker_cln_channel_cron.command: > ofelia.job-exec.cln_channel_cron.command: >
su clightning -c bash -c " su clightning -c bash -c "
if [ $$(lightning-cli --regtest getinfo | jq '.num_active_channels + .num_pending_channels') -ge 3 ]; then if [ $$(lightning-cli --regtest getinfo | jq '.num_active_channels + .num_pending_channels') -ge 3 ]; then
exit 0 exit 0
@ -519,8 +531,8 @@ services:
depends_on: depends_on:
- bitcoin - bitcoin
- sn_lnd - sn_lnd
- stacker_lnd - lnd
- stacker_cln - cln
restart: unless-stopped restart: unless-stopped
command: daemon --docker -f label=com.docker.compose.project=${COMPOSE_PROJECT_NAME} command: daemon --docker -f label=com.docker.compose.project=${COMPOSE_PROJECT_NAME}
volumes: volumes:
@ -550,12 +562,12 @@ services:
- wallets - wallets
restart: unless-stopped restart: unless-stopped
depends_on: depends_on:
stacker_lnd: lnd:
condition: service_healthy condition: service_healthy
restart: true restart: true
volumes: volumes:
- nwc_send:/app - nwc_send:/app
- stacker_lnd:/app/.lnd - lnd:/app/.lnd
environment: environment:
- RUST_LOG=info - RUST_LOG=info
entrypoint: entrypoint:
@ -567,7 +579,7 @@ services:
- '--cert-file' - '--cert-file'
- '/app/.lnd/tls.cert' - '/app/.lnd/tls.cert'
- '--lnd-host' - '--lnd-host'
- 'stacker_lnd' - 'lnd'
- '--lnd-port' - '--lnd-port'
- '10009' - '10009'
- '--max-amount' - '--max-amount'
@ -584,12 +596,12 @@ services:
- wallets - wallets
restart: unless-stopped restart: unless-stopped
depends_on: depends_on:
stacker_lnd: lnd:
condition: service_healthy condition: service_healthy
restart: true restart: true
volumes: volumes:
- nwc_recv:/app - nwc_recv:/app
- stacker_lnd:/app/.lnd - lnd:/app/.lnd
environment: environment:
- RUST_LOG=info - RUST_LOG=info
entrypoint: entrypoint:
@ -601,7 +613,7 @@ services:
- '--cert-file' - '--cert-file'
- '/app/.lnd/tls.cert' - '/app/.lnd/tls.cert'
- '--lnd-host' - '--lnd-host'
- 'stacker_lnd' - 'lnd'
- '--lnd-port' - '--lnd-port'
- '10009' - '10009'
- '--max-amount' - '--max-amount'
@ -624,29 +636,30 @@ services:
tor: tor:
condition: service_healthy condition: service_healthy
restart: true restart: true
stacker_lnd: lnd:
condition: service_healthy condition: service_healthy
restart: true restart: true
environment: environment:
- LNBITS_ADMIN_UI=true - LNBITS_ADMIN_UI=true
- LNBITS_BACKEND_WALLET_CLASS=LndWallet - LNBITS_BACKEND_WALLET_CLASS=LndWallet
- LND_GRPC_ENDPOINT=stacker_lnd - LND_GRPC_ENDPOINT=lnd
- LND_GRPC_PORT=10009 - LND_GRPC_PORT=10009
- LND_GRPC_CERT=/app/.lnd/tls.cert - LND_GRPC_CERT=/app/.lnd/tls.cert
- LND_GRPC_MACAROON=/app/.lnd/data/chain/bitcoin/regtest/admin.macaroon - LND_GRPC_MACAROON=/app/.lnd/data/chain/bitcoin/regtest/admin.macaroon
volumes: volumes:
- stacker_lnd:/app/.lnd - lnd:/app/.lnd
- tordata:/app/.tor - tordata:/app/.tor
labels: labels:
CONNECT: "localhost:${LNBITS_WEB_PORT}" CONNECT: "localhost:${LNBITS_WEB_PORT}"
TORDIR: "/app/.tor"
cpu_shares: "${CPU_SHARES_LOW}" cpu_shares: "${CPU_SHARES_LOW}"
volumes: volumes:
db: db:
os: os:
bitcoin: bitcoin:
sn_lnd: sn_lnd:
stacker_lnd: lnd:
stacker_cln: cln:
s3: s3:
nwc_send: nwc_send:
nwc_recv: nwc_recv:

View File

@ -1,3 +1,3 @@
HiddenServicePort 10009 stacker_lnd:10009 HiddenServicePort 10009 lnd:10009
HiddenServicePort 3010 stacker_cln:3010 HiddenServicePort 3010 cln:3010
HiddenServicePort 5000 lnbits:5000 HiddenServicePort 5000 lnbits:5000

View File

@ -21,9 +21,9 @@ function mergeServices {
cat /services.conf >> /tordata/torrc cat /services.conf >> /tordata/torrc
} }
# There is a circular dependency between tor and stacker_lnd: # There is a circular dependency between tor and lnd:
# <-> tor needs stacker_lnd to be running to resolve the hidden service target # <-> tor needs lnd to be running to resolve the hidden service target
# <-> stacker_lnd needs to wait for tor to start and generate the hidden service address # <-> lnd needs to wait for tor to start and generate the hidden service address
# Afaik there isn't an "official" solution for this issue. # Afaik there isn't an "official" solution for this issue.
# #
# This workaround starts tor the first time without the lnd hidden service # This workaround starts tor the first time without the lnd hidden service

View File

@ -77,8 +77,8 @@ function getCallbacks (req, res) {
if (req.cookies.sn_referrer && user?.id) { if (req.cookies.sn_referrer && user?.id) {
const referrerId = await getReferrerId(req.cookies.sn_referrer) const referrerId = await getReferrerId(req.cookies.sn_referrer)
if (referrerId && referrerId !== parseInt(user?.id)) { if (referrerId && referrerId !== parseInt(user?.id)) {
await prisma.user.updateMany({ where: { id: user.id, referrerId: null }, data: { referrerId } }) const { count } = await prisma.user.updateMany({ where: { id: user.id, referrerId: null }, data: { referrerId } })
notifyReferral(referrerId) if (count > 0) notifyReferral(referrerId)
} }
} }
} }

369
sndev
View File

@ -32,46 +32,6 @@ docker__exec() {
DOCKER_CLI_HINTS=false command docker exec -i "$@" DOCKER_CLI_HINTS=false command docker exec -i "$@"
} }
docker__sn_lnd() {
t=$1
if [ "$t" = "-t" ]; then
shift
else
t=""
fi
docker__exec $t -u lnd sn_lnd lncli "$@"
}
docker__stacker_lnd() {
t=$1
if [ "$t" = "-t" ]; then
shift
else
t=""
fi
docker__exec $t -u lnd stacker_lnd lncli "$@"
}
docker__stacker_cln() {
t=$1
if [ "$t" = "-t" ]; then
shift
else
t=""
fi
if [ "$1" = "get_onion" ]; then
onion="$(docker__exec $t stacker_cln cat /home/clightning/.tor/hidden_service/hostname | tr -d '[:space:]')"
echo "$onion:3010"
exit 0
fi
docker__exec $t -u clightning stacker_cln lightning-cli --regtest "$@"
}
sndev__start() { sndev__start() {
shift shift
@ -232,38 +192,41 @@ USAGE
echo "$help" echo "$help"
} }
sndev__fund_user() { sndev__set_balance() {
shift shift
if [ -z "$1" ]; then if [ -z "$1" ]; then
echo "<nym> argument required" echo "NYM argument required"
sndev__help_fund_user sndev__help_set_balance
exit 1 exit 1
fi fi
if [ -z "$2" ]; then if [ -z "$2" ]; then
echo "<msats> argument required" echo "MSATS argument required"
sndev__help_fund_user sndev__help_set_balance
exit 2 exit 2
fi fi
re='^[0-9]+$'
if ! [[ $2 =~ $re ]]; then if ! echo "$2" | grep -qE "^[0-9]+$"; then
echo "<msats> is not a positive integer" echo "MSATS argument is not a positive integer"
sndev__help_fund_user sndev__help_set_balance
exit 3 exit 3
fi fi
docker__exec db psql -U sn -d stackernews -q <<EOF docker__exec db psql -U sn -d stackernews -q <<EOF
UPDATE users set msats = $2 where name = '$1'; UPDATE users set msats = $2 where name = '$1';
EOF EOF
} }
sndev__help_fund_user() { sndev__help_set_balance() {
help=" help="
fund a nym without using an LN invoice (local only) set the balance of a nym
USAGE USAGE
$ sndev fund_user <nym> <msats> $ sndev set_balance NYM MSATS
<nym> - the name of the user you want to fund NYM - the name of the user you want to set the balance of
<msats> - the amount of millisatoshis to set the account to. Must be >= 0 MSATS - the amount of millisatoshis to set the account to. Must be >= 0
" "
echo "$help" echo "$help"
@ -271,7 +234,12 @@ USAGE
sndev__fund() { sndev__fund() {
shift shift
docker__stacker_lnd -t payinvoice "$@" if [ "$1" = "--cln" ]; then
shift
sndev__cli -t cln pay "$@"
else
sndev__cli -t lnd payinvoice "$@"
fi
} }
sndev__help_fund() { sndev__help_fund() {
@ -279,46 +247,24 @@ help="
pay a bolt11 for funding pay a bolt11 for funding
USAGE USAGE
$ sndev fund <bolt11> [OPTIONS] $ sndev fund BOLT11 [OPTIONS]
$ sndev fund --cln BOLT11
OPTIONS" OPTIONS"
echo "$help" echo "$help"
docker__stacker_lnd payinvoice -h | awk '/OPTIONS:/{y=1;next}y' | awk '!/^[\t ]+--pay_req value/' sndev__cli lnd payinvoice -h | awk '/OPTIONS:/{y=1;next}y' | awk '!/^[\t ]+--pay_req value/'
}
sndev__cln_fund() {
shift
docker__stacker_cln -t pay "$@"
}
sndev__help_cln_fund() {
help="
pay a bolt11 for funding with CLN
USAGE
$ sndev cln_fund <bolt11>"
echo "$help"
}
sndev__cln_withdraw() {
shift
label=$(date +%s)
docker__stacker_cln -t invoice "$1" "$label" sndev | jq -r '.bolt11'
}
sndev__help_cln_withdraw() {
help="
create a bolt11 for withdrawal with CLN
USAGE
$ sndev cln_withdraw <amount msats>"
echo "$help"
} }
sndev__withdraw() { sndev__withdraw() {
shift shift
docker__stacker_lnd addinvoice --amt "$@" | jq -r '.payment_request' if [ "$1" = "--cln" ]; then
shift
label=$(date +%s)
sndev__cli -t cln invoice "$1" "$label" sndev | jq -j '.bolt11'; echo
else
sndev__cli lnd addinvoice --amt "$@" | jq -j '.payment_request'; echo
fi
} }
sndev__help_withdraw() { sndev__help_withdraw() {
@ -326,12 +272,13 @@ sndev__help_withdraw() {
create a bolt11 for withdrawal create a bolt11 for withdrawal
USAGE USAGE
$ sndev withdraw <amount sats> [OPTIONS] $ sndev withdraw SATS [OPTIONS]
$ sndev withdraw --cln SATS
OPTIONS" OPTIONS"
echo "$help" echo "$help"
docker__stacker_lnd addinvoice -h | awk '/OPTIONS:/{y=1;next}y' | awk '!/^[\t ]+(--amt|--amt_msat) value/' sndev__cli lnd addinvoice -h | awk '/OPTIONS:/{y=1;next}y' | awk '!/^[\t ]+(--amt|--amt_msat) value/'
} }
sndev__psql() { sndev__psql() {
@ -387,6 +334,30 @@ USAGE
echo "$help" echo "$help"
} }
sndev__test() {
shift
args=""
if [ $# -gt 0 ]; then
args="-- $@"
fi
docker__exec -t -u apprunner app npm run test $args
}
sndev__help_test() {
help="
run tests
USAGE
$ sndev test [OPTIONS]
OPTIONS"
echo "$help"
docker__exec -u apprunner app npm run test -- --help | awk '/Options:/{y=1;next}y'
}
sndev__compose() { sndev__compose() {
shift shift
docker__compose "$@" docker__compose "$@"
@ -396,45 +367,6 @@ sndev__help_compose() {
docker__compose --help docker__compose --help
} }
sndev__sn_lndcli() {
shift
docker__sn_lnd -t "$@"
}
sndev__help_sn_lndcli() {
docker__sn_lnd --help
}
sndev__stacker_lndcli() {
shift
docker__stacker_lnd -t "$@"
}
sndev__help_stacker_lndcli() {
docker__stacker_lnd --help
}
sndev__stacker_clncli() {
shift
docker__stacker_cln -t "$@"
}
sndev__help_stacker_clncli() {
docker__stacker_cln help
echo
echo "EXTRA:"
echo " get_onion get the onion address"
}
sndev__stacker_litcli() {
shift
docker__exec -t litd litcli -n regtest --rpcserver localhost:8444 "$@"
}
sndev__help_stacker_litcli() {
docker__exec -t litd litcli -h
}
__sndev__pr_track() { __sndev__pr_track() {
json=$(curl -fsSH "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/stackernews/stacker.news/pulls/$1") json=$(curl -fsSH "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/stackernews/stacker.news/pulls/$1")
case $(git config --get remote.origin.url) in case $(git config --get remote.origin.url) in
@ -484,7 +416,7 @@ sndev__help_pr() {
fetch and checkout a pr fetch and checkout a pr
USAGE USAGE
$ sndev pr [OPTIONS] <pr number> $ sndev pr [OPTIONS] PR_NUMBER
OPTIONS OPTIONS
-t, --track track the pr in a new branch, creating a remote if necessary -t, --track track the pr in a new branch, creating a remote if necessary
@ -497,7 +429,7 @@ OPTIONS
sndev__login() { sndev__login() {
shift shift
if [ -z "$1" ]; then if [ -z "$1" ]; then
echo "<nym> argument required" echo "NYM argument required"
sndev__help_login sndev__help_login
exit 1 exit 1
fi fi
@ -528,84 +460,102 @@ sndev__help_login() {
login as a nym login as a nym
USAGE USAGE
$ sndev login <nym> $ sndev login NYM
" "
echo "$help" echo "$help"
} }
sndev__help_stacker_lnd() { sndev__onion() {
help="
USAGE
$ sndev stacker_lnd get_cert get the tls cert
$ sndev stacker_lnd get_onion get the onion address
"
echo "$help"
}
sndev__stacker_lnd() {
shift shift
if [ -z "$1" ]; then tordir=$(docker__compose ps $1 --format '{{.Label "TORDIR"}}')
echo "no command provided" if [ -z "$tordir" ]; then
sndev__help_stacker_lnd echo "no TORDIR label found for $1"
exit 1 exit 1
fi fi
if [ "$1" = "get_cert" ]; then onion=$(docker__exec $1 cat $tordir/hidden_service/hostname | tr -d '[:space:]')
echo $(docker__exec -t stacker_lnd openssl base64 -A -in /home/lnd/.lnd/tls.cert)
elif [ "$1" = "get_onion" ];
then
onion="$(docker__exec -t stacker_lnd cat /home/lnd/.tor/hidden_service/hostname | tr -d '[:space:]')"
echo "$onion:10009"
fi
}
sndev__help_lnbits() {
help="
USAGE
$ sndev stacker_lnbits get_onion get the onion address
"
}
sndev__lnbits() {
shift
if [ -z "$1" ]; then
echo "no command provided"
sndev__help_lnbits
exit 1
fi
if [ "$1" = "get_onion" ];
then
onion="$(docker__exec -t lnbits cat /app/.tor/hidden_service/hostname | tr -d '[:space:]')"
echo "$onion:5000"
fi
}
sndev__help_tor() {
help="
USAGE
$ sndev tor get_onion get the onion address
"
echo "$help"
}
sndev__tor() {
shift
if [ -z "$1" ]; then
echo "no command provided"
sndev__help_tor
exit 1
fi
if [ "$1" = "get_onion" ];
then
onion="$(docker__exec -t stacker_lnd cat /home/lnd/.tor/hidden_service/hostname | tr -d '[:space:]')"
echo "$onion" echo "$onion"
}
sndev__help_onion() {
help="
get the onion address of a service
USAGE
$ sndev onion SERVICE
"
echo "$help"
}
sndev__cert() {
shift
certdir=$(docker__compose ps $1 --format '{{.Label "CERTDIR"}}')
if [ -z "$certdir" ]; then
echo "no CERTDIR label found for $1"
exit 1
fi fi
docker__exec $1 cat $certdir/tls.cert | base64
}
sndev__help_cert() {
help="
get the tls cert of a service
USAGE
$ sndev cert SERVICE
"
echo "$help"
}
sndev__cli() {
t=$1
if [ "$t" = "-t" ]; then
shift
else
t=""
fi
if [ "$1" = "cli" ]; then
shift
fi
if [ -z "$1" ]; then
echo "SERVICE required"
sndev__help_cli
exit 1
fi
service=$1
cli=$(docker__compose ps $service --format '{{.Label "CLI"}}')
cli_user=$(docker__compose ps $service --format '{{.Label "CLI_USER"}}')
cli_args=$(docker__compose ps $service --format '{{.Label "CLI_ARGS"}}')
if [ -z "$cli" ]; then
echo "no CLI label found for $service"
exit 1
fi
shift
if [ -n "$cli_user" ]; then
cli_user="-u $cli_user"
fi
docker__exec $t $cli_user $service $cli $cli_args "$@"
}
sndev__help_cli() {
help="
run a cli command on a service
USAGE
$ sndev cli SERVICE [COMMAND [ARGS]]
"
echo "$help"
} }
sndev__help() { sndev__help() {
@ -643,16 +593,12 @@ COMMANDS
sn: sn:
login login as a nym login login as a nym
fund_user fund a nym without using an LN invoice set_balance set the balance of a nym
lnd: lightning:
fund pay a bolt11 for funding fund pay a bolt11 for funding
withdraw create a bolt11 for withdrawal withdraw create a bolt11 for withdrawal
cln:
cln_fund pay a bolt11 for funding with CLN
cln_withdraw create a bolt11 for withdrawal with CLN
db: db:
psql open psql on db psql open psql on db
prisma run prisma commands prisma run prisma commands
@ -660,19 +606,14 @@ COMMANDS
dev: dev:
pr fetch and checkout a pr pr fetch and checkout a pr
lint run linters lint run linters
open open container url in browser test run tests
other: other:
cli service cli passthrough
open open service GUI in browser
onion service onion address
cert service tls cert
compose docker compose passthrough compose docker compose passthrough
sn_lndcli lncli passthrough on sn_lnd
stacker_lndcli lncli passthrough on stacker_lnd
stacker_clncli lightning-cli passthrough on stacker_cln
stacker_litcli litcli passthrough on litd
tor get_onion get the onion address
stacker_lnd get_cert get the tls cert
stacker_lnd get_onion get the onion address
stacker_clncli get_onion get the onion address
lndbits get_onion get the onion address
" "
echo "$help" echo "$help"
} }

View File

@ -2,20 +2,20 @@ For testing cln as an attached receiving wallet, you'll need a rune and the cert
# host and port # host and port
`stacker_cln:3010` `cln:3010`
# host and port (onion) # host and port (onion)
Run: Run:
```bash ```bash
sndev stacker_clncli get_onion sndev onion cln
``` ```
# create rune # create rune
```bash ```bash
sndev stacker_clncli --regtest createrune restrictions='["method=invoice"]' sndev cli cln --regtest createrune restrictions='["method=invoice"]'
``` ```
# get cert # get cert

View File

@ -21,7 +21,7 @@ Or simply copy the keys from here:
( These keys can be found under `Node URL, API keys and API docs`. ) ( These keys can be found under `Node URL, API keys and API docs`. )
To use the same URL to connect to LNbits in the browser and server during local development, `localhost:<port>` is mapped to `lnbits:5000` on the server. To use the same URL to connect to LNbits in the browser and server during local development, `http://localhost:<port>` is mapped to `http://lnbits:5000` on the server.
# tor onion url # tor onion url
@ -29,5 +29,5 @@ To use the same URL to connect to LNbits in the browser and server during local
Run the following command to get the onion url: Run the following command to get the onion url:
```bash ```bash
sndev lnbits get_onion sndev onion lnbits
``` ```

View File

@ -2,20 +2,22 @@ For testing lnd as an attached receiving wallet, you'll need a macaroon and the
# host and port # host and port
`stacker_lnd:10009` `lnd:10009`
## host and port (onion) ## host and port (onion)
To get the onion address run this command: To get the onion address run this command:
```bash ```bash
sndev stacker_lnd get_onion sndev onion lnd
``` ```
Then use port 10009 on the onion address.
# generate macaroon # generate macaroon
```bash ```bash
sndev stacker_lndcli -n regtest bakemacaroon invoices:write invoices:read sndev cli lnd -n regtest bakemacaroon invoices:write invoices:read
``` ```
# get cert # get cert
@ -23,5 +25,5 @@ sndev stacker_lndcli -n regtest bakemacaroon invoices:write invoices:read
To get the cert run this command: To get the cert run this command:
```bash ```bash
sndev stacker_lnd get_cert sndev cert lnd
``` ```

View File

@ -1,4 +1,4 @@
Using webln will require installing the alby browser extension and connecting it to an alby hub connected to `stacker_lnd`. Using webln will require installing the alby browser extension and connecting it to an alby hub connected to `lnd`.
1. Install the [Alby browser extensions](https://chromewebstore.google.com/detail/alby-bitcoin-wallet-for-l/iokeahhehimjnekafflcihljlcjccdbe?pli=1) 1. Install the [Alby browser extensions](https://chromewebstore.google.com/detail/alby-bitcoin-wallet-for-l/iokeahhehimjnekafflcihljlcjccdbe?pli=1)
2. Create an Alby account 2. Create an Alby account