fix
This commit is contained in:
parent
6c219c6f62
commit
28183ed3ed
4 changed files with 22 additions and 19 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
// @generated by protobuf-ts 2.8.1
|
// @generated by protobuf-ts 2.8.1
|
||||||
// @generated from protobuf file "router.proto" (package "routerrpc", syntax proto3)
|
// @generated from protobuf file "router.proto" (package "routerrpc", syntax proto3)
|
||||||
// tslint:disable
|
// tslint:disable
|
||||||
import { Payment } from "./lightning";
|
import { Payment } from "./lightning.js";
|
||||||
import { ServiceType } from "@protobuf-ts/runtime-rpc";
|
import { ServiceType } from "@protobuf-ts/runtime-rpc";
|
||||||
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
||||||
import type { IBinaryWriter } from "@protobuf-ts/runtime";
|
import type { IBinaryWriter } from "@protobuf-ts/runtime";
|
||||||
|
|
@ -13,13 +13,13 @@ import type { PartialMessage } from "@protobuf-ts/runtime";
|
||||||
import { reflectionMergePartial } from "@protobuf-ts/runtime";
|
import { reflectionMergePartial } from "@protobuf-ts/runtime";
|
||||||
import { MESSAGE_TYPE } from "@protobuf-ts/runtime";
|
import { MESSAGE_TYPE } from "@protobuf-ts/runtime";
|
||||||
import { MessageType } from "@protobuf-ts/runtime";
|
import { MessageType } from "@protobuf-ts/runtime";
|
||||||
import { ChannelPoint } from "./lightning";
|
import { ChannelPoint } from "./lightning.js";
|
||||||
import { HTLCAttempt } from "./lightning";
|
import { HTLCAttempt } from "./lightning.js";
|
||||||
import { Failure_FailureCode } from "./lightning";
|
import { Failure_FailureCode } from "./lightning.js";
|
||||||
import { Failure } from "./lightning";
|
import { Failure } from "./lightning.js";
|
||||||
import { Route } from "./lightning";
|
import { Route } from "./lightning.js";
|
||||||
import { FeatureBit } from "./lightning";
|
import { FeatureBit } from "./lightning.js";
|
||||||
import { RouteHint } from "./lightning";
|
import { RouteHint } from "./lightning.js";
|
||||||
/**
|
/**
|
||||||
* @generated from protobuf message routerrpc.SendPaymentRequest
|
* @generated from protobuf message routerrpc.SendPaymentRequest
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import NewLightningHandler, { LightningHandler, LoadLndSettingsFromEnv } from '.
|
||||||
let lnd: LightningHandler
|
let lnd: LightningHandler
|
||||||
export const ignore = true
|
export const ignore = true
|
||||||
export const setup = async () => {
|
export const setup = async () => {
|
||||||
lnd = NewLightningHandler(LoadLndSettingsFromEnv(true), console.log, console.log)
|
lnd = NewLightningHandler(LoadLndSettingsFromEnv(true), console.log, console.log, console.log)
|
||||||
await lnd.Warmup()
|
await lnd.Warmup()
|
||||||
}
|
}
|
||||||
export const teardown = () => {
|
export const teardown = () => {
|
||||||
|
|
|
||||||
|
|
@ -74,16 +74,17 @@ export default class {
|
||||||
|
|
||||||
NewBlockHandler = async (height: number) => {
|
NewBlockHandler = async (height: number) => {
|
||||||
const confirmed = await this.paymentManager.CheckPendingTransactions(height)
|
const confirmed = await this.paymentManager.CheckPendingTransactions(height)
|
||||||
await Promise.all(confirmed.map(async ({ confs, type, tx: t }) => {
|
await Promise.all(confirmed.map(async c => {
|
||||||
const { serial_id } = t
|
|
||||||
if (type === 'outgoing') {
|
if (c.type === 'outgoing') {
|
||||||
await this.storage.paymentStorage.UpdateUserTransactionPayment(serial_id, { confs })
|
await this.storage.paymentStorage.UpdateUserTransactionPayment(c.tx.serial_id, { confs: c.confs })
|
||||||
} else {
|
} else {
|
||||||
await this.storage.paymentStorage.UpdateAddressReceivingTransaction(serial_id, { confs })
|
const { user_address: userAddress, paid_amount: amount, service_fee: serviceFee, serial_id: serialId } = c.tx
|
||||||
await this.storage.userStorage.IncrementUserBalance(t.user_address.user.user_id, t.paid_amount - t.service_fee)
|
await this.storage.paymentStorage.UpdateAddressReceivingTransaction(serialId, { confs: c.confs })
|
||||||
const operationId = `${Types.UserOperationType.INCOMING_TX}-${t.user_address.serial_id}`
|
await this.storage.userStorage.IncrementUserBalance(userAddress.user.user_id, amount - serviceFee)
|
||||||
const op = { amount: t.paid_amount, paidAtUnix: Date.now() / 1000, inbound: true, type: Types.UserOperationType.INCOMING_TX, identifier: t.user_address.address, operationId, network_fee: 0, service_fee: t.service_fee, confirmed: true }
|
const operationId = `${Types.UserOperationType.INCOMING_TX}-${userAddress.serial_id}`
|
||||||
this.sendOperationToNostr(t.user_address.linkedApplication!, t.user_address.user.user_id, op)
|
const op = { amount, paidAtUnix: Date.now() / 1000, inbound: true, type: Types.UserOperationType.INCOMING_TX, identifier: userAddress.address, operationId, network_fee: 0, service_fee: serviceFee, confirmed: true }
|
||||||
|
this.sendOperationToNostr(userAddress.linkedApplication!, userAddress.user.user_id, op)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ interface UserOperationInfo {
|
||||||
service_fees?: number
|
service_fees?: number
|
||||||
routing_fees?: number
|
routing_fees?: number
|
||||||
chain_fees?: number
|
chain_fees?: number
|
||||||
|
confs?: number
|
||||||
}
|
}
|
||||||
type PendingTx = { type: 'incoming', tx: AddressReceivingTransaction } | { type: 'outgoing', tx: UserTransactionPayment }
|
type PendingTx = { type: 'incoming', tx: AddressReceivingTransaction } | { type: 'outgoing', tx: UserTransactionPayment }
|
||||||
const defaultLnurlPayMetadata = `[["text/plain", "lnurl pay to Lightning.pub"]]`
|
const defaultLnurlPayMetadata = `[["text/plain", "lnurl pay to Lightning.pub"]]`
|
||||||
|
|
@ -416,7 +417,8 @@ export default class {
|
||||||
identifier,
|
identifier,
|
||||||
operationId: `${type}-${o.serial_id}`,
|
operationId: `${type}-${o.serial_id}`,
|
||||||
network_fee: o.chain_fees || o.routing_fees || 0,
|
network_fee: o.chain_fees || o.routing_fees || 0,
|
||||||
service_fee: o.service_fee || o.service_fees || 0
|
service_fee: o.service_fee || o.service_fees || 0,
|
||||||
|
confirmed: typeof o.confs === 'number' ? o.confs > 0 : true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue