fix app linked to lnurl invoice
This commit is contained in:
parent
80933b1ecf
commit
ad75ba66c2
3 changed files with 12 additions and 3 deletions
|
|
@ -234,10 +234,13 @@ export default class {
|
||||||
if (!Number.isInteger(sats)) {
|
if (!Number.isInteger(sats)) {
|
||||||
throw new Error("millisats amount must be integer sats amount")
|
throw new Error("millisats amount must be integer sats amount")
|
||||||
}
|
}
|
||||||
|
if (!key.linkedApplication) {
|
||||||
|
throw new Error("cannot handle lnurl for non application user")
|
||||||
|
}
|
||||||
const invoice = await this.NewInvoice(key.user.user_id, {
|
const invoice = await this.NewInvoice(key.user.user_id, {
|
||||||
amountSats: sats,
|
amountSats: sats,
|
||||||
memo: defaultLnurlPayMetadata
|
memo: defaultLnurlPayMetadata
|
||||||
})
|
}, { expiry: defaultInvoiceExpiry, linkedApplication: key.linkedApplication })
|
||||||
return {
|
return {
|
||||||
pr: invoice.invoice,
|
pr: invoice.invoice,
|
||||||
routes: []
|
routes: []
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { Entity, PrimaryGeneratedColumn, Column, Index, Check, ManyToOne, JoinColumn, CreateDateColumn, UpdateDateColumn } from "typeorm"
|
import { Entity, PrimaryGeneratedColumn, Column, Index, Check, ManyToOne, JoinColumn, CreateDateColumn, UpdateDateColumn } from "typeorm"
|
||||||
import { User } from "./User.js"
|
import { User } from "./User.js"
|
||||||
|
import { Application } from "./Application.js"
|
||||||
export type EphemeralKeyType = 'balanceCheck' | 'payInfo' | 'pay' | 'withdraw'
|
export type EphemeralKeyType = 'balanceCheck' | 'payInfo' | 'pay' | 'withdraw'
|
||||||
@Entity()
|
@Entity()
|
||||||
export class UserEphemeralKey {
|
export class UserEphemeralKey {
|
||||||
|
|
@ -11,6 +12,10 @@ export class UserEphemeralKey {
|
||||||
@JoinColumn()
|
@JoinColumn()
|
||||||
user: User
|
user: User
|
||||||
|
|
||||||
|
@ManyToOne(type => Application, { eager: true })
|
||||||
|
@JoinColumn()
|
||||||
|
linkedApplication: Application | null
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
@Index({ unique: true })
|
@Index({ unique: true })
|
||||||
key: string
|
key: string
|
||||||
|
|
|
||||||
|
|
@ -163,11 +163,12 @@ export default class {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async AddUserEphemeralKey(userId: string, keyType: EphemeralKeyType, entityManager = this.DB): Promise<UserEphemeralKey> {
|
async AddUserEphemeralKey(userId: string, keyType: EphemeralKeyType, linkedApplication?: Application, entityManager = this.DB): Promise<UserEphemeralKey> {
|
||||||
const newKey = entityManager.getRepository(UserEphemeralKey).create({
|
const newKey = entityManager.getRepository(UserEphemeralKey).create({
|
||||||
user: await this.userStorage.GetUser(userId, entityManager),
|
user: await this.userStorage.GetUser(userId, entityManager),
|
||||||
key: crypto.randomBytes(31).toString('hex'),
|
key: crypto.randomBytes(31).toString('hex'),
|
||||||
type: keyType
|
type: keyType,
|
||||||
|
linkedApplication
|
||||||
})
|
})
|
||||||
return entityManager.getRepository(UserEphemeralKey).save(newKey)
|
return entityManager.getRepository(UserEphemeralKey).save(newKey)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue