locking bugs
This commit is contained in:
parent
494277a2d5
commit
102b2f70b8
2 changed files with 25 additions and 4 deletions
|
|
@ -15,6 +15,15 @@ const start = async () => {
|
|||
const nostrSettings = LoadNosrtSettingsFromEnv()
|
||||
nostrMiddleware(serverMethods, mainHandler, nostrSettings)
|
||||
const Server = NewServer(serverMethods, serverOptions(mainHandler))
|
||||
if (process.argv[2] === 'unlock') {
|
||||
const u = process.argv[3]
|
||||
if (u) {
|
||||
console.log("unlocking user", u)
|
||||
await mainHandler.storage.userStorage.UnlockUser(u)
|
||||
} else {
|
||||
console.log("no user id found to unlock")
|
||||
}
|
||||
}
|
||||
Server.Listen(mainSettings.servicePort)
|
||||
}
|
||||
start()
|
||||
|
|
|
|||
|
|
@ -128,12 +128,18 @@ export default class {
|
|||
|
||||
const routingFeeLimit = this.lnd.GetFeeLimitAmount(payAmount)
|
||||
await this.lockUserWithMinBalance(userId, totalAmountToDecrement + routingFeeLimit)
|
||||
const payment = await this.lnd.PayInvoice(req.invoice, req.amount, routingFeeLimit)
|
||||
let payment
|
||||
try {
|
||||
payment = await this.lnd.PayInvoice(req.invoice, req.amount, routingFeeLimit)
|
||||
await this.storage.userStorage.UnlockUser(userId)
|
||||
} catch (err) {
|
||||
await this.storage.userStorage.UnlockUser(userId)
|
||||
throw err
|
||||
}
|
||||
await this.storage.userStorage.DecrementUserBalance(userId, totalAmountToDecrement + Number(payment.feeSat))
|
||||
if (isAppUserPayment && serviceFee > 0) {
|
||||
await this.storage.userStorage.IncrementUserBalance(linkedApplication.owner.user_id, serviceFee)
|
||||
}
|
||||
await this.storage.userStorage.UnlockUser(userId)
|
||||
await this.storage.paymentStorage.AddUserInvoicePayment(userId, req.invoice, payAmount, Number(payment.feeSat), serviceFee)
|
||||
return {
|
||||
preimage: payment.paymentPreimage,
|
||||
|
|
@ -154,9 +160,15 @@ export default class {
|
|||
}
|
||||
const serviceFee = this.getServiceFee(Types.UserOperationType.OUTGOING_INVOICE, req.amoutSats, false)
|
||||
await this.lockUserWithMinBalance(userId, total + serviceFee)
|
||||
const payment = await this.lnd.PayAddress(req.address, req.amoutSats, satPerVByte)
|
||||
let payment
|
||||
try {
|
||||
payment = await this.lnd.PayAddress(req.address, req.amoutSats, satPerVByte)
|
||||
await this.storage.userStorage.UnlockUser(userId)
|
||||
} catch (err) {
|
||||
await this.storage.userStorage.UnlockUser(userId)
|
||||
throw err
|
||||
}
|
||||
await this.storage.userStorage.DecrementUserBalance(userId, total + serviceFee)
|
||||
await this.storage.userStorage.UnlockUser(userId)
|
||||
await this.storage.paymentStorage.AddUserTransactionPayment(userId, req.address, payment.txid, 0, req.amoutSats, chainFees, serviceFee)
|
||||
return {
|
||||
txId: payment.txid
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue