diff --git a/bats/core/api/ln-receive.bats b/bats/core/api/ln-receive.bats new file mode 100644 index 0000000000..6e906111a6 --- /dev/null +++ b/bats/core/api/ln-receive.bats @@ -0,0 +1,380 @@ +#!/usr/bin/env bats + +load "../../helpers/cli.bash" +load "../../helpers/user.bash" +load "../../helpers/onchain.bash" +load "../../helpers/ln.bash" +load "../../helpers/wallet.bash" +load "../../helpers/callback.bash" +load "../../helpers/subscriber.bash" + +setup_file() { + lnds_init + + create_user 'alice' + user_update_username 'alice' + fund_user_onchain 'alice' 'btc_wallet' + fund_user_onchain 'alice' 'usd_wallet' + add_callback 'alice' + + fund_user_lightning 'alice' 'btc_wallet' '500000' + + subscribe_to 'alice' my-updates-sub + sleep 3 +} + +btc_amount=1000 +usd_amount=50 + +@test "ln-receive: settle via ln for BTC wallet, invoice with amount" { + btc_wallet_name="alice.btc_wallet_id" + + # Check callback events before + exec_graphql "alice" 'account-details' + account_id="$(graphql_output '.data.me.defaultAccount.id')" + [[ "$account_id" != "null" ]] || exit 1 + + start_callback + num_callback_events_before=$(cat $CALLBACK_LOG_FILE | grep "$account_id" | wc -l) + + # Generate invoice + variables=$( + jq -n \ + --arg wallet_id "$(read_value $btc_wallet_name)" \ + --arg amount "$btc_amount" \ + '{input: {walletId: $wallet_id, amount: $amount}}' + ) + exec_graphql "alice" 'ln-invoice-create' "$variables" + invoice="$(graphql_output '.data.lnInvoiceCreate.invoice')" + + payment_request="$(echo $invoice | jq -r '.paymentRequest')" + [[ "${payment_request}" != "null" ]] || exit 1 + payment_hash="$(echo $invoice | jq -r '.paymentHash')" + [[ "${payment_hash}" != "null" ]] || exit 1 + + # Get invoice by hash + variables=$( + jq -n \ + --arg wallet_id "$(read_value $btc_wallet_name)" \ + --arg payment_hash "$payment_hash" \ + '{walletId: $wallet_id, paymentHash: $payment_hash}' + ) + exec_graphql "alice" 'invoice-for-wallet-by-payment-hash' "$variables" + query_payment_hash="$(graphql_output '.data.me.defaultAccount.walletById.invoiceByPaymentHash.paymentHash')" + invoice_status="$(graphql_output '.data.me.defaultAccount.walletById.invoiceByPaymentHash.paymentStatus')" + [[ "${query_payment_hash}" == "${payment_hash}" ]] || exit 1 + [[ "${invoice_status}" == "PENDING" ]] || exit 1 + + # Receive payment + lnd_outside_cli payinvoice -f \ + --pay_req "$payment_request" + + # Check for settled + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" + + # Check for subscriber event + check_for_ln_update "$payment_hash" || exit 1 + + # Get transaction by hash + variables=$( + jq -n \ + --arg wallet_id "$(read_value $btc_wallet_name)" \ + --arg payment_hash "$payment_hash" \ + '{walletId: $wallet_id, paymentHash: $payment_hash}' + ) + + exec_graphql "alice" 'transactions-for-wallet-by-payment-hash' "$variables" + query_payment_hash="$(graphql_output '.data.me.defaultAccount.walletById.transactionsByPaymentHash[0].initiationVia.paymentHash')" + [[ "${query_payment_hash}" == "${payment_hash}" ]] || exit 1 + transaction_id="$(graphql_output '.data.me.defaultAccount.walletById.transactionsByPaymentHash[0].id')" + + # Get transaction by tx id + variables=$( + jq -n \ + --arg wallet_id "$(read_value $btc_wallet_name)" \ + --arg transaction_id "$transaction_id" \ + '{walletId: $wallet_id, transactionId: $transaction_id}' + ) + exec_graphql "alice" 'transaction-for-wallet-by-id' "$variables" + query_transaction_id="$(graphql_output '.data.me.defaultAccount.walletById.transactionById.id')" + [[ "${query_transaction_id}" == "${transaction_id}" ]] || exit 1 + + # Ensure invoice status is paid + variables=$( + jq -n \ + --arg wallet_id "$(read_value $btc_wallet_name)" \ + --arg payment_hash "$payment_hash" \ + '{walletId: $wallet_id, paymentHash: $payment_hash}' + ) + exec_graphql "alice" 'invoice-for-wallet-by-payment-hash' "$variables" + invoice_status="$(graphql_output '.data.me.defaultAccount.walletById.invoiceByPaymentHash.paymentStatus')" + [[ "${invoice_status}" == "PAID" ]] || exit 1 + + # Check for callback + num_callback_events_after=$(cat $CALLBACK_LOG_FILE | grep "$account_id" | wc -l) + [[ "$num_callback_events_after" -gt "$num_callback_events_before" ]] || exit 1 + + stop_callback +} + +@test "ln-receive: settle via ln for USD wallet, invoice with amount" { + # Generate invoice + usd_wallet_name="alice.usd_wallet_id" + + variables=$( + jq -n \ + --arg wallet_id "$(read_value $usd_wallet_name)" \ + --arg amount "$usd_amount" \ + '{input: {walletId: $wallet_id, amount: $amount}}' + ) + exec_graphql "alice" 'ln-usd-invoice-create' "$variables" + invoice="$(graphql_output '.data.lnUsdInvoiceCreate.invoice')" + + payment_request="$(echo $invoice | jq -r '.paymentRequest')" + [[ "${payment_request}" != "null" ]] || exit 1 + payment_hash="$(echo $invoice | jq -r '.paymentHash')" + [[ "${payment_hash}" != "null" ]] || exit 1 + + # Receive payment + lnd_outside_cli payinvoice -f \ + --pay_req "$payment_request" + + # Check for settled + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" + + # Check for subscriber event + check_for_ln_update "$payment_hash" || exit 1 +} + +@test "ln-receive: settle via ln for BTC wallet, amountless invoice" { + btc_wallet_name="alice.btc_wallet_id" + + # Generate invoice + variables=$( + jq -n \ + --arg wallet_id "$(read_value $btc_wallet_name)" \ + '{input: {walletId: $wallet_id}}' + ) + exec_graphql "alice" 'ln-no-amount-invoice-create' "$variables" + invoice="$(graphql_output '.data.lnNoAmountInvoiceCreate.invoice')" + + payment_request="$(echo $invoice | jq -r '.paymentRequest')" + [[ "${payment_request}" != "null" ]] || exit 1 + payment_hash="$(echo $invoice | jq -r '.paymentHash')" + [[ "${payment_hash}" != "null" ]] || exit 1 + + # Receive payment + lnd_outside_cli payinvoice -f \ + --pay_req "$payment_request" \ + --amt "$btc_amount" + + # Check for settled + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" + + # Check for subscriber event + check_for_ln_update "$payment_hash" || exit 1 +} + +@test "ln-receive: handle less-than-1-sat ln payment for BTC wallet" { + btc_wallet_name="alice.btc_wallet_id" + + # Generate amountless invoice + invoice_variables=$( + jq -n \ + --arg wallet_id "$(read_value $btc_wallet_name)" \ + '{input: {walletId: $wallet_id}}' + ) + exec_graphql "alice" 'ln-no-amount-invoice-create' "$invoice_variables" + invoice="$(graphql_output '.data.lnNoAmountInvoiceCreate.invoice')" + + payment_request="$(echo $invoice | jq -r '.paymentRequest')" + [[ "${payment_request}" != "null" ]] || exit 1 + payment_hash="$(echo $invoice | jq -r '.paymentHash')" + [[ "${payment_hash}" != "null" ]] || exit 1 + + # Check that invoice is retrievable from lnd1 + invoice_from_lnd=$(lnd_cli lookupinvoice "$payment_hash") + [[ -n $invoice_from_lnd ]] || exit 1 + + # Receive less-than-1-sat payment + pay_variables=$( + jq -n \ + --arg payment_request "$payment_request" \ + --arg amt_msat "995" \ + --arg timeout_seconds "5" \ + '{payment_request: $payment_request, amt_msat: $amt_msat, timeout_seconds: $timeout_seconds}'\ + | tr -d '[:space:]') + lnd_outside_rest "v2/router/send" "$pay_variables" + + # Check that payment fails + response=$(tail -n 1 "$LNDS_REST_LOG") + [[ -n $response ]] || exit 1 + pay_status=$(echo $response | jq -r '.result.status') + [[ "$pay_status" == "FAILED" ]] || exit 1 + failure_reason=$(echo $response | jq -r '.result.failure_reason') + [[ "$failure_reason" == "FAILURE_REASON_INCORRECT_PAYMENT_DETAILS" ]] || exit 1 + + # Check that invoice is removed from lnd1 + invoice_from_lnd=$(lnd_cli lookupinvoice "$payment_hash") || true + [[ -z $invoice_from_lnd ]] || exit 1 +} + +@test "ln-receive: settle via ln for USD wallet, amountless invoice" { + # Generate invoice + usd_wallet_name="alice.usd_wallet_id" + + variables=$( + jq -n \ + --arg wallet_id "$(read_value $usd_wallet_name)" \ + '{input: {walletId: $wallet_id}}' + ) + exec_graphql "alice" 'ln-no-amount-invoice-create' "$variables" + invoice="$(graphql_output '.data.lnNoAmountInvoiceCreate.invoice')" + + payment_request="$(echo $invoice | jq -r '.paymentRequest')" + [[ "${payment_request}" != "null" ]] || exit 1 + payment_hash="$(echo $invoice | jq -r '.paymentHash')" + [[ "${payment_hash}" != "null" ]] || exit 1 + + # Receive payment + lnd_outside_cli payinvoice -f \ + --pay_req "$payment_request" \ + --amt "$btc_amount" + + # Check for settled + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" + + # Check for subscriber event + check_for_ln_update "$payment_hash" || exit 1 +} + +@test "ln-receive: settles btc-wallet invoices created while trigger down" { + token_name="$ALICE_TOKEN_NAME" + btc_wallet_name="alice.btc_wallet_id" + + # Stop trigger + # stop_trigger + + # Generate invoice + variables=$( + jq -n \ + --arg wallet_id "$(read_value $btc_wallet_name)" \ + '{input: {walletId: $wallet_id}}' + ) + exec_graphql "alice" 'ln-no-amount-invoice-create' "$variables" + invoice="$(graphql_output '.data.lnNoAmountInvoiceCreate.invoice')" + + payment_request="$(echo $invoice | jq -r '.paymentRequest')" + [[ "${payment_request}" != "null" ]] || exit 1 + payment_hash="$(echo $invoice | jq -r '.paymentHash')" + [[ "${payment_hash}" != "null" ]] || exit 1 + + # Start trigger + # start_trigger + sleep 5 + + # Pay invoice & check for settled + lnd_outside_cli payinvoice -f \ + --pay_req "$payment_request" \ + --amt "$btc_amount" + + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" +} + +@test "ln-receive: settles usd-wallet invoices created while trigger down" { + usd_wallet_name="alice.usd_wallet_id" + + # Stop trigger + # stop_trigger + + # Generate invoice + variables=$( + jq -n \ + --arg wallet_id "$(read_value $usd_wallet_name)" \ + '{input: {walletId: $wallet_id}}' + ) + exec_graphql "alice" 'ln-no-amount-invoice-create' "$variables" + invoice="$(graphql_output '.data.lnNoAmountInvoiceCreate.invoice')" + + payment_request="$(echo $invoice | jq -r '.paymentRequest')" + [[ "${payment_request}" != "null" ]] || exit 1 + payment_hash="$(echo $invoice | jq -r '.paymentHash')" + [[ "${payment_hash}" != "null" ]] || exit 1 + + # Start trigger + # start_trigger + sleep 5 + + # Pay invoice & check for settled + lnd_outside_cli payinvoice -f \ + --pay_req "$payment_request" \ + --amt "$btc_amount" + + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" +} + +@test "ln-receive: settles btc-wallet invoices created & paid while trigger down" { + btc_wallet_name="alice.btc_wallet_id" + + # Stop trigger + # stop_trigger + + # Generate invoice + variables=$( + jq -n \ + --arg wallet_id "$(read_value $btc_wallet_name)" \ + '{input: {walletId: $wallet_id}}' + ) + exec_graphql "alice" 'ln-no-amount-invoice-create' "$variables" + invoice="$(graphql_output '.data.lnNoAmountInvoiceCreate.invoice')" + + payment_request="$(echo $invoice | jq -r '.paymentRequest')" + [[ "${payment_request}" != "null" ]] || exit 1 + payment_hash="$(echo $invoice | jq -r '.paymentHash')" + [[ "${payment_hash}" != "null" ]] || exit 1 + + # Pay invoice + lnd_outside_cli payinvoice -f \ + --pay_req "$payment_request" \ + --amt "$btc_amount" \ + & + + # Start trigger + # start_trigger + + # Check for settled + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" +} + +@test "ln-receive: settles usd-wallet invoices created & paid while trigger down" { + usd_wallet_name="alice.usd_wallet_id" + + # Stop trigger + # stop_trigger + + # Generate invoice + variables=$( + jq -n \ + --arg wallet_id "$(read_value $usd_wallet_name)" \ + '{input: {walletId: $wallet_id}}' + ) + exec_graphql "alice" 'ln-no-amount-invoice-create' "$variables" + invoice="$(graphql_output '.data.lnNoAmountInvoiceCreate.invoice')" + + payment_request="$(echo $invoice | jq -r '.paymentRequest')" + [[ "${payment_request}" != "null" ]] || exit 1 + payment_hash="$(echo $invoice | jq -r '.paymentHash')" + [[ "${payment_hash}" != "null" ]] || exit 1 + + # Pay invoice + lnd_outside_cli payinvoice -f \ + --pay_req "$payment_request" \ + --amt "$btc_amount" \ + & + + # Start trigger + # start_trigger + + # Check for settled + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" +} diff --git a/core/api/test/bats/ln-send.bats b/bats/core/api/ln-send.bats similarity index 69% rename from core/api/test/bats/ln-send.bats rename to bats/core/api/ln-send.bats index fa6aafe62b..bfb1ca5ff5 100644 --- a/core/api/test/bats/ln-send.bats +++ b/bats/core/api/ln-send.bats @@ -1,72 +1,33 @@ #!/usr/bin/env bats -load "helpers/setup-and-teardown" -load "helpers/ln" +load "../../helpers/cli.bash" +load "../../helpers/user.bash" +load "../../helpers/onchain.bash" +load "../../helpers/ln.bash" +load "../../helpers/wallet.bash" setup_file() { - clear_cache - - bitcoind_init - start_trigger - start_server - start_exporter - lnds_init - initialize_user_from_onchain "$ALICE_TOKEN_NAME" "$ALICE_PHONE" "$CODE" - user_update_username "$ALICE_TOKEN_NAME" - initialize_user_from_onchain "$BOB_TOKEN_NAME" "$BOB_PHONE" "$CODE" -} -teardown_file() { - stop_trigger - stop_server - stop_exporter -} + create_user 'alice' + user_update_username 'alice' + fund_user_onchain 'alice' 'btc_wallet' + fund_user_onchain 'alice' 'usd_wallet' -setup() { - reset_redis -} + create_user 'bob' + user_update_username 'bob' + fund_user_onchain 'bob' 'btc_wallet' + fund_user_onchain 'bob' 'usd_wallet' -teardown() { - if [[ "$(balance_for_check)" != 0 ]]; then - fail "Error: balance_for_check failed" - fi -} - -amount_sent_for_ln_txn_by_hash() { - token_name="$1" - payment_hash="$2" - - first=20 - txn_variables=$( - jq -n \ - --argjson first "$first" \ - '{"first": $first}' - ) - exec_graphql "$token_name" 'transactions' "$txn_variables" > /dev/null - - jq_query=' - [ - .data.me.defaultAccount.transactions.edges[] - | select(.node.initiationVia.paymentHash == $payment_hash) - | select(.node.direction == "SEND") - ] - | first .node.settlementAmount - ' - local amount=$(echo $output \ - | jq -r \ - --arg payment_hash "$payment_hash" \ - "$jq_query" - ) - abs $amount + fund_user_lightning 'alice' 'btc_wallet' '500000' + fund_user_lightning 'bob' 'btc_wallet' '500000' } btc_amount=1000 usd_amount=50 @test "ln-send: lightning settled - lnInvoicePaymentSend from btc" { - token_name="$ALICE_TOKEN_NAME" - btc_wallet_name="$token_name.btc_wallet_id" + btc_wallet_name="alice.btc_wallet_id" initial_lnd1_balance=$(lnd_cli channelbalance | jq -r '.balance') @@ -82,16 +43,16 @@ usd_amount=50 '{input: {walletId: $wallet_id, paymentRequest: $payment_request}}' ) - exec_graphql "$token_name" 'ln-invoice-fee-probe' "$variables" + exec_graphql "alice" 'ln-invoice-fee-probe' "$variables" fee_amount="$(graphql_output '.data.lnInvoiceFeeProbe.amount')" [[ "${fee_amount}" = "0" ]] || exit 1 - exec_graphql "$token_name" 'ln-invoice-payment-send' "$variables" + exec_graphql "alice" 'ln-invoice-payment-send' "$variables" send_status="$(graphql_output '.data.lnInvoicePaymentSend.status')" [[ "${send_status}" = "SUCCESS" ]] || exit 1 # Check for settled - retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" final_lnd1_balance=$(lnd_cli channelbalance | jq -r '.balance') lnd1_diff="$(( $initial_lnd1_balance - $final_lnd1_balance ))" @@ -99,8 +60,7 @@ usd_amount=50 } @test "ln-send: lightning settled - lnInvoicePaymentSend from btc, no fee probe" { - token_name="$ALICE_TOKEN_NAME" - btc_wallet_name="$token_name.btc_wallet_id" + btc_wallet_name="alice.btc_wallet_id" initial_lnd1_balance=$(lnd_cli channelbalance | jq -r '.balance') @@ -116,12 +76,12 @@ usd_amount=50 '{input: {walletId: $wallet_id, paymentRequest: $payment_request}}' ) - exec_graphql "$token_name" 'ln-invoice-payment-send' "$variables" + exec_graphql "alice" 'ln-invoice-payment-send' "$variables" send_status="$(graphql_output '.data.lnInvoicePaymentSend.status')" [[ "${send_status}" = "SUCCESS" ]] || exit 1 # Check for settled - retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" final_lnd1_balance=$(lnd_cli channelbalance | jq -r '.balance') lnd1_diff="$(( $initial_lnd1_balance - $final_lnd1_balance ))" @@ -129,8 +89,7 @@ usd_amount=50 } @test "ln-send: lightning settled - lnInvoicePaymentSend from usd" { - token_name="$ALICE_TOKEN_NAME" - usd_wallet_name="$token_name.usd_wallet_id" + usd_wallet_name="alice.usd_wallet_id" initial_lnd1_balance=$(lnd_cli channelbalance | jq -r '.balance') @@ -146,16 +105,16 @@ usd_amount=50 '{input: {walletId: $wallet_id, paymentRequest: $payment_request}}' ) - exec_graphql "$token_name" 'ln-usd-invoice-fee-probe' "$variables" + exec_graphql "alice" 'ln-usd-invoice-fee-probe' "$variables" fee_amount="$(graphql_output '.data.lnUsdInvoiceFeeProbe.amount')" [[ "${fee_amount}" = "0" ]] || exit 1 - exec_graphql "$token_name" 'ln-invoice-payment-send' "$variables" + exec_graphql "alice" 'ln-invoice-payment-send' "$variables" send_status="$(graphql_output '.data.lnInvoicePaymentSend.status')" [[ "${send_status}" = "SUCCESS" ]] || exit 1 # Check for settled - retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" final_lnd1_balance=$(lnd_cli channelbalance | jq -r '.balance') lnd1_diff="$(( $initial_lnd1_balance - $final_lnd1_balance ))" @@ -163,8 +122,7 @@ usd_amount=50 } @test "ln-send: lightning settled - lnInvoicePaymentSend from usd, no fee probe" { - token_name="$ALICE_TOKEN_NAME" - usd_wallet_name="$token_name.usd_wallet_id" + usd_wallet_name="alice.usd_wallet_id" initial_lnd1_balance=$(lnd_cli channelbalance | jq -r '.balance') @@ -180,12 +138,12 @@ usd_amount=50 '{input: {walletId: $wallet_id, paymentRequest: $payment_request}}' ) - exec_graphql "$token_name" 'ln-invoice-payment-send' "$variables" + exec_graphql "alice" 'ln-invoice-payment-send' "$variables" send_status="$(graphql_output '.data.lnInvoicePaymentSend.status')" [[ "${send_status}" = "SUCCESS" ]] || exit 1 # Check for settled - retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" final_lnd1_balance=$(lnd_cli channelbalance | jq -r '.balance') lnd1_diff="$(( $initial_lnd1_balance - $final_lnd1_balance ))" @@ -193,8 +151,7 @@ usd_amount=50 } @test "ln-send: lightning settled - lnNoAmountInvoicePaymentSend" { - token_name="$ALICE_TOKEN_NAME" - btc_wallet_name="$token_name.btc_wallet_id" + btc_wallet_name="alice.btc_wallet_id" initial_lnd1_balance=$(lnd_cli channelbalance | jq -r '.balance') @@ -211,16 +168,16 @@ usd_amount=50 '{input: {walletId: $wallet_id, paymentRequest: $payment_request, amount: $amount}}' ) - exec_graphql "$token_name" 'ln-no-amount-invoice-fee-probe' "$variables" + exec_graphql "alice" 'ln-no-amount-invoice-fee-probe' "$variables" fee_amount="$(graphql_output '.data.lnNoAmountInvoiceFeeProbe.amount')" [[ "${fee_amount}" = "0" ]] || exit 1 - exec_graphql "$token_name" 'ln-no-amount-invoice-payment-send' "$variables" + exec_graphql "alice" 'ln-no-amount-invoice-payment-send' "$variables" send_status="$(graphql_output '.data.lnNoAmountInvoicePaymentSend.status')" [[ "${send_status}" = "SUCCESS" ]] || exit 1 # Check for settled - retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" final_lnd1_balance=$(lnd_cli channelbalance | jq -r '.balance') lnd1_diff="$(( $initial_lnd1_balance - $final_lnd1_balance ))" @@ -228,8 +185,7 @@ usd_amount=50 } @test "ln-send: lightning settled - lnNoAmountInvoicePaymentSend, no fee probe" { - token_name="$ALICE_TOKEN_NAME" - btc_wallet_name="$token_name.btc_wallet_id" + btc_wallet_name="alice.btc_wallet_id" initial_lnd1_balance=$(lnd_cli channelbalance | jq -r '.balance') @@ -246,12 +202,12 @@ usd_amount=50 '{input: {walletId: $wallet_id, paymentRequest: $payment_request, amount: $amount}}' ) - exec_graphql "$token_name" 'ln-no-amount-invoice-payment-send' "$variables" + exec_graphql "alice" 'ln-no-amount-invoice-payment-send' "$variables" send_status="$(graphql_output '.data.lnNoAmountInvoicePaymentSend.status')" [[ "${send_status}" = "SUCCESS" ]] || exit 1 # Check for settled - retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" final_lnd1_balance=$(lnd_cli channelbalance | jq -r '.balance') lnd1_diff="$(( $initial_lnd1_balance - $final_lnd1_balance ))" @@ -259,10 +215,9 @@ usd_amount=50 } @test "ln-send: lightning settled - lnNoAmountUsdInvoicePaymentSend" { - token_name="$ALICE_TOKEN_NAME" - usd_wallet_name="$token_name.usd_wallet_id" + usd_wallet_name="alice.usd_wallet_id" - initial_balance="$(balance_for_wallet $token_name 'USD')" + initial_balance="$(balance_for_wallet alice 'USD')" initial_lnd1_balance=$(lnd_cli channelbalance | jq -r '.balance') invoice_response="$(lnd_outside_cli addinvoice)" @@ -278,18 +233,18 @@ usd_amount=50 '{input: {walletId: $wallet_id, paymentRequest: $payment_request, amount: $amount}}' ) - exec_graphql "$token_name" 'ln-no-amount-usd-invoice-fee-probe' "$variables" + exec_graphql "alice" 'ln-no-amount-usd-invoice-fee-probe' "$variables" fee_amount="$(graphql_output '.data.lnNoAmountUsdInvoiceFeeProbe.amount')" [[ "${fee_amount}" = "0" ]] || exit 1 - exec_graphql "$token_name" 'ln-no-amount-usd-invoice-payment-send' "$variables" + exec_graphql "alice" 'ln-no-amount-usd-invoice-payment-send' "$variables" send_status="$(graphql_output '.data.lnNoAmountUsdInvoicePaymentSend.status')" [[ "${send_status}" = "SUCCESS" ]] || exit 1 # Check for settled - retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" - final_balance="$(balance_for_wallet $token_name 'USD')" + final_balance="$(balance_for_wallet alice 'USD')" wallet_diff="$(( $initial_balance - $final_balance ))" [[ "$wallet_diff" == "$usd_amount" ]] || exit 1 @@ -299,10 +254,9 @@ usd_amount=50 } @test "ln-send: lightning settled - lnNoAmountUsdInvoicePaymentSend, no fee probe" { - token_name="$ALICE_TOKEN_NAME" - usd_wallet_name="$token_name.usd_wallet_id" + usd_wallet_name="alice.usd_wallet_id" - initial_balance="$(balance_for_wallet $token_name 'USD')" + initial_balance="$(balance_for_wallet alice 'USD')" initial_lnd1_balance=$(lnd_cli channelbalance | jq -r '.balance') invoice_response="$(lnd_outside_cli addinvoice)" @@ -318,14 +272,14 @@ usd_amount=50 '{input: {walletId: $wallet_id, paymentRequest: $payment_request, amount: $amount}}' ) - exec_graphql "$token_name" 'ln-no-amount-usd-invoice-payment-send' "$variables" + exec_graphql "alice" 'ln-no-amount-usd-invoice-payment-send' "$variables" send_status="$(graphql_output '.data.lnNoAmountUsdInvoicePaymentSend.status')" [[ "${send_status}" = "SUCCESS" ]] || exit 1 # Check for settled - retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" - final_balance="$(balance_for_wallet $token_name 'USD')" + final_balance="$(balance_for_wallet alice 'USD')" wallet_diff="$(( $initial_balance - $final_balance ))" [[ "$wallet_diff" == "$usd_amount" ]] || exit 1 @@ -335,25 +289,16 @@ usd_amount=50 } @test "ln-send: intraledger settled - lnInvoicePaymentSend from btc to btc, with contacts check" { - token_name="$ALICE_TOKEN_NAME" - btc_wallet_name="$token_name.btc_wallet_id" - - recipient_token_name="user_$RANDOM" - recipient_phone="$(random_phone)" - login_user \ - "$recipient_token_name" \ - "$recipient_phone" \ - "$CODE" - user_update_username "$recipient_token_name" - btc_recipient_wallet_name="$recipient_token_name.btc_wallet_id" - - initial_balance="$(balance_for_wallet $token_name 'BTC')" + btc_wallet_name="alice.btc_wallet_id" + btc_recipient_wallet_name="bob.btc_wallet_id" + + initial_balance="$(balance_for_wallet alice 'BTC')" initial_lnd1_balance=$(lnd_cli channelbalance | jq -r '.balance') # Check is not contact before send - run is_contact "$token_name" "$recipient_token_name" + run is_contact "alice" "bob" [[ "$status" -ne "0" ]] || exit 1 - run is_contact "$recipient_token_name" "$token_name" + run is_contact "bob" "alice" [[ "$status" -ne "0" ]] || exit 1 variables=$( @@ -362,7 +307,7 @@ usd_amount=50 --arg amount "$btc_amount" \ '{input: {walletId: $wallet_id, amount: $amount}}' ) - exec_graphql "$recipient_token_name" 'ln-invoice-create' "$variables" + exec_graphql "bob" 'ln-invoice-create' "$variables" invoice="$(graphql_output '.data.lnInvoiceCreate.invoice')" payment_request="$(echo $invoice | jq -r '.paymentRequest')" @@ -377,15 +322,15 @@ usd_amount=50 '{input: {walletId: $wallet_id, paymentRequest: $payment_request}}' ) - exec_graphql "$token_name" 'ln-invoice-payment-send' "$variables" + exec_graphql "alice" 'ln-invoice-payment-send' "$variables" send_status="$(graphql_output '.data.lnInvoicePaymentSend.status')" [[ "${send_status}" = "SUCCESS" ]] || exit 1 # Check for settled - retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" - check_for_ln_initiated_settled "$recipient_token_name" "$payment_hash" + retry 30 1 check_for_ln_initiated_settled "alice" "$payment_hash" + check_for_ln_initiated_settled "bob" "$payment_hash" - final_balance="$(balance_for_wallet $token_name 'BTC')" + final_balance="$(balance_for_wallet alice 'BTC')" wallet_diff="$(( $initial_balance - $final_balance ))" [[ "$wallet_diff" == "$btc_amount" ]] || exit 1 @@ -394,20 +339,17 @@ usd_amount=50 [[ "$lnd1_diff" == "0" ]] || exit 1 # Check is contact after send - run is_contact "$token_name" "$recipient_token_name" + run is_contact "alice" "bob" [[ "$status" == "0" ]] || exit 1 - run is_contact "$recipient_token_name" "$token_name" + run is_contact "bob" "alice" [[ "$status" == "0" ]] || exit 1 } @test "ln-send: intraledger settled - lnInvoicePaymentSend from usd to btc" { - token_name="$ALICE_TOKEN_NAME" - usd_wallet_name="$token_name.usd_wallet_id" - - recipient_token_name="$BOB_TOKEN_NAME" - btc_recipient_wallet_name="$recipient_token_name.btc_wallet_id" + usd_wallet_name="alice.usd_wallet_id" + btc_recipient_wallet_name="bob.btc_wallet_id" - initial_recipient_balance="$(balance_for_wallet $recipient_token_name 'BTC')" + initial_recipient_balance="$(balance_for_wallet bob 'BTC')" initial_lnd1_balance=$(lnd_cli channelbalance | jq -r '.balance') variables=$( @@ -416,7 +358,7 @@ usd_amount=50 --arg amount "$btc_amount" \ '{input: {walletId: $wallet_id, amount: $amount}}' ) - exec_graphql "$recipient_token_name" 'ln-invoice-create' "$variables" + exec_graphql "bob" 'ln-invoice-create' "$variables" invoice="$(graphql_output '.data.lnInvoiceCreate.invoice')" payment_request="$(echo $invoice | jq -r '.paymentRequest')" @@ -431,19 +373,19 @@ usd_amount=50 '{input: {walletId: $wallet_id, paymentRequest: $payment_request}}' ) - exec_graphql "$token_name" 'ln-usd-invoice-fee-probe' "$variables" + exec_graphql "alice" 'ln-usd-invoice-fee-probe' "$variables" fee_amount="$(graphql_output '.data.lnUsdInvoiceFeeProbe.amount')" [[ "${fee_amount}" = "0" ]] || exit 1 - exec_graphql "$token_name" 'ln-invoice-payment-send' "$variables" + exec_graphql "alice" 'ln-invoice-payment-send' "$variables" send_status="$(graphql_output '.data.lnInvoicePaymentSend.status')" [[ "${send_status}" = "SUCCESS" ]] || exit 1 # Check for settled - retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" - check_for_ln_initiated_settled "$recipient_token_name" "$payment_hash" + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" + check_for_ln_initiated_settled "bob" "$payment_hash" - final_recipient_balance="$(balance_for_wallet $recipient_token_name 'BTC')" + final_recipient_balance="$(balance_for_wallet bob 'BTC')" recipient_wallet_diff="$(( $final_recipient_balance - $initial_recipient_balance ))" [[ "$recipient_wallet_diff" == "$btc_amount" ]] || exit 1 @@ -453,13 +395,10 @@ usd_amount=50 } @test "ln-send: intraledger settled - lnNoAmountInvoicePaymentSend from btc to usd" { - token_name="$ALICE_TOKEN_NAME" - btc_wallet_name="$token_name.btc_wallet_id" + btc_wallet_name="alice.btc_wallet_id" + usd_recipient_wallet_name="bob.usd_wallet_id" - recipient_token_name="$BOB_TOKEN_NAME" - usd_recipient_wallet_name="$recipient_token_name.usd_wallet_id" - - initial_balance="$(balance_for_wallet $token_name 'BTC')" + initial_balance="$(balance_for_wallet alice 'BTC')" initial_lnd1_balance=$(lnd_cli channelbalance | jq -r '.balance') variables=$( @@ -467,7 +406,7 @@ usd_amount=50 --arg wallet_id "$(read_value $usd_recipient_wallet_name)" \ '{input: {walletId: $wallet_id}}' ) - exec_graphql "$recipient_token_name" 'ln-no-amount-invoice-create' "$variables" + exec_graphql "bob" 'ln-no-amount-invoice-create' "$variables" invoice="$(graphql_output '.data.lnNoAmountInvoiceCreate.invoice')" payment_request="$(echo $invoice | jq -r '.paymentRequest')" @@ -483,15 +422,15 @@ usd_amount=50 '{input: {walletId: $wallet_id, paymentRequest: $payment_request, amount: $amount}}' ) - exec_graphql "$token_name" 'ln-no-amount-invoice-payment-send' "$variables" + exec_graphql "alice" 'ln-no-amount-invoice-payment-send' "$variables" send_status="$(graphql_output '.data.lnNoAmountInvoicePaymentSend.status')" [[ "${send_status}" = "SUCCESS" ]] || exit 1 # Check for settled - retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" - check_for_ln_initiated_settled "$recipient_token_name" "$payment_hash" + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" + check_for_ln_initiated_settled "bob" "$payment_hash" - final_balance="$(balance_for_wallet $token_name 'BTC')" + final_balance="$(balance_for_wallet alice 'BTC')" wallet_diff="$(( $initial_balance - $final_balance ))" [[ "$wallet_diff" == "$btc_amount" ]] || exit 1 @@ -501,13 +440,10 @@ usd_amount=50 } @test "ln-send: intraledger settled - lnNoAmountUsdInvoicePaymentSend from usd to usd" { - token_name="$ALICE_TOKEN_NAME" - usd_wallet_name="$token_name.usd_wallet_id" - - recipient_token_name="$BOB_TOKEN_NAME" - usd_recipient_wallet_name="$recipient_token_name.usd_wallet_id" + usd_wallet_name="alice.usd_wallet_id" + usd_recipient_wallet_name="bob.usd_wallet_id" - initial_balance="$(balance_for_wallet $token_name 'USD')" + initial_balance="$(balance_for_wallet alice 'USD')" initial_lnd1_balance=$(lnd_cli channelbalance | jq -r '.balance') variables=$( @@ -515,7 +451,7 @@ usd_amount=50 --arg wallet_id "$(read_value $usd_recipient_wallet_name)" \ '{input: {walletId: $wallet_id}}' ) - exec_graphql "$recipient_token_name" 'ln-no-amount-invoice-create' "$variables" + exec_graphql "bob" 'ln-no-amount-invoice-create' "$variables" invoice="$(graphql_output '.data.lnNoAmountInvoiceCreate.invoice')" payment_request="$(echo $invoice | jq -r '.paymentRequest')" @@ -531,15 +467,15 @@ usd_amount=50 '{input: {walletId: $wallet_id, paymentRequest: $payment_request, amount: $amount}}' ) - exec_graphql "$token_name" 'ln-no-amount-usd-invoice-payment-send' "$variables" + exec_graphql "alice" 'ln-no-amount-usd-invoice-payment-send' "$variables" send_status="$(graphql_output '.data.lnNoAmountUsdInvoicePaymentSend.status')" [[ "${send_status}" = "SUCCESS" ]] || exit 1 # Check for settled - retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" - check_for_ln_initiated_settled "$recipient_token_name" "$payment_hash" + retry 15 1 check_for_ln_initiated_settled "alice" "$payment_hash" + check_for_ln_initiated_settled "bob" "$payment_hash" - final_balance="$(balance_for_wallet $token_name 'USD')" + final_balance="$(balance_for_wallet alice 'USD')" wallet_diff="$(( $initial_balance - $final_balance ))" [[ "$wallet_diff" == "$usd_amount" ]] || exit 1 @@ -549,8 +485,7 @@ usd_amount=50 } @test "ln-send: ln settled - settle failed and then successful payment" { - token_name="$ALICE_TOKEN_NAME" - btc_wallet_name="$token_name.btc_wallet_id" + btc_wallet_name="alice.btc_wallet_id" threshold_amount=150000 invoice_response="$(lnd_outside_2_cli addinvoice --amt $threshold_amount)" @@ -561,7 +496,7 @@ usd_amount=50 check_num_txns() { expected_num="$1" - num_txns="$(num_txns_for_hash "$token_name" "$payment_hash")" + num_txns="$(num_txns_for_hash "alice" "$payment_hash")" [[ "$num_txns" == "$expected_num" ]] || exit 1 } @@ -569,7 +504,7 @@ usd_amount=50 rebalance_channel lnd_outside_cli lnd_outside_2_cli "$(( $threshold_amount - 1 ))" # Try payment and check for fail - initial_balance="$(balance_for_wallet $token_name 'BTC')" + initial_balance="$(balance_for_wallet alice 'BTC')" variables=$( jq -n \ @@ -577,7 +512,7 @@ usd_amount=50 --arg payment_request "$payment_request" \ '{input: {walletId: $wallet_id, paymentRequest: $payment_request}}' ) - exec_graphql "$token_name" 'ln-invoice-payment-send' "$variables" + exec_graphql "alice" 'ln-invoice-payment-send' "$variables" send_status="$(graphql_output '.data.lnInvoicePaymentSend.status')" error_msg="$(graphql_output '.data.lnInvoicePaymentSend.errors[0].message')" [[ "${send_status}" = "FAILURE" ]] || exit 1 @@ -585,7 +520,7 @@ usd_amount=50 # Check for txns retry 15 1 check_num_txns "2" - balance_after_fail="$(balance_for_wallet $token_name 'BTC')" + balance_after_fail="$(balance_for_wallet alice 'BTC')" [[ "$initial_balance" == "$balance_after_fail" ]] || exit 1 # Rebalance last hop so same payment will succeed @@ -593,27 +528,26 @@ usd_amount=50 lnd_cli resetmc # Retry payment and check for success - exec_graphql "$token_name" 'ln-invoice-fee-probe' "$variables" + exec_graphql "alice" 'ln-invoice-fee-probe' "$variables" num_errors="$(graphql_output '.data.lnInvoiceFeeProbe.errors | length')" fee_amount="$(graphql_output '.data.lnInvoiceFeeProbe.amount')" [[ "$num_errors" == "0" ]] || exit 1 [[ "${fee_amount}" -gt "0" ]] || exit 1 - exec_graphql "$token_name" 'ln-invoice-payment-send' "$variables" + exec_graphql "alice" 'ln-invoice-payment-send' "$variables" send_status="$(graphql_output '.data.lnInvoicePaymentSend.status')" [[ "${send_status}" = "SUCCESS" ]] || exit 1 # Check for txns retry 15 1 check_num_txns "3" - balance_after_success="$(balance_for_wallet $token_name 'BTC')" + balance_after_success="$(balance_for_wallet alice 'BTC')" [[ "$balance_after_success" -lt "$initial_balance" ]] || exit 1 } @test "ln-send: ln settled - settle failed and then pending-to-failed payment" { skip "missing xxd dep, failing on concourse" - token_name="$ALICE_TOKEN_NAME" - btc_wallet_name="$token_name.btc_wallet_id" + btc_wallet_name="alice.btc_wallet_id" threshold_amount=150000 secret=$(xxd -l 32 -p /dev/urandom) @@ -625,7 +559,7 @@ usd_amount=50 check_num_txns() { expected_num="$1" - num_txns="$(num_txns_for_hash "$token_name" "$payment_hash")" + num_txns="$(num_txns_for_hash "alice" "$payment_hash")" [[ "$num_txns" == "$expected_num" ]] || exit 1 } @@ -633,7 +567,7 @@ usd_amount=50 rebalance_channel lnd_outside_cli lnd_outside_2_cli "$(( $threshold_amount - 1 ))" # Try payment and check for fail - initial_balance="$(balance_for_wallet $token_name 'BTC')" + initial_balance="$(balance_for_wallet alice 'BTC')" variables=$( jq -n \ @@ -641,7 +575,7 @@ usd_amount=50 --arg payment_request "$payment_request" \ '{input: {walletId: $wallet_id, paymentRequest: $payment_request}}' ) - exec_graphql "$token_name" 'ln-invoice-payment-send' "$variables" + exec_graphql "alice" 'ln-invoice-payment-send' "$variables" send_status="$(graphql_output '.data.lnInvoicePaymentSend.status')" error_msg="$(graphql_output '.data.lnInvoicePaymentSend.errors[0].message')" [[ "${send_status}" = "FAILURE" ]] || exit 1 @@ -649,7 +583,7 @@ usd_amount=50 # Check for txns retry 15 1 check_num_txns "2" - balance_after_fail="$(balance_for_wallet $token_name 'BTC')" + balance_after_fail="$(balance_for_wallet alice 'BTC')" [[ "$initial_balance" == "$balance_after_fail" ]] || exit 1 # Rebalance last hop so same payment will succeed @@ -657,34 +591,34 @@ usd_amount=50 lnd_cli resetmc # Retry payment and check for pending - exec_graphql "$token_name" 'ln-invoice-payment-send' "$variables" + exec_graphql "alice" 'ln-invoice-payment-send' "$variables" send_status="$(graphql_output '.data.lnInvoicePaymentSend.status')" [[ "${send_status}" = "PENDING" ]] || exit 1 # Check for txns retry 15 1 check_num_txns "3" - check_for_ln_initiated_pending "$token_name" "$payment_hash" "10" \ + check_for_ln_initiated_pending "alice" "$payment_hash" "10" \ || exit 1 - balance_while_pending="$(balance_for_wallet $token_name 'BTC')" + balance_while_pending="$(balance_for_wallet alice 'BTC')" [[ "$balance_while_pending" -lt "$initial_balance" ]] || exit 1 # Cancel hodl invoice lnd_outside_2_cli cancelinvoice "$payment_hash" retry 15 1 check_num_txns "4" - balance_after_pending_failed="$(balance_for_wallet $token_name 'BTC')" + balance_after_pending_failed="$(balance_for_wallet alice 'BTC')" [[ "$balance_after_pending_failed" == "$initial_balance" ]] || exit 1 - run check_for_ln_initiated_pending "$token_name" "$payment_hash" "10" + run check_for_ln_initiated_pending "alice" "$payment_hash" "10" [[ "$status" -ne 0 ]] || exit 1 } @test "ln-send: ln settled - pending-to-failed usd payment" { skip "missing xxd dep, failing on concourse" - token_name="$ALICE_TOKEN_NAME" - btc_wallet_name="$token_name.btc_wallet_id" - usd_wallet_name="$token_name.usd_wallet_id" + + btc_wallet_name="alice.btc_wallet_id" + usd_wallet_name="alice.usd_wallet_id" threshold_amount=150000 secret=$(xxd -l 32 -p /dev/urandom) @@ -696,12 +630,12 @@ usd_amount=50 check_num_txns() { expected_num="$1" - num_txns="$(num_txns_for_hash "$token_name" "$payment_hash")" + num_txns="$(num_txns_for_hash "alice" "$payment_hash")" [[ "$num_txns" == "$expected_num" ]] || exit 1 } - initial_btc_balance="$(balance_for_wallet $token_name 'BTC')" - initial_usd_balance="$(balance_for_wallet $token_name 'USD')" + initial_btc_balance="$(balance_for_wallet alice 'BTC')" + initial_usd_balance="$(balance_for_wallet alice 'USD')" # Rebalance last hop so payment will succeed rebalance_channel lnd_outside_cli lnd_outside_2_cli "$(( $threshold_amount * 2 ))" @@ -714,16 +648,16 @@ usd_amount=50 --arg payment_request "$payment_request" \ '{input: {walletId: $wallet_id, paymentRequest: $payment_request}}' ) - exec_graphql "$token_name" 'ln-invoice-payment-send' "$variables" + exec_graphql "alice" 'ln-invoice-payment-send' "$variables" send_status="$(graphql_output '.data.lnInvoicePaymentSend.status')" [[ "${send_status}" = "PENDING" ]] || exit 1 # Check for txns retry 15 1 check_num_txns "1" - check_for_ln_initiated_pending "$token_name" "$payment_hash" "10" \ + check_for_ln_initiated_pending "alice" "$payment_hash" "10" \ || exit 1 - btc_balance_while_pending="$(balance_for_wallet $token_name 'BTC')" - usd_balance_while_pending="$(balance_for_wallet $token_name 'USD')" + btc_balance_while_pending="$(balance_for_wallet alice 'BTC')" + usd_balance_while_pending="$(balance_for_wallet alice 'USD')" [[ "$btc_balance_while_pending" == "$initial_btc_balance" ]] || exit 1 [[ "$usd_balance_while_pending" -lt "$initial_usd_balance" ]] || exit 1 @@ -731,11 +665,11 @@ usd_amount=50 lnd_outside_2_cli cancelinvoice "$payment_hash" retry 15 1 check_num_txns "2" - btc_balance_after_pending_failed="$(balance_for_wallet $token_name 'BTC')" - usd_balance_after_pending_failed="$(balance_for_wallet $token_name 'USD')" + btc_balance_after_pending_failed="$(balance_for_wallet alice 'BTC')" + usd_balance_after_pending_failed="$(balance_for_wallet alice 'USD')" [[ "$btc_balance_after_pending_failed" -gt "$btc_balance_while_pending" ]] || exit 1 [[ "$usd_balance_after_pending_failed" == "$usd_balance_while_pending" ]] || exit 1 - run check_for_ln_initiated_pending "$token_name" "$payment_hash" "10" + run check_for_ln_initiated_pending "alice" "$payment_hash" "10" [[ "$status" -ne 0 ]] || exit 1 } diff --git a/bats/gql/account-details.gql b/bats/gql/account-details.gql new file mode 100644 index 0000000000..adc71fd240 --- /dev/null +++ b/bats/gql/account-details.gql @@ -0,0 +1,8 @@ +query me { + me { + defaultAccount { + id + level + } + } +} diff --git a/bats/gql/invoice-for-wallet-by-payment-hash.gql b/bats/gql/invoice-for-wallet-by-payment-hash.gql new file mode 100644 index 0000000000..147bb65714 --- /dev/null +++ b/bats/gql/invoice-for-wallet-by-payment-hash.gql @@ -0,0 +1,17 @@ +query me($walletId: WalletId!, $paymentHash: PaymentHash!) { + me { + defaultAccount { + id + walletById(walletId: $walletId) { + id + invoiceByPaymentHash(paymentHash: $paymentHash) { + paymentHash + paymentStatus + ... on LnInvoice { + satoshis + } + } + } + } + } +} diff --git a/bats/gql/ln-invoice-create.gql b/bats/gql/ln-invoice-create.gql new file mode 100644 index 0000000000..3e3a27d0a0 --- /dev/null +++ b/bats/gql/ln-invoice-create.gql @@ -0,0 +1,11 @@ +mutation lnInvoiceCreateInput($input: LnInvoiceCreateInput!) { + lnInvoiceCreate(input: $input) { + invoice { + paymentRequest + paymentHash + } + errors { + message + } + } +} diff --git a/bats/gql/ln-invoice-fee-probe.gql b/bats/gql/ln-invoice-fee-probe.gql new file mode 100644 index 0000000000..3064f585df --- /dev/null +++ b/bats/gql/ln-invoice-fee-probe.gql @@ -0,0 +1,8 @@ +mutation LnInvoiceFeeProbe($input: LnInvoiceFeeProbeInput!) { + lnInvoiceFeeProbe(input: $input) { + errors { + message + } + amount + } +} diff --git a/bats/gql/ln-invoice-payment-send copy.gql b/bats/gql/ln-invoice-payment-send copy.gql new file mode 100644 index 0000000000..cb66944ef0 --- /dev/null +++ b/bats/gql/ln-invoice-payment-send copy.gql @@ -0,0 +1,8 @@ +mutation lnInvoicePaymentSend($input: LnInvoicePaymentInput!) { + lnInvoicePaymentSend(input: $input) { + errors { + message + } + status + } +} diff --git a/bats/gql/ln-invoice-payment-send.gql b/bats/gql/ln-invoice-payment-send.gql new file mode 100644 index 0000000000..cb66944ef0 --- /dev/null +++ b/bats/gql/ln-invoice-payment-send.gql @@ -0,0 +1,8 @@ +mutation lnInvoicePaymentSend($input: LnInvoicePaymentInput!) { + lnInvoicePaymentSend(input: $input) { + errors { + message + } + status + } +} diff --git a/bats/gql/ln-no-amount-invoice-create.gql b/bats/gql/ln-no-amount-invoice-create.gql new file mode 100644 index 0000000000..ac03667394 --- /dev/null +++ b/bats/gql/ln-no-amount-invoice-create.gql @@ -0,0 +1,11 @@ +mutation lnNoAmountInvoiceCreate($input: LnNoAmountInvoiceCreateInput!) { + lnNoAmountInvoiceCreate(input: $input) { + invoice { + paymentRequest + paymentHash + } + errors { + message + } + } +} diff --git a/bats/gql/ln-no-amount-invoice-fee-probe.gql b/bats/gql/ln-no-amount-invoice-fee-probe.gql new file mode 100644 index 0000000000..cbd12026ac --- /dev/null +++ b/bats/gql/ln-no-amount-invoice-fee-probe.gql @@ -0,0 +1,8 @@ +mutation lnNoAmountInvoiceFeeProbe($input: LnNoAmountInvoiceFeeProbeInput!) { + lnNoAmountInvoiceFeeProbe(input: $input) { + errors { + message + } + amount + } +} diff --git a/bats/gql/ln-no-amount-invoice-payment-send copy.gql b/bats/gql/ln-no-amount-invoice-payment-send copy.gql new file mode 100644 index 0000000000..7131b589b4 --- /dev/null +++ b/bats/gql/ln-no-amount-invoice-payment-send copy.gql @@ -0,0 +1,8 @@ +mutation lnNoAmountInvoicePaymentSend($input: LnNoAmountInvoicePaymentInput!) { + lnNoAmountInvoicePaymentSend(input: $input) { + errors { + message + } + status + } +} diff --git a/bats/gql/ln-no-amount-invoice-payment-send.gql b/bats/gql/ln-no-amount-invoice-payment-send.gql new file mode 100644 index 0000000000..7131b589b4 --- /dev/null +++ b/bats/gql/ln-no-amount-invoice-payment-send.gql @@ -0,0 +1,8 @@ +mutation lnNoAmountInvoicePaymentSend($input: LnNoAmountInvoicePaymentInput!) { + lnNoAmountInvoicePaymentSend(input: $input) { + errors { + message + } + status + } +} diff --git a/bats/gql/ln-no-amount-usd-invoice-fee-probe.gql b/bats/gql/ln-no-amount-usd-invoice-fee-probe.gql new file mode 100644 index 0000000000..00bde20e62 --- /dev/null +++ b/bats/gql/ln-no-amount-usd-invoice-fee-probe.gql @@ -0,0 +1,8 @@ +mutation lnNoAmountUsdInvoiceFeeProbe($input: LnNoAmountUsdInvoiceFeeProbeInput!) { + lnNoAmountUsdInvoiceFeeProbe(input: $input) { + errors { + message + } + amount + } +} diff --git a/bats/gql/ln-no-amount-usd-invoice-payment-send.gql b/bats/gql/ln-no-amount-usd-invoice-payment-send.gql new file mode 100644 index 0000000000..a34ccee880 --- /dev/null +++ b/bats/gql/ln-no-amount-usd-invoice-payment-send.gql @@ -0,0 +1,8 @@ +mutation lnNoAmountUsdInvoicePaymentSend($input: LnNoAmountUsdInvoicePaymentInput!) { + lnNoAmountUsdInvoicePaymentSend(input: $input) { + errors { + message + } + status + } +} diff --git a/bats/gql/ln-usd-invoice-create.gql b/bats/gql/ln-usd-invoice-create.gql new file mode 100644 index 0000000000..270e9ef009 --- /dev/null +++ b/bats/gql/ln-usd-invoice-create.gql @@ -0,0 +1,11 @@ +mutation lnUsdInvoiceCreate($input: LnUsdInvoiceCreateInput!) { + lnUsdInvoiceCreate(input: $input) { + invoice { + paymentRequest + paymentHash + } + errors { + message + } + } +} diff --git a/bats/gql/ln-usd-invoice-fee-probe.gql b/bats/gql/ln-usd-invoice-fee-probe.gql new file mode 100644 index 0000000000..1508e144aa --- /dev/null +++ b/bats/gql/ln-usd-invoice-fee-probe.gql @@ -0,0 +1,8 @@ +mutation lnUsdInvoiceFeeProbe($input: LnUsdInvoiceFeeProbeInput!) { + lnUsdInvoiceFeeProbe(input: $input) { + errors { + message + } + amount + } +} diff --git a/bats/gql/my-updates-sub.gql b/bats/gql/my-updates-sub.gql new file mode 100644 index 0000000000..94297df873 --- /dev/null +++ b/bats/gql/my-updates-sub.gql @@ -0,0 +1,57 @@ +subscription myUpdates { + myUpdates { + errors { + message + } + me { + id + defaultAccount { + id + wallets { + id + walletCurrency + balance + } + } + } + update { + type: __typename + ... on Price { + base + offset + currencyUnit + formattedAmount + } + ... on RealtimePrice { + id + timestamp + denominatorCurrency + btcSatPrice { + base + offset + currencyUnit + } + usdCentPrice { + base + offset + currencyUnit + } + } + ... on LnUpdate { + paymentHash + status + } + ... on OnChainUpdate { + txNotificationType + txHash + amount + usdPerSat + } + ... on IntraLedgerUpdate { + txNotificationType + amount + usdPerSat + } + } + } +} diff --git a/bats/gql/transaction-for-wallet-by-id.gql b/bats/gql/transaction-for-wallet-by-id.gql new file mode 100644 index 0000000000..cc5c946f05 --- /dev/null +++ b/bats/gql/transaction-for-wallet-by-id.gql @@ -0,0 +1,54 @@ +query transactionForWalletById($walletId: WalletId!, $transactionId: ID!) { + me { + defaultAccount { + id + displayCurrency + walletById(walletId: $walletId) { + transactionById(transactionId: $transactionId) { + __typename + id + status + direction + memo + createdAt + settlementAmount + settlementFee + settlementDisplayAmount + settlementDisplayFee + settlementDisplayCurrency + settlementCurrency + settlementPrice { + base + offset + } + initiationVia { + __typename + ... on InitiationViaIntraLedger { + counterPartyWalletId + counterPartyUsername + } + ... on InitiationViaLn { + paymentHash + } + ... on InitiationViaOnChain { + address + } + } + settlementVia { + __typename + ... on SettlementViaIntraLedger { + counterPartyWalletId + counterPartyUsername + } + ... on SettlementViaLn { + preImage + } + ... on SettlementViaOnChain { + transactionHash + } + } + } + } + } + } +} diff --git a/bats/gql/transactions-for-wallet-by-payment-hash.gql b/bats/gql/transactions-for-wallet-by-payment-hash.gql new file mode 100644 index 0000000000..515d08232f --- /dev/null +++ b/bats/gql/transactions-for-wallet-by-payment-hash.gql @@ -0,0 +1,57 @@ +query transactionsForWalletByPaymentHash( + $walletId: WalletId! + $paymentHash: PaymentHash! +) { + me { + defaultAccount { + displayCurrency + walletById(walletId: $walletId) { + id + transactionsByPaymentHash(paymentHash: $paymentHash) { + __typename + id + status + direction + memo + createdAt + settlementAmount + settlementFee + settlementDisplayAmount + settlementDisplayFee + settlementDisplayCurrency + settlementCurrency + settlementPrice { + base + offset + } + initiationVia { + __typename + ... on InitiationViaIntraLedger { + counterPartyWalletId + counterPartyUsername + } + ... on InitiationViaLn { + paymentHash + } + ... on InitiationViaOnChain { + address + } + } + settlementVia { + __typename + ... on SettlementViaIntraLedger { + counterPartyWalletId + counterPartyUsername + } + ... on SettlementViaLn { + preImage + } + ... on SettlementViaOnChain { + transactionHash + } + } + } + } + } + } +} diff --git a/bats/helpers/_common.bash b/bats/helpers/_common.bash index 96080dc52c..5eb6778920 100644 --- a/bats/helpers/_common.bash +++ b/bats/helpers/_common.bash @@ -53,6 +53,23 @@ retry() { false } +is_number() { + if ! [[ $1 =~ ^-?[0-9]+$ ]]; then + echo "Error: $2 input is not a number: $1" + exit 1 + fi +} + +abs() { + is_number $1 || return 1 + + if [[ $1 -lt 0 ]]; then + echo "$((- $1))" + else + echo "$1" + fi +} + gql_query() { cat "$(gql_file "$1")" | tr '\n' ' ' | sed 's/"/\\"/g' } diff --git a/bats/helpers/callback.bash b/bats/helpers/callback.bash new file mode 100644 index 0000000000..86b7c347db --- /dev/null +++ b/bats/helpers/callback.bash @@ -0,0 +1,31 @@ +CURRENT_FILE=${BASH_SOURCE:-bats/helpers/.} +source "$(dirname "$CURRENT_FILE")/_common.bash" + +export CALLBACK_PID_FILE="${BATS_ROOT_DIR}/.gql_subscriber_pid" +export CALLBACK_LOG_FILE="${BATS_ROOT_DIR}/.e2e-callback.log" + +add_callback() { + local token_name=$1 + + local variables=$( + jq -n \ + --arg url "$SVIX_CALLBACK_URL" \ + '{input: {url: $url}}' + ) + exec_graphql "$token_name" 'callback-endpoint-add' "$variables" +} + +start_callback() { + stop_callback > /dev/null 2>&1 || true + rm -f "$CALLBACK_LOG_FILE" "$CALLBACK_PID_FILE" || true + + background \ + buck2 run //bats/helpers/callback:run + > "${CALLBACK_LOG_FILE}" + echo $! > "$CALLBACK_PID_FILE" +} + +stop_callback() { + [[ -f "$CALLBACK_PID_FILE" ]] && kill $(cat $CALLBACK_PID_FILE) > /dev/null || true +} + diff --git a/bats/helpers/callback/BUCK b/bats/helpers/callback/BUCK new file mode 100644 index 0000000000..3b3edbff06 --- /dev/null +++ b/bats/helpers/callback/BUCK @@ -0,0 +1,9 @@ +load( + "@toolchains//workspace-pnpm:macros.bzl", + "dev_pnpm_task_binary", +) + +dev_pnpm_task_binary( + name = "run", + command = "callback", +) diff --git a/bats/helpers/callback/package.json b/bats/helpers/callback/package.json new file mode 100644 index 0000000000..0daf3d7ded --- /dev/null +++ b/bats/helpers/callback/package.json @@ -0,0 +1,10 @@ +{ + "name": "callback", + "scripts": { + "callback": "tsx src/callback.ts" + }, + "devDependencies": { + "@types/node": "^20.8.7", + "tsx": "^4.2.0" + } +} diff --git a/bats/helpers/callback/pnpm-lock.yaml b/bats/helpers/callback/pnpm-lock.yaml new file mode 100644 index 0000000000..931aa202ec --- /dev/null +++ b/bats/helpers/callback/pnpm-lock.yaml @@ -0,0 +1,285 @@ +lockfileVersion: '6.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + devDependencies: + '@types/node': + specifier: ^20.8.7 + version: 20.10.0 + tsx: + specifier: ^4.2.0 + version: 4.6.0 + +packages: + + /@esbuild/android-arm64@0.18.20: + resolution: {integrity: sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@esbuild/android-arm@0.18.20: + resolution: {integrity: sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==} + engines: {node: '>=12'} + cpu: [arm] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@esbuild/android-x64@0.18.20: + resolution: {integrity: sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@esbuild/darwin-arm64@0.18.20: + resolution: {integrity: sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@esbuild/darwin-x64@0.18.20: + resolution: {integrity: sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@esbuild/freebsd-arm64@0.18.20: + resolution: {integrity: sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/freebsd-x64@0.18.20: + resolution: {integrity: sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-arm64@0.18.20: + resolution: {integrity: sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-arm@0.18.20: + resolution: {integrity: sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-ia32@0.18.20: + resolution: {integrity: sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-loong64@0.18.20: + resolution: {integrity: sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-mips64el@0.18.20: + resolution: {integrity: sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-ppc64@0.18.20: + resolution: {integrity: sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-riscv64@0.18.20: + resolution: {integrity: sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-s390x@0.18.20: + resolution: {integrity: sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-x64@0.18.20: + resolution: {integrity: sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/netbsd-x64@0.18.20: + resolution: {integrity: sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/openbsd-x64@0.18.20: + resolution: {integrity: sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/sunos-x64@0.18.20: + resolution: {integrity: sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-arm64@0.18.20: + resolution: {integrity: sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-ia32@0.18.20: + resolution: {integrity: sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-x64@0.18.20: + resolution: {integrity: sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@types/node@20.10.0: + resolution: {integrity: sha512-D0WfRmU9TQ8I9PFx9Yc+EBHw+vSpIub4IDvQivcp26PtPrdMGAq5SDcpXEo/epqa/DXotVpekHiLNTg3iaKXBQ==} + dependencies: + undici-types: 5.26.5 + dev: true + + /esbuild@0.18.20: + resolution: {integrity: sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@esbuild/android-arm': 0.18.20 + '@esbuild/android-arm64': 0.18.20 + '@esbuild/android-x64': 0.18.20 + '@esbuild/darwin-arm64': 0.18.20 + '@esbuild/darwin-x64': 0.18.20 + '@esbuild/freebsd-arm64': 0.18.20 + '@esbuild/freebsd-x64': 0.18.20 + '@esbuild/linux-arm': 0.18.20 + '@esbuild/linux-arm64': 0.18.20 + '@esbuild/linux-ia32': 0.18.20 + '@esbuild/linux-loong64': 0.18.20 + '@esbuild/linux-mips64el': 0.18.20 + '@esbuild/linux-ppc64': 0.18.20 + '@esbuild/linux-riscv64': 0.18.20 + '@esbuild/linux-s390x': 0.18.20 + '@esbuild/linux-x64': 0.18.20 + '@esbuild/netbsd-x64': 0.18.20 + '@esbuild/openbsd-x64': 0.18.20 + '@esbuild/sunos-x64': 0.18.20 + '@esbuild/win32-arm64': 0.18.20 + '@esbuild/win32-ia32': 0.18.20 + '@esbuild/win32-x64': 0.18.20 + dev: true + + /fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /get-tsconfig@4.7.2: + resolution: {integrity: sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A==} + dependencies: + resolve-pkg-maps: 1.0.0 + dev: true + + /resolve-pkg-maps@1.0.0: + resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} + dev: true + + /tsx@4.6.0: + resolution: {integrity: sha512-HLHaDQ78mly4Pd5co6tWQOiNVYoYYAPUcwSSZK4bcs3zSEsg+/67LS/ReHook0E7DKPfe1J5jc0ocIhUrnaR4w==} + engines: {node: '>=18.0.0'} + hasBin: true + dependencies: + esbuild: 0.18.20 + get-tsconfig: 4.7.2 + optionalDependencies: + fsevents: 2.3.3 + dev: true + + /undici-types@5.26.5: + resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + dev: true diff --git a/bats/helpers/callback/pnpm-workspace.yaml b/bats/helpers/callback/pnpm-workspace.yaml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/bats/helpers/callback/pnpm-workspace.yaml @@ -0,0 +1 @@ +--- diff --git a/core/api/test/bats/helpers/callback.js b/bats/helpers/callback/src/callback.ts similarity index 92% rename from core/api/test/bats/helpers/callback.js rename to bats/helpers/callback/src/callback.ts index 2ed7673d68..5179aad96c 100644 --- a/core/api/test/bats/helpers/callback.js +++ b/bats/helpers/callback/src/callback.ts @@ -1,4 +1,4 @@ -const http = require("http") +import http from "http" const PORT = 8080 diff --git a/bats/helpers/cli.bash b/bats/helpers/cli.bash index fecdc9fec7..32169544d6 100644 --- a/bats/helpers/cli.bash +++ b/bats/helpers/cli.bash @@ -1,3 +1,15 @@ +tilt_cli() { + tilt $@ +} + +bria_cli() { + docker exec "${COMPOSE_PROJECT_NAME}-bria-1" bria $@ +} + +mongo_cli() { + docker exec "${COMPOSE_PROJECT_NAME}-mongodb-1" mongosh --quiet mongodb://localhost:27017/galoy --eval $@ +} + bitcoin_cli() { docker exec "${COMPOSE_PROJECT_NAME}-bitcoind-1" bitcoin-cli $@ } @@ -10,14 +22,43 @@ lnd_cli() { $@ } -bria_cli() { - docker exec "${COMPOSE_PROJECT_NAME}-bria-1" bria $@ +lnd2_cli() { + docker exec "${COMPOSE_PROJECT_NAME}-lnd2-1" \ + lncli \ + --macaroonpath /root/.lnd/admin.macaroon \ + --tlscertpath /root/.lnd/tls.cert \ + $@ } -tilt_cli() { - tilt $@ +lnd_outside_cli() { + docker exec "${COMPOSE_PROJECT_NAME}-lnd-outside-1-1" \ + lncli \ + --macaroonpath /root/.lnd/admin.macaroon \ + --tlscertpath /root/.lnd/tls.cert \ + $@ } -mongo_cli() { - docker exec "${COMPOSE_PROJECT_NAME}-mongodb-1" mongosh --quiet mongodb://localhost:27017/galoy --eval $@ +lnd_outside_2_cli() { + docker exec "${COMPOSE_PROJECT_NAME}-lnd-outside-2-1" \ + lncli \ + --macaroonpath /root/.lnd/admin.macaroon \ + --tlscertpath /root/.lnd/tls.cert \ + $@ +} + +run_with_lnd() { + local lnd_name="$1" + shift # This will shift away the function name, so $1 becomes the next argument + + if [[ "$lnd_name" == "lnd_cli" ]]; then + lnd_cli "$@" + elif [[ "$lnd_name" == "lnd2_cli" ]]; then + lnd2_cli "$@" + elif [[ "$lnd_name" == "lnd_outside_cli" ]]; then + lnd_outside_cli "$@" + elif [[ "$lnd_name" == "lnd_outside_2_cli" ]]; then + lnd_outside_2_cli "$@" + else + echo "Invalid function name passed!" && return 1 + fi } diff --git a/bats/helpers/ln.bash b/bats/helpers/ln.bash index e068c3859c..82a3015e23 100644 --- a/bats/helpers/ln.bash +++ b/bats/helpers/ln.bash @@ -1,6 +1,120 @@ CURRENT_FILE=${BASH_SOURCE:-bats/helpers/.} source "$(dirname "$CURRENT_FILE")/_common.bash" source "$(dirname "$CURRENT_FILE")/cli.bash" +source "$(dirname "$CURRENT_FILE")/subscriber.bash" + +fund_user_lightning() { + local token_name=$1 + local wallet_id_name="$token_name.${2}_id" # btc_wallet or usd_wallet + local amount=$3 + + variables=$( + jq -n \ + --arg wallet_id "$(read_value $wallet_id_name)" \ + '{input: {walletId: $wallet_id}}' + ) + exec_graphql "$token_name" 'ln-no-amount-invoice-create' "$variables" + invoice="$(graphql_output '.data.lnNoAmountInvoiceCreate.invoice')" + + payment_request="$(echo $invoice | jq -r '.paymentRequest')" + [[ "${payment_request}" != "null" ]] + payment_hash="$(echo $invoice | jq -r '.paymentHash')" + [[ "${payment_hash}" != "null" ]] + + lnd_outside_cli payinvoice -f \ + --pay_req "$payment_request" \ + --amt "$amount" + + retry 15 1 check_for_ln_initiated_settled "$token_name" "$payment_hash" +} + +lnds_init() { + # Clean up any existing channels + close_partner_initiated_channels_with_external || true + + # Mine onchain balance + local amount="1" + local address="$(lnd_outside_cli newaddress p2wkh | jq -r '.address')" + local local_amount="10000000" + local push_amount="5000000" + bitcoin_cli sendtoaddress "$address" "$amount" + bitcoin_cli -generate 3 + + no_pending_channels() { + pending_channel="$(lnd_outside_cli pendingchannels | jq -r '.pending_open_channels[0]')" + if [[ "$pending_channel" != "null" ]]; then + bitcoin_cli -generate 3 + exit 1 + fi + } + + synced_to_graph() { + is_synced="$(lnd_outside_cli getinfo | jq -r '.synced_to_graph')" + [[ "$is_synced" == "true" ]] || exit 1 + } + + # Open channel from lndoutside1 -> lnd1 + pubkey="$(lnd_cli getinfo | jq -r '.identity_pubkey')" + endpoint="${COMPOSE_PROJECT_NAME}-lnd1-1:9735" + + lnd_outside_cli connect "${pubkey}@${endpoint}" || true + retry 10 1 synced_to_graph + lnd_outside_cli openchannel \ + --node_key "$pubkey" \ + --local_amt "$local_amount" + + retry 10 1 mempool_not_empty + retry 10 1 no_pending_channels + + # Open channel with push from lndoutside1 -> lndoutside2 + pubkey="$(lnd_outside_2_cli getinfo | jq -r '.identity_pubkey')" + endpoint="${COMPOSE_PROJECT_NAME}-lnd-outside-2-1:9735" + + lnd_outside_cli connect "${pubkey}@${endpoint}" || true + retry 10 1 synced_to_graph + lnd_outside_cli openchannel \ + --node_key "$pubkey" \ + --local_amt "$local_amount" \ + --push_amt "$push_amount" + + retry 10 1 mempool_not_empty + retry 10 1 no_pending_channels + + # FIXME: we may need some check on the graph or something else + # NB: I get randomly a "no route" error otherwise + sleep 10 +} + +close_partner_initiated_channels_with_external() { + close_channels_with_external() { + lnd_cli_value="$1" + lnd1_pubkey=$(lnd_cli getinfo | jq -r '.identity_pubkey') + lnd2_pubkey=$(lnd2_cli getinfo | jq -r '.identity_pubkey') + + partner_initiated_external_channel_filter=' + .channels[]? + | select(.initiator != true) + | select(.remote_pubkey != $lnd1_pubkey) + | select(.remote_pubkey != $lnd2_pubkey) + | .channel_point + ' + + run_with_lnd "$lnd_cli_value" listchannels \ + | jq -r \ + --arg lnd1_pubkey "$lnd1_pubkey" \ + --arg lnd2_pubkey "$lnd2_pubkey" \ + "$partner_initiated_external_channel_filter" \ + | while read -r channel_point; do + funding_txid="${channel_point%%:*}" + run_with_lnd "$lnd_cli_value" closechannel "$funding_txid" + done + } + + close_channels_with_external lnd_cli + close_channels_with_external lnd2_cli + close_channels_with_external lnd_outside_cli + close_channels_with_external lnd_outside_2_cli +} create_new_lnd_onchain_address() { local wallet_name=$1 @@ -31,3 +145,129 @@ create_new_lnd_onchain_address() { echo $address } + +# Status of LN Payment +check_for_ln_initiated_settled() { + check_for_ln_initiated_status "SUCCESS" "$@" +} + +check_for_ln_initiated_pending() { + check_for_ln_initiated_status "PENDING" "$@" +} + +check_for_ln_initiated_status() { + local expected_status=$1 + local token_name=$2 + local payment_hash=$3 + local first=${4:-"2"} + + variables=$( + jq -n \ + --argjson first "$first" \ + '{"first": $first}' + ) + exec_graphql "$token_name" 'transactions' "$variables" + + status="$(get_from_transaction_by_ln_hash_and_status $payment_hash $expected_status '.status')" + [[ "${status}" == "${expected_status}" ]] || return 1 +} + +get_from_transaction_by_ln_hash_and_status() { + payment_hash="$1" + expected_status="$2" + property_query="$3" + + jq_query=' + .data.me.defaultAccount.transactions.edges[] + | select(.node.initiationVia.paymentHash == $payment_hash) + | select(.node.status == $expected_status) + .node' + + echo $output \ + | jq -r \ + --arg payment_hash "$payment_hash" \ + --arg expected_status "$expected_status" \ + "$jq_query" \ + | jq -r "$property_query" \ + | head -n 1 +} + +mempool_not_empty() { + local txid="$(bitcoin_cli getrawmempool | jq -r ".[0]")" + [[ "$txid" != "null" ]] || exit 1 +} + +num_txns_for_hash() { + token_name="$1" + payment_hash="$2" + + first=20 + txn_variables=$( + jq -n \ + --argjson first "$first" \ + '{"first": $first}' + ) + exec_graphql "$token_name" 'transactions' "$txn_variables" > /dev/null + + jq_query=' + [ + .data.me.defaultAccount.transactions.edges[] + | select(.node.initiationVia.paymentHash == $payment_hash) + ] + | length + ' + echo $output \ + | jq -r \ + --arg payment_hash "$payment_hash" \ + "$jq_query" +} + + +rebalance_channel() { + lnd_cli_value="$1" + lnd_partner_cli_value="$2" + target_local_balance="$3" + + local_pubkey="$(run_with_lnd $lnd_cli_value getinfo | jq -r '.identity_pubkey')" + remote_pubkey="$(run_with_lnd $lnd_partner_cli_value getinfo | jq -r '.identity_pubkey')" + + partner_channel_filter=' + [ + .channels[]? + | select(.remote_pubkey == $remote_pubkey) + ] | first + ' + + channel=$( + run_with_lnd "$lnd_cli_value" listchannels \ + | jq -r \ + --arg remote_pubkey "$remote_pubkey" \ + "$partner_channel_filter" + ) + [[ "$channel" != "null" ]] + + actual_local_balance=$(echo $channel | jq -r '.local_balance') + diff="$(( $actual_local_balance - $target_local_balance ))" + if [[ "$diff" -gt 0 ]]; then + run_with_lnd "$lnd_cli_value" sendpayment --dest=$remote_pubkey --amt=$diff --keysend + elif [[ "$diff" -lt 0 ]]; then + run_with_lnd "$lnd_partner_cli_value" sendpayment --dest=$local_pubkey --amt="$(abs $diff)" --keysend + fi +} + +check_for_ln_update() { + payment_hash=$1 + + retry 10 1 \ + grep "Data.*LnUpdate.*$payment_hash" "$SUBSCRIBER_LOG_FILE" \ + | awk '{print $2}' \ + | jq -r --arg hash "$payment_hash" 'select(.data.myUpdates.update.paymentHash == $hash)' + + paid_status=$( \ + grep 'Data.*LnUpdate' "$SUBSCRIBER_LOG_FILE" \ + | awk '{print $2}' \ + | jq -r --arg hash "$payment_hash" 'select(.data.myUpdates.update.paymentHash == $hash) .data.myUpdates.update.status' + ) + + [[ "$paid_status" == "PAID" ]] || exit 1 +} diff --git a/core/api/test/bats/helpers/ln.bash b/core/api/test/bats/helpers/ln.bash index 27a46870f3..2232f75f73 100644 --- a/core/api/test/bats/helpers/ln.bash +++ b/core/api/test/bats/helpers/ln.bash @@ -334,3 +334,23 @@ num_txns_for_hash() { --arg payment_hash "$payment_hash" \ "$jq_query" } + +lnd_outside_rest() { + local route=$1 + local endpoint="https://localhost:8080/$route" + + local data=$2 + + local macaroon_hex=$( + docker exec "${COMPOSE_PROJECT_NAME}-lnd-outside-1-1" \ + xxd -p -c 10000 /root/.lnd/admin.macaroon + ) + + docker exec "${COMPOSE_PROJECT_NAME}-lnd-outside-1-1" \ + curl -s \ + --cacert /root/.lnd/tls.cert \ + -H "Grpc-Metadata-macaroon: $macaroon_hex" \ + ${data:+ -X POST -d $data} \ + "$endpoint" \ + > "$LNDS_REST_LOG" +} diff --git a/dev/Tiltfile b/dev/Tiltfile index fb99aca329..3b30d2cb18 100644 --- a/dev/Tiltfile +++ b/dev/Tiltfile @@ -317,6 +317,9 @@ docker_groups = { ], "bitcoin": [ "lnd1", + "lnd2", + "lnd-outside-1", + "lnd-outside-2", "bria", "bria-pg", "bitcoind", diff --git a/dev/config/lnd/regtest/lnd-outside-1.admin.macaroon b/dev/config/lnd/regtest/lnd-outside-1.admin.macaroon new file mode 100644 index 0000000000..246395ba4b Binary files /dev/null and b/dev/config/lnd/regtest/lnd-outside-1.admin.macaroon differ diff --git a/dev/config/lnd/regtest/lnd-outside-1.admin.macaroon.base64 b/dev/config/lnd/regtest/lnd-outside-1.admin.macaroon.base64 new file mode 100644 index 0000000000..59cf5d3f0c --- /dev/null +++ b/dev/config/lnd/regtest/lnd-outside-1.admin.macaroon.base64 @@ -0,0 +1 @@ +AgEDbG5kAvgBAwoQeE+5exgz7/0ExCn7H6AJlBIBMBoWCgdhZGRyZXNzEgRyZWFkEgV3cml0ZRoTCgRpbmZvEgRyZWFkEgV3cml0ZRoXCghpbnZvaWNlcxIEcmVhZBIFd3JpdGUaIQoIbWFjYXJvb24SCGdlbmVyYXRlEgRyZWFkEgV3cml0ZRoWCgdtZXNzYWdlEgRyZWFkEgV3cml0ZRoXCghvZmZjaGFpbhIEcmVhZBIFd3JpdGUaFgoHb25jaGFpbhIEcmVhZBIFd3JpdGUaFAoFcGVlcnMSBHJlYWQSBXdyaXRlGhgKBnNpZ25lchIIZ2VuZXJhdGUSBHJlYWQAAAYgL7pU+cKOt6zGyWTdWWmAJLP1L3cnbOPb4Rd3QtniyyM= \ No newline at end of file diff --git a/dev/config/lnd/regtest/lnd-outside-1.macaroons.db b/dev/config/lnd/regtest/lnd-outside-1.macaroons.db new file mode 100644 index 0000000000..404854654f Binary files /dev/null and b/dev/config/lnd/regtest/lnd-outside-1.macaroons.db differ diff --git a/dev/config/lnd/regtest/lnd-outside-1.pubkey b/dev/config/lnd/regtest/lnd-outside-1.pubkey new file mode 100644 index 0000000000..0e42d91614 --- /dev/null +++ b/dev/config/lnd/regtest/lnd-outside-1.pubkey @@ -0,0 +1 @@ +02147eeb1561922fe768a6a92df116f5fec8c1869ddcb6e00ee1fd0df146d51c4a diff --git a/dev/config/lnd/regtest/lnd-outside-1.wallet.db b/dev/config/lnd/regtest/lnd-outside-1.wallet.db new file mode 100644 index 0000000000..11628ce86c Binary files /dev/null and b/dev/config/lnd/regtest/lnd-outside-1.wallet.db differ diff --git a/dev/config/lnd/regtest/lnd-outside-2.admin.macaroon b/dev/config/lnd/regtest/lnd-outside-2.admin.macaroon new file mode 100644 index 0000000000..e35a69ee59 Binary files /dev/null and b/dev/config/lnd/regtest/lnd-outside-2.admin.macaroon differ diff --git a/dev/config/lnd/regtest/lnd-outside-2.admin.macaroon.base64 b/dev/config/lnd/regtest/lnd-outside-2.admin.macaroon.base64 new file mode 100644 index 0000000000..826591de2e --- /dev/null +++ b/dev/config/lnd/regtest/lnd-outside-2.admin.macaroon.base64 @@ -0,0 +1 @@ +AgEDbG5kAvgBAwoQfKO82/iPT2zIwWYPrOXvABIBMBoWCgdhZGRyZXNzEgRyZWFkEgV3cml0ZRoTCgRpbmZvEgRyZWFkEgV3cml0ZRoXCghpbnZvaWNlcxIEcmVhZBIFd3JpdGUaIQoIbWFjYXJvb24SCGdlbmVyYXRlEgRyZWFkEgV3cml0ZRoWCgdtZXNzYWdlEgRyZWFkEgV3cml0ZRoXCghvZmZjaGFpbhIEcmVhZBIFd3JpdGUaFgoHb25jaGFpbhIEcmVhZBIFd3JpdGUaFAoFcGVlcnMSBHJlYWQSBXdyaXRlGhgKBnNpZ25lchIIZ2VuZXJhdGUSBHJlYWQAAAYg2XkV+4Z4inbfXGZivRoY+r7KHNZhgxkCEdKByxbeb/Q= \ No newline at end of file diff --git a/dev/config/lnd/regtest/lnd-outside-2.macaroons.db b/dev/config/lnd/regtest/lnd-outside-2.macaroons.db new file mode 100644 index 0000000000..a052db71f6 Binary files /dev/null and b/dev/config/lnd/regtest/lnd-outside-2.macaroons.db differ diff --git a/dev/config/lnd/regtest/lnd-outside-2.pubkey b/dev/config/lnd/regtest/lnd-outside-2.pubkey new file mode 100644 index 0000000000..6c6acab50f --- /dev/null +++ b/dev/config/lnd/regtest/lnd-outside-2.pubkey @@ -0,0 +1 @@ +02f4888c0fffc494874da4445918dadaf88a63dbb96bce734b087bed56f60d231b diff --git a/dev/config/lnd/regtest/lnd-outside-2.wallet.db b/dev/config/lnd/regtest/lnd-outside-2.wallet.db new file mode 100644 index 0000000000..984b96b79d Binary files /dev/null and b/dev/config/lnd/regtest/lnd-outside-2.wallet.db differ diff --git a/dev/config/lnd/regtest/lnd2.admin.macaroon b/dev/config/lnd/regtest/lnd2.admin.macaroon new file mode 100644 index 0000000000..f414781ae8 Binary files /dev/null and b/dev/config/lnd/regtest/lnd2.admin.macaroon differ diff --git a/dev/config/lnd/regtest/lnd2.admin.macaroon.base64 b/dev/config/lnd/regtest/lnd2.admin.macaroon.base64 new file mode 100644 index 0000000000..22252d2a37 --- /dev/null +++ b/dev/config/lnd/regtest/lnd2.admin.macaroon.base64 @@ -0,0 +1 @@ +AgEDbG5kAvgBAwoQX0BxfhQTxLTiqaceBnGnfBIBMBoWCgdhZGRyZXNzEgRyZWFkEgV3cml0ZRoTCgRpbmZvEgRyZWFkEgV3cml0ZRoXCghpbnZvaWNlcxIEcmVhZBIFd3JpdGUaIQoIbWFjYXJvb24SCGdlbmVyYXRlEgRyZWFkEgV3cml0ZRoWCgdtZXNzYWdlEgRyZWFkEgV3cml0ZRoXCghvZmZjaGFpbhIEcmVhZBIFd3JpdGUaFgoHb25jaGFpbhIEcmVhZBIFd3JpdGUaFAoFcGVlcnMSBHJlYWQSBXdyaXRlGhgKBnNpZ25lchIIZ2VuZXJhdGUSBHJlYWQAAAYgMAKlr1HehfBpn2R5RPE2IuY9r/18QBeLZxYgRidpos4= \ No newline at end of file diff --git a/dev/config/lnd/regtest/lnd2.macaroons.db b/dev/config/lnd/regtest/lnd2.macaroons.db new file mode 100644 index 0000000000..4d55f07bc5 Binary files /dev/null and b/dev/config/lnd/regtest/lnd2.macaroons.db differ diff --git a/dev/config/lnd/regtest/lnd2.pubkey b/dev/config/lnd/regtest/lnd2.pubkey new file mode 100644 index 0000000000..6a3156846d --- /dev/null +++ b/dev/config/lnd/regtest/lnd2.pubkey @@ -0,0 +1 @@ +039341ef13e776dc1611502cf510110d9ac5cdc252141f5997adcfd72cef34c3a7 diff --git a/dev/config/lnd/regtest/lnd2.wallet.db b/dev/config/lnd/regtest/lnd2.wallet.db new file mode 100644 index 0000000000..85dd05c326 Binary files /dev/null and b/dev/config/lnd/regtest/lnd2.wallet.db differ diff --git a/dev/docker-compose.deps.yml b/dev/docker-compose.deps.yml index 9dcebc8895..f885eddae9 100644 --- a/dev/docker-compose.deps.yml +++ b/dev/docker-compose.deps.yml @@ -4,45 +4,45 @@ services: price: image: us.gcr.io/galoy-org/price:edge ports: - - 50051:50051 - - 9464:9464 + - 50051:50051 + - 9464:9464 price-history: image: us.gcr.io/galoy-org/price-history:edge ports: - - 50052:50052 + - 50052:50052 command: ./scripts/run-servers-dev.sh environment: - - DB_HOST=price-history-pg - - DB_PORT=5432 - - DB_USER=galoy-price-usr - - DB_PWD=galoy-price-pwd - - DB_DB=galoy-price-history - - DB_POOL_MIN=1 - - DB_POOL_MAX=5 - - DB_DEBUG=false + - DB_HOST=price-history-pg + - DB_PORT=5432 + - DB_USER=galoy-price-usr + - DB_PWD=galoy-price-pwd + - DB_DB=galoy-price-history + - DB_POOL_MIN=1 + - DB_POOL_MAX=5 + - DB_DEBUG=false depends_on: - - price-history-pg - - price-history-migrate + - price-history-pg + - price-history-migrate price-history-migrate: image: us.gcr.io/galoy-org/price-history-migrate:edge ports: [] environment: - - DB_HOST=price-history-pg - - DB_PORT=5432 - - DB_USER=galoy-price-usr - - DB_PWD=galoy-price-pwd - - DB_DB=galoy-price-history - - DB_POOL_MIN=1 - - DB_POOL_MAX=5 - - DB_DEBUG=false + - DB_HOST=price-history-pg + - DB_PORT=5432 + - DB_USER=galoy-price-usr + - DB_PWD=galoy-price-pwd + - DB_DB=galoy-price-history + - DB_POOL_MIN=1 + - DB_POOL_MAX=5 + - DB_DEBUG=false depends_on: - - price-history-pg + - price-history-pg price-history-pg: image: postgres:14.1 environment: - - POSTGRES_USER=galoy-price-usr - - POSTGRES_PASSWORD=galoy-price-pwd - - POSTGRES_DB=galoy-price-history + - POSTGRES_USER=galoy-price-usr + - POSTGRES_PASSWORD=galoy-price-pwd + - POSTGRES_DB=galoy-price-history api-keys-pg: image: postgres:14.1 environment: @@ -173,6 +173,66 @@ services: cp /root/.lnd/macaroons.db /root/.lnd/data/chain/bitcoin/regtest/macaroons.db cp /root/.lnd/admin.macaroon /root/.lnd/data/chain/bitcoin/regtest/admin.macaroon /bin/lnd + lnd2: + image: lightninglabs/lnd:v0.16.2-beta + ports: + - "10010:10009" + volumes: + - ${HOST_PROJECT_PATH:-.}/config/lnd/lnd.conf:/root/.lnd/lnd.conf + - ${HOST_PROJECT_PATH:-.}/config/lnd/tls.key:/root/.lnd/tls.key + - ${HOST_PROJECT_PATH:-.}/config/lnd/tls.cert:/root/.lnd/tls.cert + - ${HOST_PROJECT_PATH:-.}/config/lnd/regtest/lnd2.wallet.db:/root/.lnd/wallet.db + - ${HOST_PROJECT_PATH:-.}/config/lnd/regtest/lnd2.macaroons.db:/root/.lnd/macaroons.db + - ${HOST_PROJECT_PATH:-.}/config/lnd/regtest/lnd2.admin.macaroon:/root/.lnd/admin.macaroon + depends_on: [bitcoind] + entrypoint: ["/bin/sh", "-c"] + command: + - | + mkdir -p /root/.lnd/data/chain/bitcoin/regtest/ + cp /root/.lnd/wallet.db /root/.lnd/data/chain/bitcoin/regtest/wallet.db + cp /root/.lnd/macaroons.db /root/.lnd/data/chain/bitcoin/regtest/macaroons.db + cp /root/.lnd/admin.macaroon /root/.lnd/data/chain/bitcoin/regtest/admin.macaroon + /bin/lnd + lnd-outside-1: + image: lightninglabs/lnd:v0.16.2-beta + ports: + - "10012:10009" + volumes: + - ${HOST_PROJECT_PATH:-.}/config/lnd/lnd.conf:/root/.lnd/lnd.conf + - ${HOST_PROJECT_PATH:-.}/config/lnd/tls.key:/root/.lnd/tls.key + - ${HOST_PROJECT_PATH:-.}/config/lnd/tls.cert:/root/.lnd/tls.cert + - ${HOST_PROJECT_PATH:-.}/config/lnd/regtest/lnd-outside-1.wallet.db:/root/.lnd/wallet.db + - ${HOST_PROJECT_PATH:-.}/config/lnd/regtest/lnd-outside-1.macaroons.db:/root/.lnd/macaroons.db + - ${HOST_PROJECT_PATH:-.}/config/lnd/regtest/lnd-outside-1.admin.macaroon:/root/.lnd/admin.macaroon + entrypoint: ["/bin/sh", "-c"] + command: + - | + mkdir -p /root/.lnd/data/chain/bitcoin/regtest/ + cp /root/.lnd/wallet.db /root/.lnd/data/chain/bitcoin/regtest/wallet.db + cp /root/.lnd/macaroons.db /root/.lnd/data/chain/bitcoin/regtest/macaroons.db + cp /root/.lnd/admin.macaroon /root/.lnd/data/chain/bitcoin/regtest/admin.macaroon + /bin/lnd + depends_on: [bitcoind] + lnd-outside-2: + image: lightninglabs/lnd:v0.16.2-beta + ports: + - "10013:10009" + volumes: + - ${HOST_PROJECT_PATH:-.}/config/lnd/lnd.conf:/root/.lnd/lnd.conf + - ${HOST_PROJECT_PATH:-.}/config/lnd/tls.key:/root/.lnd/tls.key + - ${HOST_PROJECT_PATH:-.}/config/lnd/tls.cert:/root/.lnd/tls.cert + - ${HOST_PROJECT_PATH:-.}/config/lnd/regtest/lnd-outside-2.wallet.db:/root/.lnd/wallet.db + - ${HOST_PROJECT_PATH:-.}/config/lnd/regtest/lnd-outside-2.macaroons.db:/root/.lnd/macaroons.db + - ${HOST_PROJECT_PATH:-.}/config/lnd/regtest/lnd-outside-2.admin.macaroon:/root/.lnd/admin.macaroon + entrypoint: ["/bin/sh", "-c"] + command: + - | + mkdir -p /root/.lnd/data/chain/bitcoin/regtest/ + cp /root/.lnd/wallet.db /root/.lnd/data/chain/bitcoin/regtest/wallet.db + cp /root/.lnd/macaroons.db /root/.lnd/data/chain/bitcoin/regtest/macaroons.db + cp /root/.lnd/admin.macaroon /root/.lnd/data/chain/bitcoin/regtest/admin.macaroon + /bin/lnd + depends_on: [bitcoind] bria: image: us.gcr.io/galoy-org/bria:latest ports: @@ -284,4 +344,4 @@ services: - otel-agent restart: on-failure:10 volumes: - - ${HOST_PROJECT_PATH:-.}/:/repo \ No newline at end of file + - ${HOST_PROJECT_PATH:-.}/:/repo