Merge branch 'master' into debits
This commit is contained in:
commit
45f4f01bce
5 changed files with 32 additions and 24 deletions
1
.github/dependabot.yml
vendored
1
.github/dependabot.yml
vendored
|
|
@ -9,3 +9,4 @@ updates:
|
||||||
directory: "/" # Location of package manifests
|
directory: "/" # Location of package manifests
|
||||||
schedule:
|
schedule:
|
||||||
interval: "weekly"
|
interval: "weekly"
|
||||||
|
branch: "test"
|
||||||
|
|
|
||||||
9
package-lock.json
generated
9
package-lock.json
generated
|
|
@ -53,7 +53,7 @@
|
||||||
"@types/chai": "^4.3.4",
|
"@types/chai": "^4.3.4",
|
||||||
"@types/chai-string": "^1.4.5",
|
"@types/chai-string": "^1.4.5",
|
||||||
"@types/cors": "^2.8.17",
|
"@types/cors": "^2.8.17",
|
||||||
"@types/eccrypto": "^1.1.3",
|
"@types/eccrypto": "^1.1.6",
|
||||||
"@types/jsonwebtoken": "^9.0.6",
|
"@types/jsonwebtoken": "^9.0.6",
|
||||||
"@types/lodash": "^4.14.182",
|
"@types/lodash": "^4.14.182",
|
||||||
"@types/node": "^16.11.10",
|
"@types/node": "^16.11.10",
|
||||||
|
|
@ -598,10 +598,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/eccrypto": {
|
"node_modules/@types/eccrypto": {
|
||||||
"version": "1.1.3",
|
"version": "1.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/@types/eccrypto/-/eccrypto-1.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/eccrypto/-/eccrypto-1.1.6.tgz",
|
||||||
"integrity": "sha512-3O0qER6JMYReqVbcQTGmXeMHdw3O+rVps63tlo5g5zoB3altJS8yzSvboSivwVWeYO9o5jSATu7P0UIqYZPgow==",
|
"integrity": "sha512-rsmcX5LdDZ3xN2W3al6+YR+XNmiQWlXSwVhsU184QOwNQNJ83YpwvAt8a7cT7y3RpVWkKWmXoIFdanI/z38rNQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/expect": "^1.20.4",
|
"@types/expect": "^1.20.4",
|
||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@
|
||||||
"@types/chai": "^4.3.4",
|
"@types/chai": "^4.3.4",
|
||||||
"@types/chai-string": "^1.4.5",
|
"@types/chai-string": "^1.4.5",
|
||||||
"@types/cors": "^2.8.17",
|
"@types/cors": "^2.8.17",
|
||||||
"@types/eccrypto": "^1.1.3",
|
"@types/eccrypto": "^1.1.6",
|
||||||
"@types/jsonwebtoken": "^9.0.6",
|
"@types/jsonwebtoken": "^9.0.6",
|
||||||
"@types/lodash": "^4.14.182",
|
"@types/lodash": "^4.14.182",
|
||||||
"@types/node": "^16.11.10",
|
"@types/node": "^16.11.10",
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import { AddInvoiceReq } from './addInvoiceReq.js';
|
||||||
import { PayInvoiceReq } from './payInvoiceReq.js';
|
import { PayInvoiceReq } from './payInvoiceReq.js';
|
||||||
import { SendCoinsReq } from './sendCoinsReq.js';
|
import { SendCoinsReq } from './sendCoinsReq.js';
|
||||||
import { LndSettings, AddressPaidCb, InvoicePaidCb, NodeInfo, Invoice, DecodedInvoice, PaidInvoice, NewBlockCb, HtlcCb, BalanceInfo } from './settings.js';
|
import { LndSettings, AddressPaidCb, InvoicePaidCb, NodeInfo, Invoice, DecodedInvoice, PaidInvoice, NewBlockCb, HtlcCb, BalanceInfo } from './settings.js';
|
||||||
import { getLogger } from '../helpers/logger.js';
|
import { ERROR, getLogger } from '../helpers/logger.js';
|
||||||
import { HtlcEvent_EventType } from '../../../proto/lnd/router.js';
|
import { HtlcEvent_EventType } from '../../../proto/lnd/router.js';
|
||||||
import { LiquidityProvider, LiquidityRequest } from '../main/liquidityProvider.js';
|
import { LiquidityProvider, LiquidityRequest } from '../main/liquidityProvider.js';
|
||||||
import { Utils } from '../helpers/utilsWrapper.js';
|
import { Utils } from '../helpers/utilsWrapper.js';
|
||||||
|
|
@ -464,6 +464,25 @@ export default class {
|
||||||
return res.response
|
return res.response
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async GetPaymentFromHash(paymentHash: string): Promise<Payment | null> {
|
||||||
|
const abortController = new AbortController()
|
||||||
|
const stream = this.router.trackPaymentV2({
|
||||||
|
paymentHash: Buffer.from(paymentHash, 'hex'),
|
||||||
|
noInflightUpdates: false
|
||||||
|
}, { abort: abortController.signal })
|
||||||
|
return new Promise((res, rej) => {
|
||||||
|
stream.responses.onError(error => {
|
||||||
|
this.log(ERROR, "error with trackPaymentV2", error.message)
|
||||||
|
rej(null)
|
||||||
|
})
|
||||||
|
stream.responses.onMessage(payment => {
|
||||||
|
abortController.abort()
|
||||||
|
res(payment)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
async ListPeers() {
|
async ListPeers() {
|
||||||
const res = await this.lightning.listPeers({ latestError: true }, DeadLineMetadata())
|
const res = await this.lightning.listPeers({ latestError: true }, DeadLineMetadata())
|
||||||
return res.response
|
return res.response
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { MainSettings } from './settings.js'
|
||||||
import { InboundOptionals, defaultInvoiceExpiry } from '../storage/paymentStorage.js'
|
import { InboundOptionals, defaultInvoiceExpiry } from '../storage/paymentStorage.js'
|
||||||
import LND from '../lnd/lnd.js'
|
import LND from '../lnd/lnd.js'
|
||||||
import { Application } from '../storage/entity/Application.js'
|
import { Application } from '../storage/entity/Application.js'
|
||||||
import { getLogger, PubLogger } from '../helpers/logger.js'
|
import { ERROR, getLogger, PubLogger } from '../helpers/logger.js'
|
||||||
import { UserReceivingAddress } from '../storage/entity/UserReceivingAddress.js'
|
import { UserReceivingAddress } from '../storage/entity/UserReceivingAddress.js'
|
||||||
import { AddressPaidCb, InvoicePaidCb, PaidInvoice } from '../lnd/settings.js'
|
import { AddressPaidCb, InvoicePaidCb, PaidInvoice } from '../lnd/settings.js'
|
||||||
import { UserReceivingInvoice, ZapInfo } from '../storage/entity/UserReceivingInvoice.js'
|
import { UserReceivingInvoice, ZapInfo } from '../storage/entity/UserReceivingInvoice.js'
|
||||||
|
|
@ -124,23 +124,10 @@ export default class {
|
||||||
}
|
}
|
||||||
|
|
||||||
checkPendingLndPayment = async (log: PubLogger, p: UserInvoicePayment) => {
|
checkPendingLndPayment = async (log: PubLogger, p: UserInvoicePayment) => {
|
||||||
if (p.paymentIndex === 0 || p.paymentIndex === -1) {
|
const decoded = await this.lnd.DecodeInvoice(p.invoice)
|
||||||
log("found a pending payment with no payment index, skipping", p.serial_id)
|
const payment = await this.lnd.GetPaymentFromHash(decoded.paymentHash)
|
||||||
//const fullAmount = p.paid_amount + p.service_fees + p.routing_fees
|
if (!payment || payment.paymentHash !== decoded.paymentHash) {
|
||||||
//log("found a pending payment with no payment index, refunding", fullAmount, "sats to user", p.user.user_id)
|
log(ERROR, "lnd payment not found for pending payment hash ", decoded.paymentHash)
|
||||||
//await this.storage.txQueue.PushToQueue({
|
|
||||||
// dbTx: true, description: "refund failed pending payment", exec: async tx => {
|
|
||||||
// await this.storage.userStorage.IncrementUserBalance(p.user.user_id, fullAmount, "payment_refund:" + p.invoice, tx)
|
|
||||||
// await this.storage.paymentStorage.UpdateExternalPayment(p.serial_id, 0, 0, false)
|
|
||||||
// }
|
|
||||||
//})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
console.log({ p })
|
|
||||||
const paymentRes = await this.lnd.GetPayment(p.paymentIndex)
|
|
||||||
const payment = paymentRes.payments[0]
|
|
||||||
if (!payment || Number(payment.paymentIndex) !== p.paymentIndex) {
|
|
||||||
log("lnd payment not found for pending payment", p.serial_id, "with index", p.paymentIndex)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue