commit
42d272c751
4 changed files with 16 additions and 11 deletions
|
|
@ -70,6 +70,7 @@ LSP_MAX_FEE_BPS=100
|
|||
# You also need an SSL reverse proxy from the domain to this local host
|
||||
# Read more at https://docs.shock.network
|
||||
#SERVICE_URL=https://yourdomainhere.xyz
|
||||
#LNURL_META_TEXT=LNURL via Lightning.Pub
|
||||
|
||||
#SUBSCRIPTION_SERVICES
|
||||
# Opt-in to cloud relays for LNURL and Nostr
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ export default class {
|
|||
async GetAppUserLNURLInfo(appId: string, req: Types.GetAppUserLNURLInfoRequest): Promise<Types.LnurlPayInfoResponse> {
|
||||
const app = await this.storage.applicationStorage.GetApplication(appId)
|
||||
const user = await this.storage.applicationStorage.GetApplicationUser(app, req.user_identifier)
|
||||
return this.paymentManager.GetLnurlPayInfoFromUser(user.user.user_id, app, req.base_url_override)
|
||||
return this.paymentManager.GetLnurlPayInfoFromUser(user.user.user_id, app, { baseUrl: req.base_url_override })
|
||||
}
|
||||
async RequestNPubLinkingToken(appId: string, req: Types.RequestNPubLinkingTokenRequest, reset: boolean): Promise<Types.RequestNPubLinkingTokenResponse> {
|
||||
const app = await this.storage.applicationStorage.GetApplication(appId);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ interface UserOperationInfo {
|
|||
internal?: boolean;
|
||||
}
|
||||
export type PendingTx = { type: 'incoming', tx: AddressReceivingTransaction } | { type: 'outgoing', tx: UserTransactionPayment }
|
||||
const defaultLnurlPayMetadata = `[["text/plain", "lnurl pay to Lightning.pub"]]`
|
||||
const defaultLnurlPayMetadata = (text: string) => `[["text/plain", "${text}"]]`
|
||||
const defaultLnAddressMetadata = (text: string, id: string) => `[["text/plain", "${text}"],["text/identifier", "${id}"]]`
|
||||
const confInOne = 1000 * 1000
|
||||
const confInTwo = 100 * 1000 * 1000
|
||||
export default class {
|
||||
|
|
@ -513,10 +514,11 @@ export default class {
|
|||
}
|
||||
}
|
||||
|
||||
async GetLnurlPayInfoFromUser(userId: string, linkedApplication: Application, baseUrl?: string): Promise<Types.LnurlPayInfoResponse> {
|
||||
async GetLnurlPayInfoFromUser(userId: string, linkedApplication: Application, opts: { baseUrl?: string, metadata?: string } = {}): Promise<Types.LnurlPayInfoResponse> {
|
||||
if (this.isDefaultServiceUrl()) {
|
||||
throw new Error("Lnurl not enabled. Make sure to set SERVICE_URL env variable")
|
||||
}
|
||||
const { baseUrl, metadata } = opts
|
||||
const payK1 = await this.storage.paymentStorage.AddUserEphemeralKey(userId, 'pay', linkedApplication)
|
||||
const url = baseUrl ? baseUrl : `${this.settings.serviceUrl}/api/guest/lnurl_pay/handle`
|
||||
const { remote } = await this.lnd.ChannelBalance()
|
||||
|
|
@ -525,7 +527,7 @@ export default class {
|
|||
callback: `${url}?k1=${payK1.key}`,
|
||||
maxSendable: remote * 1000,
|
||||
minSendable: 10000,
|
||||
metadata: defaultLnurlPayMetadata,
|
||||
metadata: metadata ? metadata : defaultLnurlPayMetadata(this.settings.lnurlMetaText),
|
||||
allowsNostr: !!linkedApplication.nostr_public_key,
|
||||
nostrPubkey: linkedApplication.nostr_public_key || ""
|
||||
}
|
||||
|
|
@ -545,7 +547,7 @@ export default class {
|
|||
callback: `${this.settings.serviceUrl}/api/guest/lnurl_pay/handle?k1=${payInfoK1}`,
|
||||
maxSendable: remote * 1000,
|
||||
minSendable: 10000,
|
||||
metadata: defaultLnurlPayMetadata,
|
||||
metadata: defaultLnurlPayMetadata(this.settings.lnurlMetaText),
|
||||
allowsNostr: !!key.linkedApplication.nostr_public_key,
|
||||
nostrPubkey: key.linkedApplication.nostr_public_key || ""
|
||||
}
|
||||
|
|
@ -621,7 +623,7 @@ export default class {
|
|||
}
|
||||
const invoice = await this.NewInvoice(key.user.user_id, {
|
||||
amountSats: sats,
|
||||
memo: zapInfo ? zapInfo.description : defaultLnurlPayMetadata
|
||||
memo: zapInfo ? zapInfo.description : defaultLnurlPayMetadata(this.settings.lnurlMetaText)
|
||||
}, { expiry: defaultInvoiceExpiry, linkedApplication: key.linkedApplication, zapInfo })
|
||||
return {
|
||||
pr: invoice.invoice,
|
||||
|
|
@ -634,7 +636,7 @@ export default class {
|
|||
if (!linkedUser) {
|
||||
throw new Error("this address is not linked to any user")
|
||||
}
|
||||
return this.GetLnurlPayInfoFromUser(linkedUser.user.user_id, linkedUser.application)
|
||||
return this.GetLnurlPayInfoFromUser(linkedUser.user.user_id, linkedUser.application, { metadata: defaultLnAddressMetadata(this.settings.lnurlMetaText, addressName) })
|
||||
}
|
||||
|
||||
async OpenChannel(userId: string, req: Types.OpenChannelRequest): Promise<Types.OpenChannelResponse> { throw new Error("WIP") }
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ export type MainSettings = {
|
|||
wizard: boolean
|
||||
defaultAppName: string
|
||||
pushBackupsToNostr: boolean
|
||||
lnurlMetaText: string
|
||||
}
|
||||
|
||||
export type BitcoinCoreSettings = {
|
||||
|
|
@ -70,7 +71,8 @@ export const LoadMainSettingsFromEnv = (): MainSettings => {
|
|||
disableExternalPayments: process.env.DISABLE_EXTERNAL_PAYMENTS === 'true' || false,
|
||||
wizard: process.env.WIZARD === 'true' || false,
|
||||
defaultAppName: process.env.DEFAULT_APP_NAME || "wallet",
|
||||
pushBackupsToNostr: process.env.PUSH_BACKUPS_TO_NOSTR === 'true' || false
|
||||
pushBackupsToNostr: process.env.PUSH_BACKUPS_TO_NOSTR === 'true' || false,
|
||||
lnurlMetaText: process.env.LNURL_META_TEXT || "LNURL via Lightning.pub"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue