diff --git a/docker-compose.yml b/docker-compose.yml index ddad68915..96c8a1277 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,6 +20,7 @@ services: # - lnd-outside-1 - svix # - lnd-outside-2 + - otel-agent restart: on-failure:10 integration-deps: image: busybox diff --git a/src/app/lightning/payment-status-checker.ts b/src/app/lightning/payment-status-checker.ts index a1e101bbc..2df237489 100644 --- a/src/app/lightning/payment-status-checker.ts +++ b/src/app/lightning/payment-status-checker.ts @@ -14,7 +14,7 @@ export const PaymentStatusChecker = async (uncheckedPaymentRequest: string) => { isExpired, // invoiceIsPaid should have no awareness of Ibex. TODO: add to Wallets interface invoiceIsPaid: async (): Promise => { - const ibexResp = await Ibex.invoiceFromHash({ invoice_hash: paymentHash }) + const ibexResp = await Ibex().invoiceFromHash({ invoice_hash: paymentHash }) if (ibexResp instanceof IbexClientError) return ibexResp baseLogger.info(ibexResp.status) return ibexResp.state?.id === 1 // Invoice states: https://docs.ibexmercado.com/reference/flow#invoice-states-table diff --git a/src/app/wallets/create-on-chain-address.ts b/src/app/wallets/create-on-chain-address.ts index 255ff46df..f8e787002 100644 --- a/src/app/wallets/create-on-chain-address.ts +++ b/src/app/wallets/create-on-chain-address.ts @@ -25,7 +25,7 @@ export const createOnChainAddress = async ({ const accountValidator = AccountValidator(account) if (accountValidator instanceof Error) return accountValidator - const resp = await Ibex.generateBitcoinAddress({ accountId: walletId }) + const resp = await Ibex().generateBitcoinAddress({ accountId: walletId }) if (resp instanceof IbexClientError) return resp else if (!resp.address) return new IbexClientError("Address not returned") else return resp.address diff --git a/src/app/wallets/get-transactions-for-wallet.ts b/src/app/wallets/get-transactions-for-wallet.ts index 1b8088ec3..26625232c 100644 --- a/src/app/wallets/get-transactions-for-wallet.ts +++ b/src/app/wallets/get-transactions-for-wallet.ts @@ -23,7 +23,7 @@ export const getTransactionsForWallets = async ({ // Flash fork: return history from Ibex const ibexCalls = await Promise.all(walletIds - .map(id => Ibex.getAccountTransactions({ + .map(id => Ibex().getAccountTransactions({ account_id: id, })) ) diff --git a/src/graphql/public/root/mutation/ln-invoice-fee-probe.ts b/src/graphql/public/root/mutation/ln-invoice-fee-probe.ts index e1cbad52b..cf7c705b9 100644 --- a/src/graphql/public/root/mutation/ln-invoice-fee-probe.ts +++ b/src/graphql/public/root/mutation/ln-invoice-fee-probe.ts @@ -52,7 +52,7 @@ const LnInvoiceFeeProbeMutation = GT.Field< // walletId, // uncheckedPaymentRequest: paymentRequest, // }) - const resp: any | IbexClientError = await Ibex.getFeeEstimation({ + const resp: any | IbexClientError = await Ibex().getFeeEstimation({ // walletId, // we are not checking internal payment flow bolt11: paymentRequest, }) diff --git a/src/graphql/public/root/mutation/ln-invoice-payment-send.ts b/src/graphql/public/root/mutation/ln-invoice-payment-send.ts index 9daad654a..ede7e8cba 100644 --- a/src/graphql/public/root/mutation/ln-invoice-payment-send.ts +++ b/src/graphql/public/root/mutation/ln-invoice-payment-send.ts @@ -74,7 +74,7 @@ const LnInvoicePaymentSendMutation = GT.Field< */ if (!domainAccount) throw new Error("Authentication required") - const PayLightningInvoice = await Ibex.payInvoiceV2({ + const PayLightningInvoice = await Ibex().payInvoiceV2({ bolt11: paymentRequest, accountId: walletId, }) diff --git a/src/graphql/public/root/mutation/ln-noamount-invoice-create.ts b/src/graphql/public/root/mutation/ln-noamount-invoice-create.ts index 232af7653..7530e2edf 100644 --- a/src/graphql/public/root/mutation/ln-noamount-invoice-create.ts +++ b/src/graphql/public/root/mutation/ln-noamount-invoice-create.ts @@ -50,7 +50,7 @@ const LnNoAmountInvoiceCreateMutation = GT.Field({ // FLASH FORK: create IBEX invoice instead of Galoy invoice // TODO: move this into Wallets.addInvoiceNoAmountForSelf - const resp = await Ibex.addInvoice({ + const resp = await Ibex().addInvoice({ amount: 0, accountId: walletId, memo, diff --git a/src/graphql/public/root/mutation/ln-noamount-usd-invoice-fee-probe.ts b/src/graphql/public/root/mutation/ln-noamount-usd-invoice-fee-probe.ts index 67fdddaf4..0447057db 100644 --- a/src/graphql/public/root/mutation/ln-noamount-usd-invoice-fee-probe.ts +++ b/src/graphql/public/root/mutation/ln-noamount-usd-invoice-fee-probe.ts @@ -50,7 +50,7 @@ const LnNoAmountUsdInvoiceFeeProbeMutation = GT.Field({ // }) // TODO: Move Ibex call to Payments interface - const resp: any | IbexClientError = await Ibex.getFeeEstimation({ + const resp: any | IbexClientError = await Ibex().getFeeEstimation({ bolt11: paymentRequest, amount: String(amount / 100), currencyId: "3" diff --git a/src/graphql/public/root/mutation/ln-noamount-usd-invoice-payment-send.ts b/src/graphql/public/root/mutation/ln-noamount-usd-invoice-payment-send.ts index 3553bbcde..3a4c94a51 100644 --- a/src/graphql/public/root/mutation/ln-noamount-usd-invoice-payment-send.ts +++ b/src/graphql/public/root/mutation/ln-noamount-usd-invoice-payment-send.ts @@ -84,7 +84,7 @@ const LnNoAmountUsdInvoicePaymentSendMutation = GT.Field< if (!domainAccount) throw new Error("Authentication required") // eslint-disable-next-line @typescript-eslint/no-explicit-any - const PayLightningInvoice = await Ibex.payInvoiceV2({ + const PayLightningInvoice = await Ibex().payInvoiceV2({ bolt11: paymentRequest, accountId: walletId, amount: amount / 100, diff --git a/src/graphql/public/root/mutation/ln-usd-invoice-create.ts b/src/graphql/public/root/mutation/ln-usd-invoice-create.ts index 2f52a009f..3e1540b86 100644 --- a/src/graphql/public/root/mutation/ln-usd-invoice-create.ts +++ b/src/graphql/public/root/mutation/ln-usd-invoice-create.ts @@ -54,7 +54,7 @@ const LnUsdInvoiceCreateMutation = GT.Field({ } // FLASH FORK: create IBEX invoice instead of Galoy invoice - const resp = await Ibex.addInvoice({ + const resp = await Ibex().addInvoice({ amount: amount / 100, accountId: walletId, memo, diff --git a/src/graphql/public/root/mutation/ln-usd-invoice-fee-probe.ts b/src/graphql/public/root/mutation/ln-usd-invoice-fee-probe.ts index a7ccf3a7f..e2950dd18 100644 --- a/src/graphql/public/root/mutation/ln-usd-invoice-fee-probe.ts +++ b/src/graphql/public/root/mutation/ln-usd-invoice-fee-probe.ts @@ -65,7 +65,7 @@ const LnUsdInvoiceFeeProbeMutation = GT.Field< // uncheckedPaymentRequest: paymentRequest, // }) - const resp: any | IbexClientError = await Ibex.getFeeEstimation({ + const resp: any | IbexClientError = await Ibex().getFeeEstimation({ // walletId, // we are not checking internal payment flow bolt11: paymentRequest, }) diff --git a/src/graphql/public/root/mutation/on-chain-address-current.ts b/src/graphql/public/root/mutation/on-chain-address-current.ts index 67f33a2f0..b32ecbcff 100644 --- a/src/graphql/public/root/mutation/on-chain-address-current.ts +++ b/src/graphql/public/root/mutation/on-chain-address-current.ts @@ -33,7 +33,7 @@ const OnChainAddressCurrentMutation = GT.Field({ // const address = await Wallets.getLastOnChainAddress(walletId) // eslint-disable-next-line @typescript-eslint/no-explicit-any - const resp = await Ibex.generateBitcoinAddress({ + const resp = await Ibex().generateBitcoinAddress({ accountId: walletId, }) diff --git a/src/graphql/public/root/mutation/onchain-usd-payment-send-as-sats.ts b/src/graphql/public/root/mutation/onchain-usd-payment-send-as-sats.ts index 6bedbb37c..c49962ad9 100644 --- a/src/graphql/public/root/mutation/onchain-usd-payment-send-as-sats.ts +++ b/src/graphql/public/root/mutation/onchain-usd-payment-send-as-sats.ts @@ -80,7 +80,7 @@ const OnChainUsdPaymentSendAsBtcDenominatedMutation = GT.Field< // }) if (!domainAccount) throw new Error("Authentication required") - const resp = await Ibex.sendToAddressV2({ + const resp = await Ibex().sendToAddressV2({ accountId: walletId, address, amount: toCents(amount), diff --git a/src/graphql/public/root/mutation/onchain-usd-payment-send.ts b/src/graphql/public/root/mutation/onchain-usd-payment-send.ts index e2ba26b50..e157cd571 100644 --- a/src/graphql/public/root/mutation/onchain-usd-payment-send.ts +++ b/src/graphql/public/root/mutation/onchain-usd-payment-send.ts @@ -79,7 +79,7 @@ const OnChainUsdPaymentSendMutation = GT.Field< // }) if (!domainAccount) throw new Error("Authentication required") - const resp = await Ibex.sendToAddressV2({ + const resp = await Ibex().sendToAddressV2({ accountId: walletId, address, amount: amount / 100, diff --git a/src/graphql/public/root/query/globals.ts b/src/graphql/public/root/query/globals.ts index 1e81ea04b..4a359df1a 100644 --- a/src/graphql/public/root/query/globals.ts +++ b/src/graphql/public/root/query/globals.ts @@ -18,11 +18,11 @@ const feesConfig = getFeesConfig() const GlobalsQuery = GT.Field({ type: Globals, resolve: async () => { - let nodesIds = await Lightning.listNodesPubkeys() - if (nodesIds instanceof Error) nodesIds = [] + // let nodesIds = await Lightning.listNodesPubkeys() + // if (nodesIds instanceof Error) nodesIds = [] return { - nodesIds, + nodesIds: [], network: NETWORK, lightningAddressDomain: getLightningAddressDomain(), lightningAddressDomainAliases: getLightningAddressDomainAliases(), diff --git a/src/graphql/public/root/query/on-chain-usd-tx-fee-query.ts b/src/graphql/public/root/query/on-chain-usd-tx-fee-query.ts index 50e20ad97..5261a8104 100644 --- a/src/graphql/public/root/query/on-chain-usd-tx-fee-query.ts +++ b/src/graphql/public/root/query/on-chain-usd-tx-fee-query.ts @@ -45,7 +45,7 @@ const OnChainUsdTxFeeQuery = GT.Field({ // speed, // }) - const resp = await Ibex.estimateFeeV2({ + const resp = await Ibex().estimateFeeV2({ "currency-id": "3", // ref/create USD enum/constant address: address, amount: amount / 100, diff --git a/src/services/ibex/client/authentication/index.ts b/src/services/ibex/client/authentication/index.ts index 13684fd5e..084ff4e59 100644 --- a/src/services/ibex/client/authentication/index.ts +++ b/src/services/ibex/client/authentication/index.ts @@ -4,8 +4,7 @@ import { IbexApiError, IbexAuthenticationError, IbexClientError } from "../error import Redis from "./redis-datastore"; import { FetchResponse } from "api/dist/core"; import { CacheServiceError, CacheUndefinedError } from "@domain/cache"; -import { baseLogger as log } from "@services/logger"; -import { logResponse } from "../errors/logger"; +import { wrapAsyncToRunInSpan } from "@services/tracing"; // TODO: Divide this into setAccessToken and setRefreshToken which take Partial const storeTokens = async (signInResp: SignInResponse200): Promise => { @@ -17,30 +16,27 @@ const storeTokens = async (signInResp: SignInResponse200): Promise => { } = signInResp if (!accessToken) return Promise.reject(new IbexClientError("No access token found in Ibex response body")) - const atResp = await Redis.setAccessToken(accessToken, accessTokenExpiresAt) + await Redis.setAccessToken(accessToken, accessTokenExpiresAt) IbexSDK.auth(accessToken) if (!refreshToken) return Promise.reject(new IbexClientError("No refresh token found in Ibex response body")) - const rtResp = await Redis.setRefreshToken(refreshToken, refreshTokenExpiresAt) - - if (atResp instanceof CacheServiceError) log.warn(`IBEX: Failed to write accessToken to redis cache: ${atResp.message}`) - if (rtResp instanceof CacheServiceError) log.warn(`IBEX: Failed to write refreshToken to redis cache: ${rtResp.message}`) + await Redis.setRefreshToken(refreshToken, refreshTokenExpiresAt) } -const signIn = async (): Promise => { - log.info("IBEX: Signing in...") - return IbexSDK.signIn({ email: IBEX_EMAIL, password: IBEX_PASSWORD }) - .then(_ => _.data) - .then(_ => storeTokens(_)) - .catch(e => new IbexApiError(e.status, e.data)) - .then(logResponse) -} +const signIn = wrapAsyncToRunInSpan({ + namespace: "service.ibex.client", + fnName: "signIn", + fn: async (): Promise => { + return IbexSDK.signIn({ email: IBEX_EMAIL, password: IBEX_PASSWORD }) + .then(_ => _.data) + .then(_ => storeTokens(_)) + .catch(e => new IbexApiError(e.status, e.data)) + } +}) const refreshAccessToken = async (): Promise => { - log.info("IBEX: Refreshing token...") const tokenOrErr = await Redis.getRefreshToken() if (tokenOrErr instanceof CacheUndefinedError) { - log.info("IBEX: Refresh token not found.") return await signIn().catch((e: IbexApiError) => new IbexAuthenticationError(e)) } if (tokenOrErr instanceof CacheServiceError) return new IbexAuthenticationError(tokenOrErr) @@ -60,7 +56,6 @@ export const withAuth = async (apiCall: () => Promise> const atResp = await Redis.getAccessToken() if (atResp instanceof CacheUndefinedError) { - log.info("IBEX: Access token not found.") const refreshResp = await refreshAccessToken() if (refreshResp instanceof IbexAuthenticationError) return refreshResp } else if (atResp instanceof CacheServiceError) return new IbexAuthenticationError(atResp) @@ -70,7 +65,6 @@ export const withAuth = async (apiCall: () => Promise> return (await apiCall()).data } catch (err: any) { if (err.status === 401) { - log.info("IBEX: Access token unauthorized.") const refreshResp = await refreshAccessToken() if (refreshResp instanceof IbexAuthenticationError) return refreshResp return (await apiCall()).data diff --git a/src/services/ibex/client/errors/logger.ts b/src/services/ibex/client/errors/logger.ts deleted file mode 100644 index f2156185f..000000000 --- a/src/services/ibex/client/errors/logger.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { baseLogger as log } from "@services/logger" -import { IbexClientError } from "." - -export const logRequest = (method: string, params: any): void => { - log.info(params, `Calling Ibex.${method}. Request params:`) -} - -export const logResponse = (e: any) => { - if (e instanceof IbexClientError) log.error(e) - else log.info(e, "Response Data:") - return e -} \ No newline at end of file diff --git a/src/services/ibex/client/index.ts b/src/services/ibex/client/index.ts index 68036ac57..be9d342e9 100644 --- a/src/services/ibex/client/index.ts +++ b/src/services/ibex/client/index.ts @@ -1,119 +1,112 @@ // Ibex SDK API registry: https://dash.readme.com/api/v1/api-registry/cpd51bloegfhl2 import IbexSDK, * as types from "./.api/apis/sing-in" // TODO: @sing-in@ -import { IbexClientError, IbexAuthenticationError, IbexApiError } from "./errors" +import { IbexAuthenticationError, IbexApiError } from "./errors" import { withAuth } from "./authentication"; -import { logRequest, logResponse } from "./errors/logger" import WebhookServer from "../webhook-server" +import { addAttributesToCurrentSpan, wrapAsyncFunctionsToRunInSpan } from "@services/tracing" -// This is a wrapper around the Ibex api that handles authentication -class AuthenticatedIbexClient { - private static instance: AuthenticatedIbexClient | null = null; - private constructor() {} - - static getInstance(): AuthenticatedIbexClient { - if (!AuthenticatedIbexClient.instance) { - AuthenticatedIbexClient.instance = new AuthenticatedIbexClient(); - } - return AuthenticatedIbexClient.instance; - } - - async getAccountTransactions(metadata: types.GMetadataParam): Promise { - logRequest("getAccountTransactions", metadata) +// This is a wrapper around the Ibex api that adds tracing & authentication +export default () => { + const getAccountTransactions = async (metadata: types.GMetadataParam): Promise => { + addAttributesToCurrentSpan({ "request.params": JSON.stringify(metadata) }) return withAuth(() => IbexSDK.g(metadata)) - .catch(_ => new IbexApiError(_.status, _.data)) - .then(logResponse) + .catch(e => new IbexApiError(e.status, e.data)) } - async getTransactionDetails(metadata: types.GetTransactionDetails1MetadataParam): Promise { - logRequest("getTransactionDetails", metadata) + const getTransactionDetails = async (metadata: types.GetTransactionDetails1MetadataParam): Promise => { + addAttributesToCurrentSpan({ "request.params": JSON.stringify(metadata) }) return withAuth(() => IbexSDK.getTransactionDetails1(metadata)) - .catch(_ => new IbexApiError(_.status, _.data)) - .then(logResponse) + .catch(e => new IbexApiError(e.status, e.data)) } - async createAccount(body: types.CreateAccountBodyParam): Promise { - logRequest("createAccount", body) + const createAccount = async (body: types.CreateAccountBodyParam): Promise => { + addAttributesToCurrentSpan({ "request.params": JSON.stringify(body) }) return withAuth(() => IbexSDK.createAccount(body)) - .catch(_ => new IbexApiError(_.status, _.data)) - .then(logResponse) + .catch(e => new IbexApiError(e.status, e.data)) } - async getAccountDetails(metadata: types.GetAccountDetailsMetadataParam): Promise { - logRequest("getAccountDetails", metadata) + const getAccountDetails = async (metadata: types.GetAccountDetailsMetadataParam): Promise => { + addAttributesToCurrentSpan({ "request.params": JSON.stringify(metadata) }) return withAuth(() => IbexSDK.getAccountDetails(metadata)) - .catch(_ => new IbexApiError(_.status, _.data)) - .then(logResponse) + .catch(e => new IbexApiError(e.status, e.data)) } - async generateBitcoinAddress(body: types.GenerateBitcoinAddressBodyParam): Promise { - logRequest("generateBitcoinAddress", body) + const generateBitcoinAddress = async (body: types.GenerateBitcoinAddressBodyParam): Promise => { + addAttributesToCurrentSpan({ "request.params": JSON.stringify(body) }) return withAuth(() => IbexSDK.generateBitcoinAddress(body)) - .catch(_ => new IbexApiError(_.status, _.data)) - .then(logResponse) + .catch(e => new IbexApiError(e.status, e.data)) } - async addInvoice(body: types.AddInvoiceBodyParam): Promise { + const addInvoice = async (body: types.AddInvoiceBodyParam): Promise => { const bodyWithHooks = { ...body, webhookUrl: WebhookServer.endpoints.onReceive, webhookSecret: WebhookServer.secret, } as types.AddInvoiceBodyParam - logRequest("addInvoice", bodyWithHooks) + addAttributesToCurrentSpan({ "request.params": JSON.stringify(body) }) return withAuth(() => IbexSDK.addInvoice(bodyWithHooks)) - .catch(_ => new IbexApiError(_.status, _.data)) - .then(logResponse) + .catch(e => new IbexApiError(e.status, e.data)) } - async invoiceFromHash(metadata: types.InvoiceFromHashMetadataParam): Promise { - logRequest("invoiceFromHash", metadata) + const invoiceFromHash = async (metadata: types.InvoiceFromHashMetadataParam): Promise => { + addAttributesToCurrentSpan({ "request.params": JSON.stringify(metadata) }) return withAuth(() => IbexSDK.invoiceFromHash(metadata)) - .catch(_ => new IbexApiError(_.status, _.data)) - .then(logResponse) + .catch(e => new IbexApiError(e.status, e.data)) } // LN fee estimation // GetFeeEstimationResponse200 not defined - async getFeeEstimation(metadata: types.GetFeeEstimationMetadataParam): Promise { - logRequest("getFeeEstimation", metadata) + const getFeeEstimation = async (metadata: types.GetFeeEstimationMetadataParam): Promise => { + addAttributesToCurrentSpan({ "request.params": JSON.stringify(metadata) }) return withAuth(() => IbexSDK.getFeeEstimation(metadata)) - .catch(_ => new IbexApiError(_.status, _.data)) - .then(logResponse) + .catch(e => new IbexApiError(e.status, e.data)) } - async payInvoiceV2(body: types.PayInvoiceV2BodyParam): Promise { + const payInvoiceV2 = async (body: types.PayInvoiceV2BodyParam): Promise => { const bodyWithHooks = { ...body, webhookUrl: WebhookServer.endpoints.onPay, webhookSecret: WebhookServer.secret, } as types.PayInvoiceV2BodyParam - logRequest("payInvoiceV2", bodyWithHooks) + addAttributesToCurrentSpan({ "request.params": JSON.stringify(body) }) return withAuth(() => IbexSDK.payInvoiceV2(bodyWithHooks)) - .catch(_ => new IbexApiError(_.status, _.data)) - .then(logResponse) + .catch(e => new IbexApiError(e.status, e.data)) } - async sendToAddressV2(body: types.SendToAddressCopyBodyParam): Promise { - logRequest("sendToAddressV2", body) + const sendToAddressV2 = async (body: types.SendToAddressCopyBodyParam): Promise => { + addAttributesToCurrentSpan({ "request.params": JSON.stringify(body) }) return withAuth(() => IbexSDK.sendToAddressCopy(body)) - .catch(_ => new IbexApiError(_.status, _.data)) - .then(logResponse) + .catch(e => new IbexApiError(e.status, e.data)) } // onchain fee estimation - async estimateFeeV2(metadata: types.EstimateFeeCopyMetadataParam): Promise { - logRequest("estimateFeeV2", metadata) + const estimateFeeV2 = async (metadata: types.EstimateFeeCopyMetadataParam): Promise => { + addAttributesToCurrentSpan({ "request.params": JSON.stringify(metadata) }) return withAuth(() => IbexSDK.estimateFeeCopy(metadata)) - .catch(_ => new IbexApiError(_.status, _.data)) - .then(logResponse) + .catch(e => new IbexApiError(e.status, e.data)) } - async createLnurlPay(body: types.CreateLnurlPayBodyParam): Promise { - logRequest("createLnurlPay", body) + const createLnurlPay = async (body: types.CreateLnurlPayBodyParam): Promise => { + addAttributesToCurrentSpan({ "request.params": JSON.stringify(body) }) return withAuth(() => IbexSDK.createLnurlPay(body)) - .catch(_ => new IbexApiError(_.status, _.data)) - .then(logResponse) + .catch(e => new IbexApiError(e.status, e.data)) } -} -// TODO: Change to static class -export default AuthenticatedIbexClient.getInstance() + return wrapAsyncFunctionsToRunInSpan({ + namespace: "services.ibex.client", + fns: { + getAccountTransactions, + getTransactionDetails, + createAccount, + getAccountDetails, + generateBitcoinAddress, + addInvoice, + invoiceFromHash, + getFeeEstimation, + payInvoiceV2, + sendToAddressV2, + estimateFeeV2, + createLnurlPay + }, + }) +} diff --git a/src/services/ibex/docs/samples/ibex.http b/src/services/ibex/docs/samples/ibex.http index 3411ab7c4..10208351f 100644 --- a/src/services/ibex/docs/samples/ibex.http +++ b/src/services/ibex/docs/samples/ibex.http @@ -86,10 +86,10 @@ Accept: application/json Authorization: {{accessToken}} ### get Invoice requirements (lnurl-pay) -@k1 = 267f9b5dbfa1fd6c73d446ff76dcd537afd86d2b2ac94029be407a154e972f45 +@k1 = 65d31dc0729a26c192db51562f0fdf4d51f9a20e0e541188639e53214081d945 GET {{baseurl}}/lnurl/pay/invoice-requirements?k1={{k1}} HTTP/1.1 Accept: application/json -Authorization: {{accessToken}} +# Authorization: {{accessToken}} ### Create LNURL-pay POST {{baseurl}}/lnurl/pay HTTP/1.1 diff --git a/src/services/ledger/index.ts b/src/services/ledger/index.ts index 065e25af2..281e7f061 100644 --- a/src/services/ledger/index.ts +++ b/src/services/ledger/index.ts @@ -304,7 +304,7 @@ export const LedgerService = (): ILedgerService => { } } - const resp = await Ibex.getAccountDetails({ accountId: walletId }) + const resp = await Ibex().getAccountDetails({ accountId: walletId }) if (resp instanceof IbexApiError ) { console.error(`Ibex Call failed with ${resp.code}: ${resp.message}`) if (resp.code === 403) return toSats(0) // this is a hack for requests to Ibex with accountIds it doesn't recognize diff --git a/src/services/mongoose/wallets.ts b/src/services/mongoose/wallets.ts index 86bcc247c..c2dcde767 100644 --- a/src/services/mongoose/wallets.ts +++ b/src/services/mongoose/wallets.ts @@ -39,7 +39,7 @@ export const WalletsRepository = (): IWalletsRepository => { // FLASH FORK: create IBEX account if currency is USD let ibexAccountId: string | undefined if (currency === "USD") { - const resp = await Ibex.createAccount({ + const resp = await Ibex().createAccount({ name: accountId, currencyId: 3, }) @@ -49,7 +49,7 @@ export const WalletsRepository = (): IWalletsRepository => { let lnurlp: string | undefined if (ibexAccountId !== undefined) { - const lnurlResp = await Ibex.createLnurlPay({ accountId: ibexAccountId }) + const lnurlResp = await Ibex().createLnurlPay({ accountId: ibexAccountId }) if (lnurlResp instanceof IbexClientError) baseLogger.error(lnurlResp, `Failed to create lnurl-pay address for ibex account with id ${ibexAccountId}`) else lnurlp = lnurlResp.lnurl }