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)) {
|
||||
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, {
|
||||
amountSats: sats,
|
||||
memo: defaultLnurlPayMetadata
|
||||
})
|
||||
}, { expiry: defaultInvoiceExpiry, linkedApplication: key.linkedApplication })
|
||||
return {
|
||||
pr: invoice.invoice,
|
||||
routes: []
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { Entity, PrimaryGeneratedColumn, Column, Index, Check, ManyToOne, JoinColumn, CreateDateColumn, UpdateDateColumn } from "typeorm"
|
||||
import { User } from "./User.js"
|
||||
import { Application } from "./Application.js"
|
||||
export type EphemeralKeyType = 'balanceCheck' | 'payInfo' | 'pay' | 'withdraw'
|
||||
@Entity()
|
||||
export class UserEphemeralKey {
|
||||
|
|
@ -11,6 +12,10 @@ export class UserEphemeralKey {
|
|||
@JoinColumn()
|
||||
user: User
|
||||
|
||||
@ManyToOne(type => Application, { eager: true })
|
||||
@JoinColumn()
|
||||
linkedApplication: Application | null
|
||||
|
||||
@Column()
|
||||
@Index({ unique: true })
|
||||
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({
|
||||
user: await this.userStorage.GetUser(userId, entityManager),
|
||||
key: crypto.randomBytes(31).toString('hex'),
|
||||
type: keyType
|
||||
type: keyType,
|
||||
linkedApplication
|
||||
})
|
||||
return entityManager.getRepository(UserEphemeralKey).save(newKey)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue