diff --git a/env.example b/env.example index f4383e14..b238ad6d 100644 --- a/env.example +++ b/env.example @@ -25,6 +25,9 @@ #PORT=1776 #JWT_SECRET= +#Lightning Address Bridge +#BRIDGE_URL=https://shockwallet.app + #LIGHTNING # Maximum amount in network fees passed to LND when it pays an external invoice # BPS are basis points, 100 BPS = 1% diff --git a/proto/autogenerated/client.md b/proto/autogenerated/client.md index 320f86b3..92630611 100644 --- a/proto/autogenerated/client.md +++ b/proto/autogenerated/client.md @@ -1070,6 +1070,7 @@ The nostr server will send back a message response, and inside the body there wi ### UserInfo - __balance__: _number_ + - __bridge_url__: _string_ - __callback_url__: _string_ - __max_withdrawable__: _number_ - __ndebit__: _string_ diff --git a/proto/autogenerated/go/types.go b/proto/autogenerated/go/types.go index b2f9652b..cb884762 100644 --- a/proto/autogenerated/go/types.go +++ b/proto/autogenerated/go/types.go @@ -460,6 +460,7 @@ type UseInviteLinkRequest struct { } type UserInfo struct { Balance int64 `json:"balance"` + Bridge_url string `json:"bridge_url"` Callback_url string `json:"callback_url"` Max_withdrawable int64 `json:"max_withdrawable"` Ndebit string `json:"ndebit"` diff --git a/proto/autogenerated/ts/types.ts b/proto/autogenerated/ts/types.ts index ce4982b5..2a7e2c71 100644 --- a/proto/autogenerated/ts/types.ts +++ b/proto/autogenerated/ts/types.ts @@ -2612,6 +2612,7 @@ export const UseInviteLinkRequestValidate = (o?: UseInviteLinkRequest, opts: Use export type UserInfo = { balance: number + bridge_url: string callback_url: string max_withdrawable: number ndebit: string @@ -2626,6 +2627,7 @@ export const UserInfoOptionalFields: [] = [] export type UserInfoOptions = OptionsBaseMessage & { checkOptionalsAreSet?: [] balance_CustomCheck?: (v: number) => boolean + bridge_url_CustomCheck?: (v: string) => boolean callback_url_CustomCheck?: (v: string) => boolean max_withdrawable_CustomCheck?: (v: number) => boolean ndebit_CustomCheck?: (v: string) => boolean @@ -2643,6 +2645,9 @@ export const UserInfoValidate = (o?: UserInfo, opts: UserInfoOptions = {}, path: if (typeof o.balance !== 'number') return new Error(`${path}.balance: is not a number`) if (opts.balance_CustomCheck && !opts.balance_CustomCheck(o.balance)) return new Error(`${path}.balance: custom check failed`) + if (typeof o.bridge_url !== 'string') return new Error(`${path}.bridge_url: is not a string`) + if (opts.bridge_url_CustomCheck && !opts.bridge_url_CustomCheck(o.bridge_url)) return new Error(`${path}.bridge_url: custom check failed`) + if (typeof o.callback_url !== 'string') return new Error(`${path}.callback_url: is not a string`) if (opts.callback_url_CustomCheck && !opts.callback_url_CustomCheck(o.callback_url)) return new Error(`${path}.callback_url: custom check failed`) diff --git a/proto/service/structs.proto b/proto/service/structs.proto index c4e90041..ae2eca96 100644 --- a/proto/service/structs.proto +++ b/proto/service/structs.proto @@ -362,6 +362,7 @@ message UserInfo{ string noffer = 8; string ndebit = 9; string callback_url = 10; + string bridge_url = 11; } message GetUserOperationsRequest{ int64 latestIncomingInvoice = 1; diff --git a/src/services/main/appUserManager.ts b/src/services/main/appUserManager.ts index d512c621..db2c32f1 100644 --- a/src/services/main/appUserManager.ts +++ b/src/services/main/appUserManager.ts @@ -69,7 +69,8 @@ export default class { service_fee_bps: this.settings.outgoingAppUserInvoiceFeeBps, noffer: nofferEncode({ pubkey: app.nostr_public_key!, offer: appUser.identifier, priceType: OfferPriceType.Spontaneous, relay: nostrSettings.relays[0] }), ndebit: ndebitEncode({ pubkey: app.nostr_public_key!, pointerId: appUser.identifier, relay: nostrSettings.relays[0] }), - callback_url: appUser.callback_url + callback_url: appUser.callback_url, + bridge_url: this.settings.bridgeUrl } } diff --git a/src/services/main/applicationManager.ts b/src/services/main/applicationManager.ts index 558ac00f..a7244b8e 100644 --- a/src/services/main/applicationManager.ts +++ b/src/services/main/applicationManager.ts @@ -164,7 +164,8 @@ export default class { service_fee_bps: this.settings.outgoingAppUserInvoiceFeeBps, noffer: nofferEncode({ pubkey: app.nostr_public_key!, offer: u.identifier, priceType: OfferPriceType.Spontaneous, relay: nostrSettings.relays[0] }), ndebit: ndebitEncode({ pubkey: app.nostr_public_key!, pointerId: u.identifier, relay: nostrSettings.relays[0] }), - callback_url: u.callback_url + callback_url: u.callback_url, + bridge_url: this.settings.bridgeUrl }, max_withdrawable: this.paymentManager.GetMaxPayableInvoice(u.user.balance_sats, true) @@ -208,7 +209,8 @@ export default class { service_fee_bps: this.settings.outgoingAppUserInvoiceFeeBps, noffer: nofferEncode({ pubkey: app.nostr_public_key!, offer: user.identifier, priceType: OfferPriceType.Spontaneous, relay: nostrSettings.relays[0] }), ndebit: ndebitEncode({ pubkey: app.nostr_public_key!, pointerId: user.identifier, relay: nostrSettings.relays[0] }), - callback_url: user.callback_url + callback_url: user.callback_url, + bridge_url: this.settings.bridgeUrl }, } } diff --git a/src/services/main/settings.ts b/src/services/main/settings.ts index 89aeb512..e9d7ef7d 100644 --- a/src/services/main/settings.ts +++ b/src/services/main/settings.ts @@ -33,7 +33,8 @@ export type MainSettings = { wizard: boolean defaultAppName: string pushBackupsToNostr: boolean - lnurlMetaText: string + lnurlMetaText: string, + bridgeUrl: string } export type BitcoinCoreSettings = { @@ -72,7 +73,8 @@ export const LoadMainSettingsFromEnv = (): MainSettings => { wizard: process.env.WIZARD === 'true' || false, defaultAppName: process.env.DEFAULT_APP_NAME || "wallet", pushBackupsToNostr: process.env.PUSH_BACKUPS_TO_NOSTR === 'true' || false, - lnurlMetaText: process.env.LNURL_META_TEXT || "LNURL via Lightning.pub" + lnurlMetaText: process.env.LNURL_META_TEXT || "LNURL via Lightning.pub", + bridgeUrl: process.env.BRIDGE_URL || "https://shockwallet.app" } }