This commit is contained in:
hatim boufnichel 2022-11-21 23:12:38 +01:00
parent 96b619c886
commit 4fd8c0d71d
31 changed files with 2734 additions and 2004 deletions

View file

@ -5,7 +5,7 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": " tsc && node build/src/testRunner.js", "test": " tsc && node build/src/testRunner.js",
"start": "tsc && cd build && node src/index.js", "start": "tsc && node build/src/index.js",
"build_autogenerated": "cd proto && rimraf autogenerated && protoc -I ./service --pub_out=. service/*", "build_autogenerated": "cd proto && rimraf autogenerated && protoc -I ./service --pub_out=. service/*",
"build_lnd_client_1": "cd proto && protoc -I ./others --plugin=.\\node_modules\\.bin\\protoc-gen-ts_proto.cmd --ts_proto_out=./lnd --ts_proto_opt=esModuleInterop=true others/* ", "build_lnd_client_1": "cd proto && protoc -I ./others --plugin=.\\node_modules\\.bin\\protoc-gen-ts_proto.cmd --ts_proto_out=./lnd --ts_proto_opt=esModuleInterop=true others/* ",
"build_lnd_client": "cd proto && rimraf lnd/* && npx protoc --ts_out ./lnd --ts_opt long_type_string --proto_path others others/* ", "build_lnd_client": "cd proto && rimraf lnd/* && npx protoc --ts_out ./lnd --ts_opt long_type_string --proto_path others others/* ",
@ -68,4 +68,4 @@
"ts-node": "10.7.0", "ts-node": "10.7.0",
"typescript": "4.5.2" "typescript": "4.5.2"
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -94,6 +94,31 @@ export default (methods: Types.ServerMethods, opts: ServerOptions) => {
res.json({status: 'OK', ...response}) res.json({status: 'OK', ...response})
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e } } catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
}) })
if (!opts.allowNotImplementedMethods && !methods.GetUserInfo) throw new Error('method: GetUserInfo is not implemented')
app.post('/api/user/info', async (req, res) => {
try {
if (!methods.GetUserInfo) throw new Error('method: GetUserInfo is not implemented')
const authContext = await opts.UserAuthGuard(req.headers['authorization'])
const query = req.query
const params = req.params
const response = await methods.GetUserInfo({ ...authContext, ...query, ...params })
res.json({status: 'OK', ...response})
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
})
if (!opts.allowNotImplementedMethods && !methods.GetUserOperations) throw new Error('method: GetUserOperations is not implemented')
app.post('/api/user/operations', async (req, res) => {
try {
if (!methods.GetUserOperations) throw new Error('method: GetUserOperations is not implemented')
const authContext = await opts.UserAuthGuard(req.headers['authorization'])
const request = req.body
const error = Types.GetUserOperationsRequestValidate(request)
if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger)
const query = req.query
const params = req.params
const response = await methods.GetUserOperations({ ...authContext, ...query, ...params }, request)
res.json({status: 'OK', ...response})
} catch (ex) { const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
})
if (!opts.allowNotImplementedMethods && !methods.NewAddress) throw new Error('method: NewAddress is not implemented') if (!opts.allowNotImplementedMethods && !methods.NewAddress) throw new Error('method: NewAddress is not implemented')
app.post('/api/user/chain/new', async (req, res) => { app.post('/api/user/chain/new', async (req, res) => {
try { try {

View file

@ -78,6 +78,34 @@ export default (params: ClientParams) => ({
} }
return { status: 'ERROR', reason: 'invalid response' } return { status: 'ERROR', reason: 'invalid response' }
}, },
GetUserInfo: async (): Promise<ResultError | ({ status: 'OK' }& Types.UserInfo)> => {
const auth = await params.retrieveUserAuth()
if (auth === null) throw new Error('retrieveUserAuth() returned null')
let finalRoute = '/api/user/info'
const { data } = await axios.post(params.baseUrl + finalRoute, {}, { headers: { 'authorization': auth } })
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
if (data.status === 'OK') {
const result = data
if(!params.checkResult) return { status: 'OK', ...result }
const error = Types.UserInfoValidate(result)
if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message }
}
return { status: 'ERROR', reason: 'invalid response' }
},
GetUserOperations: async (request: Types.GetUserOperationsRequest): Promise<ResultError | ({ status: 'OK' }& Types.GetUserOperationsResponse)> => {
const auth = await params.retrieveUserAuth()
if (auth === null) throw new Error('retrieveUserAuth() returned null')
let finalRoute = '/api/user/operations'
const { data } = await axios.post(params.baseUrl + finalRoute, request, { headers: { 'authorization': auth } })
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
if (data.status === 'OK') {
const result = data
if(!params.checkResult) return { status: 'OK', ...result }
const error = Types.GetUserOperationsResponseValidate(result)
if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message }
}
return { status: 'ERROR', reason: 'invalid response' }
},
NewAddress: async (request: Types.NewAddressRequest): Promise<ResultError | ({ status: 'OK' }& Types.NewAddressResponse)> => { NewAddress: async (request: Types.NewAddressRequest): Promise<ResultError | ({ status: 'OK' }& Types.NewAddressResponse)> => {
const auth = await params.retrieveUserAuth() const auth = await params.retrieveUserAuth()
if (auth === null) throw new Error('retrieveUserAuth() returned null') if (auth === null) throw new Error('retrieveUserAuth() returned null')

View file

@ -9,6 +9,35 @@ export type NostrClientParams = {
checkResult?: true checkResult?: true
} }
export default (params: NostrClientParams, send: (to:string, message: NostrRequest) => Promise<any>) => ({ export default (params: NostrClientParams, send: (to:string, message: NostrRequest) => Promise<any>) => ({
GetUserInfo: async (): Promise<ResultError | ({ status: 'OK' }& Types.UserInfo)> => {
const auth = await params.retrieveNostrUserAuth()
if (auth === null) throw new Error('retrieveNostrUserAuth() returned null')
const nostrRequest: NostrRequest = {}
const data = await send(params.pubDestination, {rpcName:'GetUserInfo',authIdentifier:auth, ...nostrRequest })
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
if (data.status === 'OK') {
const result = data
if(!params.checkResult) return { status: 'OK', ...result }
const error = Types.UserInfoValidate(result)
if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message }
}
return { status: 'ERROR', reason: 'invalid response' }
},
GetUserOperations: async (request: Types.GetUserOperationsRequest): Promise<ResultError | ({ status: 'OK' }& Types.GetUserOperationsResponse)> => {
const auth = await params.retrieveNostrUserAuth()
if (auth === null) throw new Error('retrieveNostrUserAuth() returned null')
const nostrRequest: NostrRequest = {}
nostrRequest.body = request
const data = await send(params.pubDestination, {rpcName:'GetUserOperations',authIdentifier:auth, ...nostrRequest })
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
if (data.status === 'OK') {
const result = data
if(!params.checkResult) return { status: 'OK', ...result }
const error = Types.GetUserOperationsResponseValidate(result)
if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message }
}
return { status: 'ERROR', reason: 'invalid response' }
},
NewAddress: async (request: Types.NewAddressRequest): Promise<ResultError | ({ status: 'OK' }& Types.NewAddressResponse)> => { NewAddress: async (request: Types.NewAddressRequest): Promise<ResultError | ({ status: 'OK' }& Types.NewAddressResponse)> => {
const auth = await params.retrieveNostrUserAuth() const auth = await params.retrieveNostrUserAuth()
if (auth === null) throw new Error('retrieveNostrUserAuth() returned null') if (auth === null) throw new Error('retrieveNostrUserAuth() returned null')

View file

@ -21,6 +21,29 @@ export default (methods: Types.ServerMethods, opts: NostrOptions) => {
const logger = opts.logger || { log: console.log, error: console.error } const logger = opts.logger || { log: console.log, error: console.error }
return async (req: NostrRequest, res: NostrResponse) => { return async (req: NostrRequest, res: NostrResponse) => {
switch (req.rpcName) { switch (req.rpcName) {
case 'GetUserInfo':
try {
if (!methods.GetUserInfo) throw new Error('method: GetUserInfo is not implemented')
const authContext = await opts.NostrUserAuthGuard(req.authIdentifier)
const query = req.query
const params = req.params
const response = await methods.GetUserInfo({ ...authContext, ...query, ...params })
res({status: 'OK', ...response})
}catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
break
case 'GetUserOperations':
try {
if (!methods.GetUserOperations) throw new Error('method: GetUserOperations is not implemented')
const authContext = await opts.NostrUserAuthGuard(req.authIdentifier)
const request = req.body
const error = Types.GetUserOperationsRequestValidate(request)
if (error !== null) return logErrorAndReturnResponse(error, 'invalid request body', res, logger)
const query = req.query
const params = req.params
const response = await methods.GetUserOperations({ ...authContext, ...query, ...params }, request)
res({status: 'OK', ...response})
}catch(ex){ const e = ex as any; logErrorAndReturnResponse(e, e.message || e, res, logger); if (opts.throwErrors) throw e }
break
case 'NewAddress': case 'NewAddress':
try { try {
if (!methods.NewAddress) throw new Error('method: NewAddress is not implemented') if (!methods.NewAddress) throw new Error('method: NewAddress is not implemented')

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.8.1 with parameter long_type_number // @generated by protobuf-ts 2.8.1
// @generated from protobuf file "invoices.proto" (package "invoicesrpc", syntax proto3) // @generated from protobuf file "invoices.proto" (package "invoicesrpc", syntax proto3)
// tslint:disable // tslint:disable
import type { RpcTransport } from "@protobuf-ts/runtime-rpc"; import type { RpcTransport } from "@protobuf-ts/runtime-rpc";

View file

@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.8.1 with parameter long_type_number // @generated by protobuf-ts 2.8.1
// @generated from protobuf file "invoices.proto" (package "invoicesrpc", syntax proto3) // @generated from protobuf file "invoices.proto" (package "invoicesrpc", syntax proto3)
// tslint:disable // tslint:disable
import { Invoice } from "./lightning.js"; import { Invoice } from "./lightning.js";
@ -59,7 +59,7 @@ export interface AddHoldInvoiceRequest {
* *
* @generated from protobuf field: int64 value = 3; * @generated from protobuf field: int64 value = 3;
*/ */
value: number; value: bigint;
/** /**
* *
* The value of this invoice in millisatoshis * The value of this invoice in millisatoshis
@ -68,7 +68,7 @@ export interface AddHoldInvoiceRequest {
* *
* @generated from protobuf field: int64 value_msat = 10; * @generated from protobuf field: int64 value_msat = 10;
*/ */
valueMsat: number; valueMsat: bigint;
/** /**
* *
* Hash (SHA-256) of a description of the payment. Used if the description of * Hash (SHA-256) of a description of the payment. Used if the description of
@ -83,7 +83,7 @@ export interface AddHoldInvoiceRequest {
* *
* @generated from protobuf field: int64 expiry = 5; * @generated from protobuf field: int64 expiry = 5;
*/ */
expiry: number; expiry: bigint;
/** /**
* Fallback on-chain address. * Fallback on-chain address.
* *
@ -95,7 +95,7 @@ export interface AddHoldInvoiceRequest {
* *
* @generated from protobuf field: uint64 cltv_expiry = 7; * @generated from protobuf field: uint64 cltv_expiry = 7;
*/ */
cltvExpiry: number; cltvExpiry: bigint;
/** /**
* *
* Route hints that can each be individually used to assist in reaching the * Route hints that can each be individually used to assist in reaching the
@ -133,7 +133,7 @@ export interface AddHoldInvoiceResp {
* *
* @generated from protobuf field: uint64 add_index = 2; * @generated from protobuf field: uint64 add_index = 2;
*/ */
addIndex: number; addIndex: bigint;
/** /**
* *
* The payment address of the generated invoice. This value should be used * The payment address of the generated invoice. This value should be used
@ -316,18 +316,18 @@ class AddHoldInvoiceRequest$Type extends MessageType<AddHoldInvoiceRequest> {
super("invoicesrpc.AddHoldInvoiceRequest", [ super("invoicesrpc.AddHoldInvoiceRequest", [
{ no: 1, name: "memo", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 1, name: "memo", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 2, name: "hash", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 2, name: "hash", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
{ no: 3, name: "value", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 3, name: "value", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 10, name: "value_msat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 10, name: "value_msat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 4, name: "description_hash", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 4, name: "description_hash", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
{ no: 5, name: "expiry", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 5, name: "expiry", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 6, name: "fallback_addr", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 6, name: "fallback_addr", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 7, name: "cltv_expiry", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 7, name: "cltv_expiry", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 8, name: "route_hints", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => RouteHint }, { no: 8, name: "route_hints", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => RouteHint },
{ no: 9, name: "private", kind: "scalar", T: 8 /*ScalarType.BOOL*/ } { no: 9, name: "private", kind: "scalar", T: 8 /*ScalarType.BOOL*/ }
]); ]);
} }
create(value?: PartialMessage<AddHoldInvoiceRequest>): AddHoldInvoiceRequest { create(value?: PartialMessage<AddHoldInvoiceRequest>): AddHoldInvoiceRequest {
const message = { memo: "", hash: new Uint8Array(0), value: 0, valueMsat: 0, descriptionHash: new Uint8Array(0), expiry: 0, fallbackAddr: "", cltvExpiry: 0, routeHints: [], private: false }; const message = { memo: "", hash: new Uint8Array(0), value: 0n, valueMsat: 0n, descriptionHash: new Uint8Array(0), expiry: 0n, fallbackAddr: "", cltvExpiry: 0n, routeHints: [], private: false };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined) if (value !== undefined)
reflectionMergePartial<AddHoldInvoiceRequest>(this, message, value); reflectionMergePartial<AddHoldInvoiceRequest>(this, message, value);
@ -345,22 +345,22 @@ class AddHoldInvoiceRequest$Type extends MessageType<AddHoldInvoiceRequest> {
message.hash = reader.bytes(); message.hash = reader.bytes();
break; break;
case /* int64 value */ 3: case /* int64 value */ 3:
message.value = reader.int64().toNumber(); message.value = reader.int64().toBigInt();
break; break;
case /* int64 value_msat */ 10: case /* int64 value_msat */ 10:
message.valueMsat = reader.int64().toNumber(); message.valueMsat = reader.int64().toBigInt();
break; break;
case /* bytes description_hash */ 4: case /* bytes description_hash */ 4:
message.descriptionHash = reader.bytes(); message.descriptionHash = reader.bytes();
break; break;
case /* int64 expiry */ 5: case /* int64 expiry */ 5:
message.expiry = reader.int64().toNumber(); message.expiry = reader.int64().toBigInt();
break; break;
case /* string fallback_addr */ 6: case /* string fallback_addr */ 6:
message.fallbackAddr = reader.string(); message.fallbackAddr = reader.string();
break; break;
case /* uint64 cltv_expiry */ 7: case /* uint64 cltv_expiry */ 7:
message.cltvExpiry = reader.uint64().toNumber(); message.cltvExpiry = reader.uint64().toBigInt();
break; break;
case /* repeated lnrpc.RouteHint route_hints */ 8: case /* repeated lnrpc.RouteHint route_hints */ 8:
message.routeHints.push(RouteHint.internalBinaryRead(reader, reader.uint32(), options)); message.routeHints.push(RouteHint.internalBinaryRead(reader, reader.uint32(), options));
@ -387,22 +387,22 @@ class AddHoldInvoiceRequest$Type extends MessageType<AddHoldInvoiceRequest> {
if (message.hash.length) if (message.hash.length)
writer.tag(2, WireType.LengthDelimited).bytes(message.hash); writer.tag(2, WireType.LengthDelimited).bytes(message.hash);
/* int64 value = 3; */ /* int64 value = 3; */
if (message.value !== 0) if (message.value !== 0n)
writer.tag(3, WireType.Varint).int64(message.value); writer.tag(3, WireType.Varint).int64(message.value);
/* int64 value_msat = 10; */ /* int64 value_msat = 10; */
if (message.valueMsat !== 0) if (message.valueMsat !== 0n)
writer.tag(10, WireType.Varint).int64(message.valueMsat); writer.tag(10, WireType.Varint).int64(message.valueMsat);
/* bytes description_hash = 4; */ /* bytes description_hash = 4; */
if (message.descriptionHash.length) if (message.descriptionHash.length)
writer.tag(4, WireType.LengthDelimited).bytes(message.descriptionHash); writer.tag(4, WireType.LengthDelimited).bytes(message.descriptionHash);
/* int64 expiry = 5; */ /* int64 expiry = 5; */
if (message.expiry !== 0) if (message.expiry !== 0n)
writer.tag(5, WireType.Varint).int64(message.expiry); writer.tag(5, WireType.Varint).int64(message.expiry);
/* string fallback_addr = 6; */ /* string fallback_addr = 6; */
if (message.fallbackAddr !== "") if (message.fallbackAddr !== "")
writer.tag(6, WireType.LengthDelimited).string(message.fallbackAddr); writer.tag(6, WireType.LengthDelimited).string(message.fallbackAddr);
/* uint64 cltv_expiry = 7; */ /* uint64 cltv_expiry = 7; */
if (message.cltvExpiry !== 0) if (message.cltvExpiry !== 0n)
writer.tag(7, WireType.Varint).uint64(message.cltvExpiry); writer.tag(7, WireType.Varint).uint64(message.cltvExpiry);
/* repeated lnrpc.RouteHint route_hints = 8; */ /* repeated lnrpc.RouteHint route_hints = 8; */
for (let i = 0; i < message.routeHints.length; i++) for (let i = 0; i < message.routeHints.length; i++)
@ -425,12 +425,12 @@ class AddHoldInvoiceResp$Type extends MessageType<AddHoldInvoiceResp> {
constructor() { constructor() {
super("invoicesrpc.AddHoldInvoiceResp", [ super("invoicesrpc.AddHoldInvoiceResp", [
{ no: 1, name: "payment_request", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 1, name: "payment_request", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 2, name: "add_index", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 2, name: "add_index", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 3, name: "payment_addr", kind: "scalar", T: 12 /*ScalarType.BYTES*/ } { no: 3, name: "payment_addr", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }
]); ]);
} }
create(value?: PartialMessage<AddHoldInvoiceResp>): AddHoldInvoiceResp { create(value?: PartialMessage<AddHoldInvoiceResp>): AddHoldInvoiceResp {
const message = { paymentRequest: "", addIndex: 0, paymentAddr: new Uint8Array(0) }; const message = { paymentRequest: "", addIndex: 0n, paymentAddr: new Uint8Array(0) };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined) if (value !== undefined)
reflectionMergePartial<AddHoldInvoiceResp>(this, message, value); reflectionMergePartial<AddHoldInvoiceResp>(this, message, value);
@ -445,7 +445,7 @@ class AddHoldInvoiceResp$Type extends MessageType<AddHoldInvoiceResp> {
message.paymentRequest = reader.string(); message.paymentRequest = reader.string();
break; break;
case /* uint64 add_index */ 2: case /* uint64 add_index */ 2:
message.addIndex = reader.uint64().toNumber(); message.addIndex = reader.uint64().toBigInt();
break; break;
case /* bytes payment_addr */ 3: case /* bytes payment_addr */ 3:
message.paymentAddr = reader.bytes(); message.paymentAddr = reader.bytes();
@ -466,7 +466,7 @@ class AddHoldInvoiceResp$Type extends MessageType<AddHoldInvoiceResp> {
if (message.paymentRequest !== "") if (message.paymentRequest !== "")
writer.tag(1, WireType.LengthDelimited).string(message.paymentRequest); writer.tag(1, WireType.LengthDelimited).string(message.paymentRequest);
/* uint64 add_index = 2; */ /* uint64 add_index = 2; */
if (message.addIndex !== 0) if (message.addIndex !== 0n)
writer.tag(2, WireType.Varint).uint64(message.addIndex); writer.tag(2, WireType.Varint).uint64(message.addIndex);
/* bytes payment_addr = 3; */ /* bytes payment_addr = 3; */
if (message.paymentAddr.length) if (message.paymentAddr.length)

View file

@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.8.1 with parameter long_type_number // @generated by protobuf-ts 2.8.1
// @generated from protobuf file "lightning.proto" (package "lnrpc", syntax proto3) // @generated from protobuf file "lightning.proto" (package "lnrpc", syntax proto3)
// tslint:disable // tslint:disable
import type { RpcTransport } from "@protobuf-ts/runtime-rpc"; import type { RpcTransport } from "@protobuf-ts/runtime-rpc";

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.8.1 with parameter long_type_number // @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 type { RpcTransport } from "@protobuf-ts/runtime-rpc"; import type { RpcTransport } from "@protobuf-ts/runtime-rpc";

View file

@ -1,4 +1,4 @@
// @generated by protobuf-ts 2.8.1 with parameter long_type_number // @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.js"; import { Payment } from "./lightning.js";
@ -38,7 +38,7 @@ export interface SendPaymentRequest {
* *
* @generated from protobuf field: int64 amt = 2; * @generated from protobuf field: int64 amt = 2;
*/ */
amt: number; amt: bigint;
/** /**
* *
* Number of millisatoshis to send. * Number of millisatoshis to send.
@ -47,7 +47,7 @@ export interface SendPaymentRequest {
* *
* @generated from protobuf field: int64 amt_msat = 12; * @generated from protobuf field: int64 amt_msat = 12;
*/ */
amtMsat: number; amtMsat: bigint;
/** /**
* The hash to use within the payment's HTLC * The hash to use within the payment's HTLC
* *
@ -100,7 +100,7 @@ export interface SendPaymentRequest {
* *
* @generated from protobuf field: int64 fee_limit_sat = 7; * @generated from protobuf field: int64 fee_limit_sat = 7;
*/ */
feeLimitSat: number; feeLimitSat: bigint;
/** /**
* *
* The maximum number of millisatoshis that will be paid as a fee of the * The maximum number of millisatoshis that will be paid as a fee of the
@ -113,7 +113,7 @@ export interface SendPaymentRequest {
* *
* @generated from protobuf field: int64 fee_limit_msat = 13; * @generated from protobuf field: int64 fee_limit_msat = 13;
*/ */
feeLimitMsat: number; feeLimitMsat: bigint;
/** /**
* *
* Deprecated, use outgoing_chan_ids. The channel id of the channel that must * Deprecated, use outgoing_chan_ids. The channel id of the channel that must
@ -131,7 +131,7 @@ export interface SendPaymentRequest {
* *
* @generated from protobuf field: repeated uint64 outgoing_chan_ids = 19; * @generated from protobuf field: repeated uint64 outgoing_chan_ids = 19;
*/ */
outgoingChanIds: number[]; outgoingChanIds: bigint[];
/** /**
* *
* The pubkey of the last hop of the route. If empty, any hop may be used. * The pubkey of the last hop of the route. If empty, any hop may be used.
@ -210,7 +210,7 @@ export interface SendPaymentRequest {
* *
* @generated from protobuf field: uint64 max_shard_size_msat = 21; * @generated from protobuf field: uint64 max_shard_size_msat = 21;
*/ */
maxShardSizeMsat: number; maxShardSizeMsat: bigint;
/** /**
* *
* If set, an AMP-payment will be attempted. * If set, an AMP-payment will be attempted.
@ -276,7 +276,7 @@ export interface RouteFeeRequest {
* *
* @generated from protobuf field: int64 amt_sat = 2; * @generated from protobuf field: int64 amt_sat = 2;
*/ */
amtSat: number; amtSat: bigint;
} }
/** /**
* @generated from protobuf message routerrpc.RouteFeeResponse * @generated from protobuf message routerrpc.RouteFeeResponse
@ -289,7 +289,7 @@ export interface RouteFeeResponse {
* *
* @generated from protobuf field: int64 routing_fee_msat = 1; * @generated from protobuf field: int64 routing_fee_msat = 1;
*/ */
routingFeeMsat: number; routingFeeMsat: bigint;
/** /**
* *
* An estimate of the worst case time delay that can occur. Note that callers * An estimate of the worst case time delay that can occur. Note that callers
@ -298,7 +298,7 @@ export interface RouteFeeResponse {
* *
* @generated from protobuf field: int64 time_lock_delay = 2; * @generated from protobuf field: int64 time_lock_delay = 2;
*/ */
timeLockDelay: number; timeLockDelay: bigint;
} }
/** /**
* @generated from protobuf message routerrpc.SendToRouteRequest * @generated from protobuf message routerrpc.SendToRouteRequest
@ -428,7 +428,7 @@ export interface PairData {
* *
* @generated from protobuf field: int64 fail_time = 1; * @generated from protobuf field: int64 fail_time = 1;
*/ */
failTime: number; failTime: bigint;
/** /**
* *
* Lowest amount that failed to forward rounded to whole sats. This may be * Lowest amount that failed to forward rounded to whole sats. This may be
@ -436,7 +436,7 @@ export interface PairData {
* *
* @generated from protobuf field: int64 fail_amt_sat = 2; * @generated from protobuf field: int64 fail_amt_sat = 2;
*/ */
failAmtSat: number; failAmtSat: bigint;
/** /**
* *
* Lowest amount that failed to forward in millisats. This may be * Lowest amount that failed to forward in millisats. This may be
@ -444,25 +444,25 @@ export interface PairData {
* *
* @generated from protobuf field: int64 fail_amt_msat = 4; * @generated from protobuf field: int64 fail_amt_msat = 4;
*/ */
failAmtMsat: number; failAmtMsat: bigint;
/** /**
* Time of last success. * Time of last success.
* *
* @generated from protobuf field: int64 success_time = 5; * @generated from protobuf field: int64 success_time = 5;
*/ */
successTime: number; successTime: bigint;
/** /**
* Highest amount that we could successfully forward rounded to whole sats. * Highest amount that we could successfully forward rounded to whole sats.
* *
* @generated from protobuf field: int64 success_amt_sat = 6; * @generated from protobuf field: int64 success_amt_sat = 6;
*/ */
successAmtSat: number; successAmtSat: bigint;
/** /**
* Highest amount that we could successfully forward in millisats. * Highest amount that we could successfully forward in millisats.
* *
* @generated from protobuf field: int64 success_amt_msat = 7; * @generated from protobuf field: int64 success_amt_msat = 7;
*/ */
successAmtMsat: number; successAmtMsat: bigint;
} }
/** /**
* @generated from protobuf message routerrpc.GetMissionControlConfigRequest * @generated from protobuf message routerrpc.GetMissionControlConfigRequest
@ -513,7 +513,7 @@ export interface MissionControlConfig {
* *
* @generated from protobuf field: uint64 half_life_seconds = 1; * @generated from protobuf field: uint64 half_life_seconds = 1;
*/ */
halfLifeSeconds: number; halfLifeSeconds: bigint;
/** /**
* *
* The probability of success mission control should assign to hop in a route * The probability of success mission control should assign to hop in a route
@ -550,7 +550,7 @@ export interface MissionControlConfig {
* *
* @generated from protobuf field: uint64 minimum_failure_relax_interval = 5; * @generated from protobuf field: uint64 minimum_failure_relax_interval = 5;
*/ */
minimumFailureRelaxInterval: number; minimumFailureRelaxInterval: bigint;
} }
/** /**
* @generated from protobuf message routerrpc.QueryProbabilityRequest * @generated from protobuf message routerrpc.QueryProbabilityRequest
@ -573,7 +573,7 @@ export interface QueryProbabilityRequest {
* *
* @generated from protobuf field: int64 amt_msat = 3; * @generated from protobuf field: int64 amt_msat = 3;
*/ */
amtMsat: number; amtMsat: bigint;
} }
/** /**
* @generated from protobuf message routerrpc.QueryProbabilityResponse * @generated from protobuf message routerrpc.QueryProbabilityResponse
@ -603,7 +603,7 @@ export interface BuildRouteRequest {
* *
* @generated from protobuf field: int64 amt_msat = 1; * @generated from protobuf field: int64 amt_msat = 1;
*/ */
amtMsat: number; amtMsat: bigint;
/** /**
* *
* CLTV delta from the current height that should be used for the timelock * CLTV delta from the current height that should be used for the timelock
@ -671,7 +671,7 @@ export interface HtlcEvent {
* *
* @generated from protobuf field: uint64 incoming_channel_id = 1; * @generated from protobuf field: uint64 incoming_channel_id = 1;
*/ */
incomingChannelId: number; incomingChannelId: bigint;
/** /**
* *
* The short channel id that the outgoing htlc left our node on. This value * The short channel id that the outgoing htlc left our node on. This value
@ -679,7 +679,7 @@ export interface HtlcEvent {
* *
* @generated from protobuf field: uint64 outgoing_channel_id = 2; * @generated from protobuf field: uint64 outgoing_channel_id = 2;
*/ */
outgoingChannelId: number; outgoingChannelId: bigint;
/** /**
* *
* Incoming id is the index of the incoming htlc in the incoming channel. * Incoming id is the index of the incoming htlc in the incoming channel.
@ -687,7 +687,7 @@ export interface HtlcEvent {
* *
* @generated from protobuf field: uint64 incoming_htlc_id = 3; * @generated from protobuf field: uint64 incoming_htlc_id = 3;
*/ */
incomingHtlcId: number; incomingHtlcId: bigint;
/** /**
* *
* Outgoing id is the index of the outgoing htlc in the outgoing channel. * Outgoing id is the index of the outgoing htlc in the outgoing channel.
@ -695,14 +695,14 @@ export interface HtlcEvent {
* *
* @generated from protobuf field: uint64 outgoing_htlc_id = 4; * @generated from protobuf field: uint64 outgoing_htlc_id = 4;
*/ */
outgoingHtlcId: number; outgoingHtlcId: bigint;
/** /**
* *
* The time in unix nanoseconds that the event occurred. * The time in unix nanoseconds that the event occurred.
* *
* @generated from protobuf field: uint64 timestamp_ns = 5; * @generated from protobuf field: uint64 timestamp_ns = 5;
*/ */
timestampNs: number; timestampNs: bigint;
/** /**
* *
* The event type indicates whether the htlc was part of a send, receive or * The event type indicates whether the htlc was part of a send, receive or
@ -796,13 +796,13 @@ export interface HtlcInfo {
* *
* @generated from protobuf field: uint64 incoming_amt_msat = 3; * @generated from protobuf field: uint64 incoming_amt_msat = 3;
*/ */
incomingAmtMsat: number; incomingAmtMsat: bigint;
/** /**
* The amount of the outgoing htlc. * The amount of the outgoing htlc.
* *
* @generated from protobuf field: uint64 outgoing_amt_msat = 4; * @generated from protobuf field: uint64 outgoing_amt_msat = 4;
*/ */
outgoingAmtMsat: number; outgoingAmtMsat: bigint;
} }
/** /**
* @generated from protobuf message routerrpc.ForwardEvent * @generated from protobuf message routerrpc.ForwardEvent
@ -915,13 +915,13 @@ export interface CircuitKey {
* *
* @generated from protobuf field: uint64 chan_id = 1; * @generated from protobuf field: uint64 chan_id = 1;
*/ */
chanId: number; chanId: bigint;
/** /**
* / The index of the incoming htlc in the incoming channel. * / The index of the incoming htlc in the incoming channel.
* *
* @generated from protobuf field: uint64 htlc_id = 2; * @generated from protobuf field: uint64 htlc_id = 2;
*/ */
htlcId: number; htlcId: bigint;
} }
/** /**
* @generated from protobuf message routerrpc.ForwardHtlcInterceptRequest * @generated from protobuf message routerrpc.ForwardHtlcInterceptRequest
@ -940,7 +940,7 @@ export interface ForwardHtlcInterceptRequest {
* *
* @generated from protobuf field: uint64 incoming_amount_msat = 5; * @generated from protobuf field: uint64 incoming_amount_msat = 5;
*/ */
incomingAmountMsat: number; incomingAmountMsat: bigint;
/** /**
* The incoming htlc expiry. * The incoming htlc expiry.
* *
@ -963,13 +963,13 @@ export interface ForwardHtlcInterceptRequest {
* *
* @generated from protobuf field: uint64 outgoing_requested_chan_id = 7; * @generated from protobuf field: uint64 outgoing_requested_chan_id = 7;
*/ */
outgoingRequestedChanId: number; outgoingRequestedChanId: bigint;
/** /**
* The outgoing htlc amount. * The outgoing htlc amount.
* *
* @generated from protobuf field: uint64 outgoing_amount_msat = 3; * @generated from protobuf field: uint64 outgoing_amount_msat = 3;
*/ */
outgoingAmountMsat: number; outgoingAmountMsat: bigint;
/** /**
* The outgoing htlc expiry. * The outgoing htlc expiry.
* *
@ -1261,17 +1261,17 @@ class SendPaymentRequest$Type extends MessageType<SendPaymentRequest> {
constructor() { constructor() {
super("routerrpc.SendPaymentRequest", [ super("routerrpc.SendPaymentRequest", [
{ no: 1, name: "dest", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 1, name: "dest", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
{ no: 2, name: "amt", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 2, name: "amt", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 12, name: "amt_msat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 12, name: "amt_msat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 3, name: "payment_hash", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 3, name: "payment_hash", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
{ no: 4, name: "final_cltv_delta", kind: "scalar", T: 5 /*ScalarType.INT32*/ }, { no: 4, name: "final_cltv_delta", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
{ no: 20, name: "payment_addr", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 20, name: "payment_addr", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
{ no: 5, name: "payment_request", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 5, name: "payment_request", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 6, name: "timeout_seconds", kind: "scalar", T: 5 /*ScalarType.INT32*/ }, { no: 6, name: "timeout_seconds", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
{ no: 7, name: "fee_limit_sat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 7, name: "fee_limit_sat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 13, name: "fee_limit_msat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 13, name: "fee_limit_msat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 8, name: "outgoing_chan_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/ }, { no: 8, name: "outgoing_chan_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/ },
{ no: 19, name: "outgoing_chan_ids", kind: "scalar", repeat: 1 /*RepeatType.PACKED*/, T: 4 /*ScalarType.UINT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 19, name: "outgoing_chan_ids", kind: "scalar", repeat: 1 /*RepeatType.PACKED*/, T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 14, name: "last_hop_pubkey", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 14, name: "last_hop_pubkey", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
{ no: 9, name: "cltv_limit", kind: "scalar", T: 5 /*ScalarType.INT32*/ }, { no: 9, name: "cltv_limit", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
{ no: 10, name: "route_hints", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => RouteHint }, { no: 10, name: "route_hints", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => RouteHint },
@ -1280,13 +1280,13 @@ class SendPaymentRequest$Type extends MessageType<SendPaymentRequest> {
{ no: 16, name: "dest_features", kind: "enum", repeat: 1 /*RepeatType.PACKED*/, T: () => ["lnrpc.FeatureBit", FeatureBit] }, { no: 16, name: "dest_features", kind: "enum", repeat: 1 /*RepeatType.PACKED*/, T: () => ["lnrpc.FeatureBit", FeatureBit] },
{ no: 17, name: "max_parts", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 17, name: "max_parts", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
{ no: 18, name: "no_inflight_updates", kind: "scalar", T: 8 /*ScalarType.BOOL*/ }, { no: 18, name: "no_inflight_updates", kind: "scalar", T: 8 /*ScalarType.BOOL*/ },
{ no: 21, name: "max_shard_size_msat", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 21, name: "max_shard_size_msat", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 22, name: "amp", kind: "scalar", T: 8 /*ScalarType.BOOL*/ }, { no: 22, name: "amp", kind: "scalar", T: 8 /*ScalarType.BOOL*/ },
{ no: 23, name: "time_pref", kind: "scalar", T: 1 /*ScalarType.DOUBLE*/ } { no: 23, name: "time_pref", kind: "scalar", T: 1 /*ScalarType.DOUBLE*/ }
]); ]);
} }
create(value?: PartialMessage<SendPaymentRequest>): SendPaymentRequest { create(value?: PartialMessage<SendPaymentRequest>): SendPaymentRequest {
const message = { dest: new Uint8Array(0), amt: 0, amtMsat: 0, paymentHash: new Uint8Array(0), finalCltvDelta: 0, paymentAddr: new Uint8Array(0), paymentRequest: "", timeoutSeconds: 0, feeLimitSat: 0, feeLimitMsat: 0, outgoingChanId: "0", outgoingChanIds: [], lastHopPubkey: new Uint8Array(0), cltvLimit: 0, routeHints: [], destCustomRecords: {}, allowSelfPayment: false, destFeatures: [], maxParts: 0, noInflightUpdates: false, maxShardSizeMsat: 0, amp: false, timePref: 0 }; const message = { dest: new Uint8Array(0), amt: 0n, amtMsat: 0n, paymentHash: new Uint8Array(0), finalCltvDelta: 0, paymentAddr: new Uint8Array(0), paymentRequest: "", timeoutSeconds: 0, feeLimitSat: 0n, feeLimitMsat: 0n, outgoingChanId: "0", outgoingChanIds: [], lastHopPubkey: new Uint8Array(0), cltvLimit: 0, routeHints: [], destCustomRecords: {}, allowSelfPayment: false, destFeatures: [], maxParts: 0, noInflightUpdates: false, maxShardSizeMsat: 0n, amp: false, timePref: 0 };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined) if (value !== undefined)
reflectionMergePartial<SendPaymentRequest>(this, message, value); reflectionMergePartial<SendPaymentRequest>(this, message, value);
@ -1301,10 +1301,10 @@ class SendPaymentRequest$Type extends MessageType<SendPaymentRequest> {
message.dest = reader.bytes(); message.dest = reader.bytes();
break; break;
case /* int64 amt */ 2: case /* int64 amt */ 2:
message.amt = reader.int64().toNumber(); message.amt = reader.int64().toBigInt();
break; break;
case /* int64 amt_msat */ 12: case /* int64 amt_msat */ 12:
message.amtMsat = reader.int64().toNumber(); message.amtMsat = reader.int64().toBigInt();
break; break;
case /* bytes payment_hash */ 3: case /* bytes payment_hash */ 3:
message.paymentHash = reader.bytes(); message.paymentHash = reader.bytes();
@ -1322,10 +1322,10 @@ class SendPaymentRequest$Type extends MessageType<SendPaymentRequest> {
message.timeoutSeconds = reader.int32(); message.timeoutSeconds = reader.int32();
break; break;
case /* int64 fee_limit_sat */ 7: case /* int64 fee_limit_sat */ 7:
message.feeLimitSat = reader.int64().toNumber(); message.feeLimitSat = reader.int64().toBigInt();
break; break;
case /* int64 fee_limit_msat */ 13: case /* int64 fee_limit_msat */ 13:
message.feeLimitMsat = reader.int64().toNumber(); message.feeLimitMsat = reader.int64().toBigInt();
break; break;
case /* uint64 outgoing_chan_id = 8 [deprecated = true, jstype = JS_STRING];*/ 8: case /* uint64 outgoing_chan_id = 8 [deprecated = true, jstype = JS_STRING];*/ 8:
message.outgoingChanId = reader.uint64().toString(); message.outgoingChanId = reader.uint64().toString();
@ -1333,9 +1333,9 @@ class SendPaymentRequest$Type extends MessageType<SendPaymentRequest> {
case /* repeated uint64 outgoing_chan_ids */ 19: case /* repeated uint64 outgoing_chan_ids */ 19:
if (wireType === WireType.LengthDelimited) if (wireType === WireType.LengthDelimited)
for (let e = reader.int32() + reader.pos; reader.pos < e;) for (let e = reader.int32() + reader.pos; reader.pos < e;)
message.outgoingChanIds.push(reader.uint64().toNumber()); message.outgoingChanIds.push(reader.uint64().toBigInt());
else else
message.outgoingChanIds.push(reader.uint64().toNumber()); message.outgoingChanIds.push(reader.uint64().toBigInt());
break; break;
case /* bytes last_hop_pubkey */ 14: case /* bytes last_hop_pubkey */ 14:
message.lastHopPubkey = reader.bytes(); message.lastHopPubkey = reader.bytes();
@ -1366,7 +1366,7 @@ class SendPaymentRequest$Type extends MessageType<SendPaymentRequest> {
message.noInflightUpdates = reader.bool(); message.noInflightUpdates = reader.bool();
break; break;
case /* uint64 max_shard_size_msat */ 21: case /* uint64 max_shard_size_msat */ 21:
message.maxShardSizeMsat = reader.uint64().toNumber(); message.maxShardSizeMsat = reader.uint64().toBigInt();
break; break;
case /* bool amp */ 22: case /* bool amp */ 22:
message.amp = reader.bool(); message.amp = reader.bool();
@ -1406,10 +1406,10 @@ class SendPaymentRequest$Type extends MessageType<SendPaymentRequest> {
if (message.dest.length) if (message.dest.length)
writer.tag(1, WireType.LengthDelimited).bytes(message.dest); writer.tag(1, WireType.LengthDelimited).bytes(message.dest);
/* int64 amt = 2; */ /* int64 amt = 2; */
if (message.amt !== 0) if (message.amt !== 0n)
writer.tag(2, WireType.Varint).int64(message.amt); writer.tag(2, WireType.Varint).int64(message.amt);
/* int64 amt_msat = 12; */ /* int64 amt_msat = 12; */
if (message.amtMsat !== 0) if (message.amtMsat !== 0n)
writer.tag(12, WireType.Varint).int64(message.amtMsat); writer.tag(12, WireType.Varint).int64(message.amtMsat);
/* bytes payment_hash = 3; */ /* bytes payment_hash = 3; */
if (message.paymentHash.length) if (message.paymentHash.length)
@ -1427,10 +1427,10 @@ class SendPaymentRequest$Type extends MessageType<SendPaymentRequest> {
if (message.timeoutSeconds !== 0) if (message.timeoutSeconds !== 0)
writer.tag(6, WireType.Varint).int32(message.timeoutSeconds); writer.tag(6, WireType.Varint).int32(message.timeoutSeconds);
/* int64 fee_limit_sat = 7; */ /* int64 fee_limit_sat = 7; */
if (message.feeLimitSat !== 0) if (message.feeLimitSat !== 0n)
writer.tag(7, WireType.Varint).int64(message.feeLimitSat); writer.tag(7, WireType.Varint).int64(message.feeLimitSat);
/* int64 fee_limit_msat = 13; */ /* int64 fee_limit_msat = 13; */
if (message.feeLimitMsat !== 0) if (message.feeLimitMsat !== 0n)
writer.tag(13, WireType.Varint).int64(message.feeLimitMsat); writer.tag(13, WireType.Varint).int64(message.feeLimitMsat);
/* uint64 outgoing_chan_id = 8 [deprecated = true, jstype = JS_STRING]; */ /* uint64 outgoing_chan_id = 8 [deprecated = true, jstype = JS_STRING]; */
if (message.outgoingChanId !== "0") if (message.outgoingChanId !== "0")
@ -1471,7 +1471,7 @@ class SendPaymentRequest$Type extends MessageType<SendPaymentRequest> {
if (message.noInflightUpdates !== false) if (message.noInflightUpdates !== false)
writer.tag(18, WireType.Varint).bool(message.noInflightUpdates); writer.tag(18, WireType.Varint).bool(message.noInflightUpdates);
/* uint64 max_shard_size_msat = 21; */ /* uint64 max_shard_size_msat = 21; */
if (message.maxShardSizeMsat !== 0) if (message.maxShardSizeMsat !== 0n)
writer.tag(21, WireType.Varint).uint64(message.maxShardSizeMsat); writer.tag(21, WireType.Varint).uint64(message.maxShardSizeMsat);
/* bool amp = 22; */ /* bool amp = 22; */
if (message.amp !== false) if (message.amp !== false)
@ -1595,11 +1595,11 @@ class RouteFeeRequest$Type extends MessageType<RouteFeeRequest> {
constructor() { constructor() {
super("routerrpc.RouteFeeRequest", [ super("routerrpc.RouteFeeRequest", [
{ no: 1, name: "dest", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 1, name: "dest", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
{ no: 2, name: "amt_sat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 2 /*LongType.NUMBER*/ } { no: 2, name: "amt_sat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ }
]); ]);
} }
create(value?: PartialMessage<RouteFeeRequest>): RouteFeeRequest { create(value?: PartialMessage<RouteFeeRequest>): RouteFeeRequest {
const message = { dest: new Uint8Array(0), amtSat: 0 }; const message = { dest: new Uint8Array(0), amtSat: 0n };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined) if (value !== undefined)
reflectionMergePartial<RouteFeeRequest>(this, message, value); reflectionMergePartial<RouteFeeRequest>(this, message, value);
@ -1614,7 +1614,7 @@ class RouteFeeRequest$Type extends MessageType<RouteFeeRequest> {
message.dest = reader.bytes(); message.dest = reader.bytes();
break; break;
case /* int64 amt_sat */ 2: case /* int64 amt_sat */ 2:
message.amtSat = reader.int64().toNumber(); message.amtSat = reader.int64().toBigInt();
break; break;
default: default:
let u = options.readUnknownField; let u = options.readUnknownField;
@ -1632,7 +1632,7 @@ class RouteFeeRequest$Type extends MessageType<RouteFeeRequest> {
if (message.dest.length) if (message.dest.length)
writer.tag(1, WireType.LengthDelimited).bytes(message.dest); writer.tag(1, WireType.LengthDelimited).bytes(message.dest);
/* int64 amt_sat = 2; */ /* int64 amt_sat = 2; */
if (message.amtSat !== 0) if (message.amtSat !== 0n)
writer.tag(2, WireType.Varint).int64(message.amtSat); writer.tag(2, WireType.Varint).int64(message.amtSat);
let u = options.writeUnknownFields; let u = options.writeUnknownFields;
if (u !== false) if (u !== false)
@ -1648,12 +1648,12 @@ export const RouteFeeRequest = new RouteFeeRequest$Type();
class RouteFeeResponse$Type extends MessageType<RouteFeeResponse> { class RouteFeeResponse$Type extends MessageType<RouteFeeResponse> {
constructor() { constructor() {
super("routerrpc.RouteFeeResponse", [ super("routerrpc.RouteFeeResponse", [
{ no: 1, name: "routing_fee_msat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 1, name: "routing_fee_msat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 2, name: "time_lock_delay", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 2 /*LongType.NUMBER*/ } { no: 2, name: "time_lock_delay", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ }
]); ]);
} }
create(value?: PartialMessage<RouteFeeResponse>): RouteFeeResponse { create(value?: PartialMessage<RouteFeeResponse>): RouteFeeResponse {
const message = { routingFeeMsat: 0, timeLockDelay: 0 }; const message = { routingFeeMsat: 0n, timeLockDelay: 0n };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined) if (value !== undefined)
reflectionMergePartial<RouteFeeResponse>(this, message, value); reflectionMergePartial<RouteFeeResponse>(this, message, value);
@ -1665,10 +1665,10 @@ class RouteFeeResponse$Type extends MessageType<RouteFeeResponse> {
let [fieldNo, wireType] = reader.tag(); let [fieldNo, wireType] = reader.tag();
switch (fieldNo) { switch (fieldNo) {
case /* int64 routing_fee_msat */ 1: case /* int64 routing_fee_msat */ 1:
message.routingFeeMsat = reader.int64().toNumber(); message.routingFeeMsat = reader.int64().toBigInt();
break; break;
case /* int64 time_lock_delay */ 2: case /* int64 time_lock_delay */ 2:
message.timeLockDelay = reader.int64().toNumber(); message.timeLockDelay = reader.int64().toBigInt();
break; break;
default: default:
let u = options.readUnknownField; let u = options.readUnknownField;
@ -1683,10 +1683,10 @@ class RouteFeeResponse$Type extends MessageType<RouteFeeResponse> {
} }
internalBinaryWrite(message: RouteFeeResponse, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { internalBinaryWrite(message: RouteFeeResponse, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* int64 routing_fee_msat = 1; */ /* int64 routing_fee_msat = 1; */
if (message.routingFeeMsat !== 0) if (message.routingFeeMsat !== 0n)
writer.tag(1, WireType.Varint).int64(message.routingFeeMsat); writer.tag(1, WireType.Varint).int64(message.routingFeeMsat);
/* int64 time_lock_delay = 2; */ /* int64 time_lock_delay = 2; */
if (message.timeLockDelay !== 0) if (message.timeLockDelay !== 0n)
writer.tag(2, WireType.Varint).int64(message.timeLockDelay); writer.tag(2, WireType.Varint).int64(message.timeLockDelay);
let u = options.writeUnknownFields; let u = options.writeUnknownFields;
if (u !== false) if (u !== false)
@ -2083,16 +2083,16 @@ export const PairHistory = new PairHistory$Type();
class PairData$Type extends MessageType<PairData> { class PairData$Type extends MessageType<PairData> {
constructor() { constructor() {
super("routerrpc.PairData", [ super("routerrpc.PairData", [
{ no: 1, name: "fail_time", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 1, name: "fail_time", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 2, name: "fail_amt_sat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 2, name: "fail_amt_sat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 4, name: "fail_amt_msat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 4, name: "fail_amt_msat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 5, name: "success_time", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 5, name: "success_time", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 6, name: "success_amt_sat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 6, name: "success_amt_sat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 7, name: "success_amt_msat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 2 /*LongType.NUMBER*/ } { no: 7, name: "success_amt_msat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ }
]); ]);
} }
create(value?: PartialMessage<PairData>): PairData { create(value?: PartialMessage<PairData>): PairData {
const message = { failTime: 0, failAmtSat: 0, failAmtMsat: 0, successTime: 0, successAmtSat: 0, successAmtMsat: 0 }; const message = { failTime: 0n, failAmtSat: 0n, failAmtMsat: 0n, successTime: 0n, successAmtSat: 0n, successAmtMsat: 0n };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined) if (value !== undefined)
reflectionMergePartial<PairData>(this, message, value); reflectionMergePartial<PairData>(this, message, value);
@ -2104,22 +2104,22 @@ class PairData$Type extends MessageType<PairData> {
let [fieldNo, wireType] = reader.tag(); let [fieldNo, wireType] = reader.tag();
switch (fieldNo) { switch (fieldNo) {
case /* int64 fail_time */ 1: case /* int64 fail_time */ 1:
message.failTime = reader.int64().toNumber(); message.failTime = reader.int64().toBigInt();
break; break;
case /* int64 fail_amt_sat */ 2: case /* int64 fail_amt_sat */ 2:
message.failAmtSat = reader.int64().toNumber(); message.failAmtSat = reader.int64().toBigInt();
break; break;
case /* int64 fail_amt_msat */ 4: case /* int64 fail_amt_msat */ 4:
message.failAmtMsat = reader.int64().toNumber(); message.failAmtMsat = reader.int64().toBigInt();
break; break;
case /* int64 success_time */ 5: case /* int64 success_time */ 5:
message.successTime = reader.int64().toNumber(); message.successTime = reader.int64().toBigInt();
break; break;
case /* int64 success_amt_sat */ 6: case /* int64 success_amt_sat */ 6:
message.successAmtSat = reader.int64().toNumber(); message.successAmtSat = reader.int64().toBigInt();
break; break;
case /* int64 success_amt_msat */ 7: case /* int64 success_amt_msat */ 7:
message.successAmtMsat = reader.int64().toNumber(); message.successAmtMsat = reader.int64().toBigInt();
break; break;
default: default:
let u = options.readUnknownField; let u = options.readUnknownField;
@ -2134,22 +2134,22 @@ class PairData$Type extends MessageType<PairData> {
} }
internalBinaryWrite(message: PairData, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { internalBinaryWrite(message: PairData, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* int64 fail_time = 1; */ /* int64 fail_time = 1; */
if (message.failTime !== 0) if (message.failTime !== 0n)
writer.tag(1, WireType.Varint).int64(message.failTime); writer.tag(1, WireType.Varint).int64(message.failTime);
/* int64 fail_amt_sat = 2; */ /* int64 fail_amt_sat = 2; */
if (message.failAmtSat !== 0) if (message.failAmtSat !== 0n)
writer.tag(2, WireType.Varint).int64(message.failAmtSat); writer.tag(2, WireType.Varint).int64(message.failAmtSat);
/* int64 fail_amt_msat = 4; */ /* int64 fail_amt_msat = 4; */
if (message.failAmtMsat !== 0) if (message.failAmtMsat !== 0n)
writer.tag(4, WireType.Varint).int64(message.failAmtMsat); writer.tag(4, WireType.Varint).int64(message.failAmtMsat);
/* int64 success_time = 5; */ /* int64 success_time = 5; */
if (message.successTime !== 0) if (message.successTime !== 0n)
writer.tag(5, WireType.Varint).int64(message.successTime); writer.tag(5, WireType.Varint).int64(message.successTime);
/* int64 success_amt_sat = 6; */ /* int64 success_amt_sat = 6; */
if (message.successAmtSat !== 0) if (message.successAmtSat !== 0n)
writer.tag(6, WireType.Varint).int64(message.successAmtSat); writer.tag(6, WireType.Varint).int64(message.successAmtSat);
/* int64 success_amt_msat = 7; */ /* int64 success_amt_msat = 7; */
if (message.successAmtMsat !== 0) if (message.successAmtMsat !== 0n)
writer.tag(7, WireType.Varint).int64(message.successAmtMsat); writer.tag(7, WireType.Varint).int64(message.successAmtMsat);
let u = options.writeUnknownFields; let u = options.writeUnknownFields;
if (u !== false) if (u !== false)
@ -2311,15 +2311,15 @@ export const SetMissionControlConfigResponse = new SetMissionControlConfigRespon
class MissionControlConfig$Type extends MessageType<MissionControlConfig> { class MissionControlConfig$Type extends MessageType<MissionControlConfig> {
constructor() { constructor() {
super("routerrpc.MissionControlConfig", [ super("routerrpc.MissionControlConfig", [
{ no: 1, name: "half_life_seconds", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 1, name: "half_life_seconds", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 2, name: "hop_probability", kind: "scalar", T: 2 /*ScalarType.FLOAT*/ }, { no: 2, name: "hop_probability", kind: "scalar", T: 2 /*ScalarType.FLOAT*/ },
{ no: 3, name: "weight", kind: "scalar", T: 2 /*ScalarType.FLOAT*/ }, { no: 3, name: "weight", kind: "scalar", T: 2 /*ScalarType.FLOAT*/ },
{ no: 4, name: "maximum_payment_results", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 4, name: "maximum_payment_results", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
{ no: 5, name: "minimum_failure_relax_interval", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 2 /*LongType.NUMBER*/ } { no: 5, name: "minimum_failure_relax_interval", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }
]); ]);
} }
create(value?: PartialMessage<MissionControlConfig>): MissionControlConfig { create(value?: PartialMessage<MissionControlConfig>): MissionControlConfig {
const message = { halfLifeSeconds: 0, hopProbability: 0, weight: 0, maximumPaymentResults: 0, minimumFailureRelaxInterval: 0 }; const message = { halfLifeSeconds: 0n, hopProbability: 0, weight: 0, maximumPaymentResults: 0, minimumFailureRelaxInterval: 0n };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined) if (value !== undefined)
reflectionMergePartial<MissionControlConfig>(this, message, value); reflectionMergePartial<MissionControlConfig>(this, message, value);
@ -2331,7 +2331,7 @@ class MissionControlConfig$Type extends MessageType<MissionControlConfig> {
let [fieldNo, wireType] = reader.tag(); let [fieldNo, wireType] = reader.tag();
switch (fieldNo) { switch (fieldNo) {
case /* uint64 half_life_seconds */ 1: case /* uint64 half_life_seconds */ 1:
message.halfLifeSeconds = reader.uint64().toNumber(); message.halfLifeSeconds = reader.uint64().toBigInt();
break; break;
case /* float hop_probability */ 2: case /* float hop_probability */ 2:
message.hopProbability = reader.float(); message.hopProbability = reader.float();
@ -2343,7 +2343,7 @@ class MissionControlConfig$Type extends MessageType<MissionControlConfig> {
message.maximumPaymentResults = reader.uint32(); message.maximumPaymentResults = reader.uint32();
break; break;
case /* uint64 minimum_failure_relax_interval */ 5: case /* uint64 minimum_failure_relax_interval */ 5:
message.minimumFailureRelaxInterval = reader.uint64().toNumber(); message.minimumFailureRelaxInterval = reader.uint64().toBigInt();
break; break;
default: default:
let u = options.readUnknownField; let u = options.readUnknownField;
@ -2358,7 +2358,7 @@ class MissionControlConfig$Type extends MessageType<MissionControlConfig> {
} }
internalBinaryWrite(message: MissionControlConfig, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { internalBinaryWrite(message: MissionControlConfig, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* uint64 half_life_seconds = 1; */ /* uint64 half_life_seconds = 1; */
if (message.halfLifeSeconds !== 0) if (message.halfLifeSeconds !== 0n)
writer.tag(1, WireType.Varint).uint64(message.halfLifeSeconds); writer.tag(1, WireType.Varint).uint64(message.halfLifeSeconds);
/* float hop_probability = 2; */ /* float hop_probability = 2; */
if (message.hopProbability !== 0) if (message.hopProbability !== 0)
@ -2370,7 +2370,7 @@ class MissionControlConfig$Type extends MessageType<MissionControlConfig> {
if (message.maximumPaymentResults !== 0) if (message.maximumPaymentResults !== 0)
writer.tag(4, WireType.Varint).uint32(message.maximumPaymentResults); writer.tag(4, WireType.Varint).uint32(message.maximumPaymentResults);
/* uint64 minimum_failure_relax_interval = 5; */ /* uint64 minimum_failure_relax_interval = 5; */
if (message.minimumFailureRelaxInterval !== 0) if (message.minimumFailureRelaxInterval !== 0n)
writer.tag(5, WireType.Varint).uint64(message.minimumFailureRelaxInterval); writer.tag(5, WireType.Varint).uint64(message.minimumFailureRelaxInterval);
let u = options.writeUnknownFields; let u = options.writeUnknownFields;
if (u !== false) if (u !== false)
@ -2388,11 +2388,11 @@ class QueryProbabilityRequest$Type extends MessageType<QueryProbabilityRequest>
super("routerrpc.QueryProbabilityRequest", [ super("routerrpc.QueryProbabilityRequest", [
{ no: 1, name: "from_node", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 1, name: "from_node", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
{ no: 2, name: "to_node", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 2, name: "to_node", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
{ no: 3, name: "amt_msat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 2 /*LongType.NUMBER*/ } { no: 3, name: "amt_msat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ }
]); ]);
} }
create(value?: PartialMessage<QueryProbabilityRequest>): QueryProbabilityRequest { create(value?: PartialMessage<QueryProbabilityRequest>): QueryProbabilityRequest {
const message = { fromNode: new Uint8Array(0), toNode: new Uint8Array(0), amtMsat: 0 }; const message = { fromNode: new Uint8Array(0), toNode: new Uint8Array(0), amtMsat: 0n };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined) if (value !== undefined)
reflectionMergePartial<QueryProbabilityRequest>(this, message, value); reflectionMergePartial<QueryProbabilityRequest>(this, message, value);
@ -2410,7 +2410,7 @@ class QueryProbabilityRequest$Type extends MessageType<QueryProbabilityRequest>
message.toNode = reader.bytes(); message.toNode = reader.bytes();
break; break;
case /* int64 amt_msat */ 3: case /* int64 amt_msat */ 3:
message.amtMsat = reader.int64().toNumber(); message.amtMsat = reader.int64().toBigInt();
break; break;
default: default:
let u = options.readUnknownField; let u = options.readUnknownField;
@ -2431,7 +2431,7 @@ class QueryProbabilityRequest$Type extends MessageType<QueryProbabilityRequest>
if (message.toNode.length) if (message.toNode.length)
writer.tag(2, WireType.LengthDelimited).bytes(message.toNode); writer.tag(2, WireType.LengthDelimited).bytes(message.toNode);
/* int64 amt_msat = 3; */ /* int64 amt_msat = 3; */
if (message.amtMsat !== 0) if (message.amtMsat !== 0n)
writer.tag(3, WireType.Varint).int64(message.amtMsat); writer.tag(3, WireType.Varint).int64(message.amtMsat);
let u = options.writeUnknownFields; let u = options.writeUnknownFields;
if (u !== false) if (u !== false)
@ -2501,7 +2501,7 @@ export const QueryProbabilityResponse = new QueryProbabilityResponse$Type();
class BuildRouteRequest$Type extends MessageType<BuildRouteRequest> { class BuildRouteRequest$Type extends MessageType<BuildRouteRequest> {
constructor() { constructor() {
super("routerrpc.BuildRouteRequest", [ super("routerrpc.BuildRouteRequest", [
{ no: 1, name: "amt_msat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 1, name: "amt_msat", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 2, name: "final_cltv_delta", kind: "scalar", T: 5 /*ScalarType.INT32*/ }, { no: 2, name: "final_cltv_delta", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
{ no: 3, name: "outgoing_chan_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/ }, { no: 3, name: "outgoing_chan_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/ },
{ no: 4, name: "hop_pubkeys", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 12 /*ScalarType.BYTES*/ }, { no: 4, name: "hop_pubkeys", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 12 /*ScalarType.BYTES*/ },
@ -2509,7 +2509,7 @@ class BuildRouteRequest$Type extends MessageType<BuildRouteRequest> {
]); ]);
} }
create(value?: PartialMessage<BuildRouteRequest>): BuildRouteRequest { create(value?: PartialMessage<BuildRouteRequest>): BuildRouteRequest {
const message = { amtMsat: 0, finalCltvDelta: 0, outgoingChanId: "0", hopPubkeys: [], paymentAddr: new Uint8Array(0) }; const message = { amtMsat: 0n, finalCltvDelta: 0, outgoingChanId: "0", hopPubkeys: [], paymentAddr: new Uint8Array(0) };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined) if (value !== undefined)
reflectionMergePartial<BuildRouteRequest>(this, message, value); reflectionMergePartial<BuildRouteRequest>(this, message, value);
@ -2521,7 +2521,7 @@ class BuildRouteRequest$Type extends MessageType<BuildRouteRequest> {
let [fieldNo, wireType] = reader.tag(); let [fieldNo, wireType] = reader.tag();
switch (fieldNo) { switch (fieldNo) {
case /* int64 amt_msat */ 1: case /* int64 amt_msat */ 1:
message.amtMsat = reader.int64().toNumber(); message.amtMsat = reader.int64().toBigInt();
break; break;
case /* int32 final_cltv_delta */ 2: case /* int32 final_cltv_delta */ 2:
message.finalCltvDelta = reader.int32(); message.finalCltvDelta = reader.int32();
@ -2548,7 +2548,7 @@ class BuildRouteRequest$Type extends MessageType<BuildRouteRequest> {
} }
internalBinaryWrite(message: BuildRouteRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { internalBinaryWrite(message: BuildRouteRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* int64 amt_msat = 1; */ /* int64 amt_msat = 1; */
if (message.amtMsat !== 0) if (message.amtMsat !== 0n)
writer.tag(1, WireType.Varint).int64(message.amtMsat); writer.tag(1, WireType.Varint).int64(message.amtMsat);
/* int32 final_cltv_delta = 2; */ /* int32 final_cltv_delta = 2; */
if (message.finalCltvDelta !== 0) if (message.finalCltvDelta !== 0)
@ -2649,11 +2649,11 @@ export const SubscribeHtlcEventsRequest = new SubscribeHtlcEventsRequest$Type();
class HtlcEvent$Type extends MessageType<HtlcEvent> { class HtlcEvent$Type extends MessageType<HtlcEvent> {
constructor() { constructor() {
super("routerrpc.HtlcEvent", [ super("routerrpc.HtlcEvent", [
{ no: 1, name: "incoming_channel_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 1, name: "incoming_channel_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 2, name: "outgoing_channel_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 2, name: "outgoing_channel_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 3, name: "incoming_htlc_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 3, name: "incoming_htlc_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 4, name: "outgoing_htlc_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 4, name: "outgoing_htlc_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 5, name: "timestamp_ns", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 5, name: "timestamp_ns", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 6, name: "event_type", kind: "enum", T: () => ["routerrpc.HtlcEvent.EventType", HtlcEvent_EventType] }, { no: 6, name: "event_type", kind: "enum", T: () => ["routerrpc.HtlcEvent.EventType", HtlcEvent_EventType] },
{ no: 7, name: "forward_event", kind: "message", oneof: "event", T: () => ForwardEvent }, { no: 7, name: "forward_event", kind: "message", oneof: "event", T: () => ForwardEvent },
{ no: 8, name: "forward_fail_event", kind: "message", oneof: "event", T: () => ForwardFailEvent }, { no: 8, name: "forward_fail_event", kind: "message", oneof: "event", T: () => ForwardFailEvent },
@ -2664,7 +2664,7 @@ class HtlcEvent$Type extends MessageType<HtlcEvent> {
]); ]);
} }
create(value?: PartialMessage<HtlcEvent>): HtlcEvent { create(value?: PartialMessage<HtlcEvent>): HtlcEvent {
const message = { incomingChannelId: 0, outgoingChannelId: 0, incomingHtlcId: 0, outgoingHtlcId: 0, timestampNs: 0, eventType: 0, event: { oneofKind: undefined } }; const message = { incomingChannelId: 0n, outgoingChannelId: 0n, incomingHtlcId: 0n, outgoingHtlcId: 0n, timestampNs: 0n, eventType: 0, event: { oneofKind: undefined } };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined) if (value !== undefined)
reflectionMergePartial<HtlcEvent>(this, message, value); reflectionMergePartial<HtlcEvent>(this, message, value);
@ -2676,19 +2676,19 @@ class HtlcEvent$Type extends MessageType<HtlcEvent> {
let [fieldNo, wireType] = reader.tag(); let [fieldNo, wireType] = reader.tag();
switch (fieldNo) { switch (fieldNo) {
case /* uint64 incoming_channel_id */ 1: case /* uint64 incoming_channel_id */ 1:
message.incomingChannelId = reader.uint64().toNumber(); message.incomingChannelId = reader.uint64().toBigInt();
break; break;
case /* uint64 outgoing_channel_id */ 2: case /* uint64 outgoing_channel_id */ 2:
message.outgoingChannelId = reader.uint64().toNumber(); message.outgoingChannelId = reader.uint64().toBigInt();
break; break;
case /* uint64 incoming_htlc_id */ 3: case /* uint64 incoming_htlc_id */ 3:
message.incomingHtlcId = reader.uint64().toNumber(); message.incomingHtlcId = reader.uint64().toBigInt();
break; break;
case /* uint64 outgoing_htlc_id */ 4: case /* uint64 outgoing_htlc_id */ 4:
message.outgoingHtlcId = reader.uint64().toNumber(); message.outgoingHtlcId = reader.uint64().toBigInt();
break; break;
case /* uint64 timestamp_ns */ 5: case /* uint64 timestamp_ns */ 5:
message.timestampNs = reader.uint64().toNumber(); message.timestampNs = reader.uint64().toBigInt();
break; break;
case /* routerrpc.HtlcEvent.EventType event_type */ 6: case /* routerrpc.HtlcEvent.EventType event_type */ 6:
message.eventType = reader.int32(); message.eventType = reader.int32();
@ -2742,19 +2742,19 @@ class HtlcEvent$Type extends MessageType<HtlcEvent> {
} }
internalBinaryWrite(message: HtlcEvent, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { internalBinaryWrite(message: HtlcEvent, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* uint64 incoming_channel_id = 1; */ /* uint64 incoming_channel_id = 1; */
if (message.incomingChannelId !== 0) if (message.incomingChannelId !== 0n)
writer.tag(1, WireType.Varint).uint64(message.incomingChannelId); writer.tag(1, WireType.Varint).uint64(message.incomingChannelId);
/* uint64 outgoing_channel_id = 2; */ /* uint64 outgoing_channel_id = 2; */
if (message.outgoingChannelId !== 0) if (message.outgoingChannelId !== 0n)
writer.tag(2, WireType.Varint).uint64(message.outgoingChannelId); writer.tag(2, WireType.Varint).uint64(message.outgoingChannelId);
/* uint64 incoming_htlc_id = 3; */ /* uint64 incoming_htlc_id = 3; */
if (message.incomingHtlcId !== 0) if (message.incomingHtlcId !== 0n)
writer.tag(3, WireType.Varint).uint64(message.incomingHtlcId); writer.tag(3, WireType.Varint).uint64(message.incomingHtlcId);
/* uint64 outgoing_htlc_id = 4; */ /* uint64 outgoing_htlc_id = 4; */
if (message.outgoingHtlcId !== 0) if (message.outgoingHtlcId !== 0n)
writer.tag(4, WireType.Varint).uint64(message.outgoingHtlcId); writer.tag(4, WireType.Varint).uint64(message.outgoingHtlcId);
/* uint64 timestamp_ns = 5; */ /* uint64 timestamp_ns = 5; */
if (message.timestampNs !== 0) if (message.timestampNs !== 0n)
writer.tag(5, WireType.Varint).uint64(message.timestampNs); writer.tag(5, WireType.Varint).uint64(message.timestampNs);
/* routerrpc.HtlcEvent.EventType event_type = 6; */ /* routerrpc.HtlcEvent.EventType event_type = 6; */
if (message.eventType !== 0) if (message.eventType !== 0)
@ -2793,12 +2793,12 @@ class HtlcInfo$Type extends MessageType<HtlcInfo> {
super("routerrpc.HtlcInfo", [ super("routerrpc.HtlcInfo", [
{ no: 1, name: "incoming_timelock", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 1, name: "incoming_timelock", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
{ no: 2, name: "outgoing_timelock", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 2, name: "outgoing_timelock", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
{ no: 3, name: "incoming_amt_msat", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 3, name: "incoming_amt_msat", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 4, name: "outgoing_amt_msat", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 2 /*LongType.NUMBER*/ } { no: 4, name: "outgoing_amt_msat", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }
]); ]);
} }
create(value?: PartialMessage<HtlcInfo>): HtlcInfo { create(value?: PartialMessage<HtlcInfo>): HtlcInfo {
const message = { incomingTimelock: 0, outgoingTimelock: 0, incomingAmtMsat: 0, outgoingAmtMsat: 0 }; const message = { incomingTimelock: 0, outgoingTimelock: 0, incomingAmtMsat: 0n, outgoingAmtMsat: 0n };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined) if (value !== undefined)
reflectionMergePartial<HtlcInfo>(this, message, value); reflectionMergePartial<HtlcInfo>(this, message, value);
@ -2816,10 +2816,10 @@ class HtlcInfo$Type extends MessageType<HtlcInfo> {
message.outgoingTimelock = reader.uint32(); message.outgoingTimelock = reader.uint32();
break; break;
case /* uint64 incoming_amt_msat */ 3: case /* uint64 incoming_amt_msat */ 3:
message.incomingAmtMsat = reader.uint64().toNumber(); message.incomingAmtMsat = reader.uint64().toBigInt();
break; break;
case /* uint64 outgoing_amt_msat */ 4: case /* uint64 outgoing_amt_msat */ 4:
message.outgoingAmtMsat = reader.uint64().toNumber(); message.outgoingAmtMsat = reader.uint64().toBigInt();
break; break;
default: default:
let u = options.readUnknownField; let u = options.readUnknownField;
@ -2840,10 +2840,10 @@ class HtlcInfo$Type extends MessageType<HtlcInfo> {
if (message.outgoingTimelock !== 0) if (message.outgoingTimelock !== 0)
writer.tag(2, WireType.Varint).uint32(message.outgoingTimelock); writer.tag(2, WireType.Varint).uint32(message.outgoingTimelock);
/* uint64 incoming_amt_msat = 3; */ /* uint64 incoming_amt_msat = 3; */
if (message.incomingAmtMsat !== 0) if (message.incomingAmtMsat !== 0n)
writer.tag(3, WireType.Varint).uint64(message.incomingAmtMsat); writer.tag(3, WireType.Varint).uint64(message.incomingAmtMsat);
/* uint64 outgoing_amt_msat = 4; */ /* uint64 outgoing_amt_msat = 4; */
if (message.outgoingAmtMsat !== 0) if (message.outgoingAmtMsat !== 0n)
writer.tag(4, WireType.Varint).uint64(message.outgoingAmtMsat); writer.tag(4, WireType.Varint).uint64(message.outgoingAmtMsat);
let u = options.writeUnknownFields; let u = options.writeUnknownFields;
if (u !== false) if (u !== false)
@ -3188,12 +3188,12 @@ export const PaymentStatus = new PaymentStatus$Type();
class CircuitKey$Type extends MessageType<CircuitKey> { class CircuitKey$Type extends MessageType<CircuitKey> {
constructor() { constructor() {
super("routerrpc.CircuitKey", [ super("routerrpc.CircuitKey", [
{ no: 1, name: "chan_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 1, name: "chan_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 2, name: "htlc_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 2 /*LongType.NUMBER*/ } { no: 2, name: "htlc_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }
]); ]);
} }
create(value?: PartialMessage<CircuitKey>): CircuitKey { create(value?: PartialMessage<CircuitKey>): CircuitKey {
const message = { chanId: 0, htlcId: 0 }; const message = { chanId: 0n, htlcId: 0n };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined) if (value !== undefined)
reflectionMergePartial<CircuitKey>(this, message, value); reflectionMergePartial<CircuitKey>(this, message, value);
@ -3205,10 +3205,10 @@ class CircuitKey$Type extends MessageType<CircuitKey> {
let [fieldNo, wireType] = reader.tag(); let [fieldNo, wireType] = reader.tag();
switch (fieldNo) { switch (fieldNo) {
case /* uint64 chan_id */ 1: case /* uint64 chan_id */ 1:
message.chanId = reader.uint64().toNumber(); message.chanId = reader.uint64().toBigInt();
break; break;
case /* uint64 htlc_id */ 2: case /* uint64 htlc_id */ 2:
message.htlcId = reader.uint64().toNumber(); message.htlcId = reader.uint64().toBigInt();
break; break;
default: default:
let u = options.readUnknownField; let u = options.readUnknownField;
@ -3223,10 +3223,10 @@ class CircuitKey$Type extends MessageType<CircuitKey> {
} }
internalBinaryWrite(message: CircuitKey, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { internalBinaryWrite(message: CircuitKey, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
/* uint64 chan_id = 1; */ /* uint64 chan_id = 1; */
if (message.chanId !== 0) if (message.chanId !== 0n)
writer.tag(1, WireType.Varint).uint64(message.chanId); writer.tag(1, WireType.Varint).uint64(message.chanId);
/* uint64 htlc_id = 2; */ /* uint64 htlc_id = 2; */
if (message.htlcId !== 0) if (message.htlcId !== 0n)
writer.tag(2, WireType.Varint).uint64(message.htlcId); writer.tag(2, WireType.Varint).uint64(message.htlcId);
let u = options.writeUnknownFields; let u = options.writeUnknownFields;
if (u !== false) if (u !== false)
@ -3243,11 +3243,11 @@ class ForwardHtlcInterceptRequest$Type extends MessageType<ForwardHtlcInterceptR
constructor() { constructor() {
super("routerrpc.ForwardHtlcInterceptRequest", [ super("routerrpc.ForwardHtlcInterceptRequest", [
{ no: 1, name: "incoming_circuit_key", kind: "message", T: () => CircuitKey }, { no: 1, name: "incoming_circuit_key", kind: "message", T: () => CircuitKey },
{ no: 5, name: "incoming_amount_msat", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 5, name: "incoming_amount_msat", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 6, name: "incoming_expiry", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 6, name: "incoming_expiry", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
{ no: 2, name: "payment_hash", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 2, name: "payment_hash", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
{ no: 7, name: "outgoing_requested_chan_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 7, name: "outgoing_requested_chan_id", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 3, name: "outgoing_amount_msat", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 2 /*LongType.NUMBER*/ }, { no: 3, name: "outgoing_amount_msat", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
{ no: 4, name: "outgoing_expiry", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 4, name: "outgoing_expiry", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
{ no: 8, name: "custom_records", kind: "map", K: 4 /*ScalarType.UINT64*/, V: { kind: "scalar", T: 12 /*ScalarType.BYTES*/ } }, { no: 8, name: "custom_records", kind: "map", K: 4 /*ScalarType.UINT64*/, V: { kind: "scalar", T: 12 /*ScalarType.BYTES*/ } },
{ no: 9, name: "onion_blob", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 9, name: "onion_blob", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
@ -3255,7 +3255,7 @@ class ForwardHtlcInterceptRequest$Type extends MessageType<ForwardHtlcInterceptR
]); ]);
} }
create(value?: PartialMessage<ForwardHtlcInterceptRequest>): ForwardHtlcInterceptRequest { create(value?: PartialMessage<ForwardHtlcInterceptRequest>): ForwardHtlcInterceptRequest {
const message = { incomingAmountMsat: 0, incomingExpiry: 0, paymentHash: new Uint8Array(0), outgoingRequestedChanId: 0, outgoingAmountMsat: 0, outgoingExpiry: 0, customRecords: {}, onionBlob: new Uint8Array(0), autoFailHeight: 0 }; const message = { incomingAmountMsat: 0n, incomingExpiry: 0, paymentHash: new Uint8Array(0), outgoingRequestedChanId: 0n, outgoingAmountMsat: 0n, outgoingExpiry: 0, customRecords: {}, onionBlob: new Uint8Array(0), autoFailHeight: 0 };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined) if (value !== undefined)
reflectionMergePartial<ForwardHtlcInterceptRequest>(this, message, value); reflectionMergePartial<ForwardHtlcInterceptRequest>(this, message, value);
@ -3270,7 +3270,7 @@ class ForwardHtlcInterceptRequest$Type extends MessageType<ForwardHtlcInterceptR
message.incomingCircuitKey = CircuitKey.internalBinaryRead(reader, reader.uint32(), options, message.incomingCircuitKey); message.incomingCircuitKey = CircuitKey.internalBinaryRead(reader, reader.uint32(), options, message.incomingCircuitKey);
break; break;
case /* uint64 incoming_amount_msat */ 5: case /* uint64 incoming_amount_msat */ 5:
message.incomingAmountMsat = reader.uint64().toNumber(); message.incomingAmountMsat = reader.uint64().toBigInt();
break; break;
case /* uint32 incoming_expiry */ 6: case /* uint32 incoming_expiry */ 6:
message.incomingExpiry = reader.uint32(); message.incomingExpiry = reader.uint32();
@ -3279,10 +3279,10 @@ class ForwardHtlcInterceptRequest$Type extends MessageType<ForwardHtlcInterceptR
message.paymentHash = reader.bytes(); message.paymentHash = reader.bytes();
break; break;
case /* uint64 outgoing_requested_chan_id */ 7: case /* uint64 outgoing_requested_chan_id */ 7:
message.outgoingRequestedChanId = reader.uint64().toNumber(); message.outgoingRequestedChanId = reader.uint64().toBigInt();
break; break;
case /* uint64 outgoing_amount_msat */ 3: case /* uint64 outgoing_amount_msat */ 3:
message.outgoingAmountMsat = reader.uint64().toNumber(); message.outgoingAmountMsat = reader.uint64().toBigInt();
break; break;
case /* uint32 outgoing_expiry */ 4: case /* uint32 outgoing_expiry */ 4:
message.outgoingExpiry = reader.uint32(); message.outgoingExpiry = reader.uint32();
@ -3328,7 +3328,7 @@ class ForwardHtlcInterceptRequest$Type extends MessageType<ForwardHtlcInterceptR
if (message.incomingCircuitKey) if (message.incomingCircuitKey)
CircuitKey.internalBinaryWrite(message.incomingCircuitKey, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); CircuitKey.internalBinaryWrite(message.incomingCircuitKey, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
/* uint64 incoming_amount_msat = 5; */ /* uint64 incoming_amount_msat = 5; */
if (message.incomingAmountMsat !== 0) if (message.incomingAmountMsat !== 0n)
writer.tag(5, WireType.Varint).uint64(message.incomingAmountMsat); writer.tag(5, WireType.Varint).uint64(message.incomingAmountMsat);
/* uint32 incoming_expiry = 6; */ /* uint32 incoming_expiry = 6; */
if (message.incomingExpiry !== 0) if (message.incomingExpiry !== 0)
@ -3337,10 +3337,10 @@ class ForwardHtlcInterceptRequest$Type extends MessageType<ForwardHtlcInterceptR
if (message.paymentHash.length) if (message.paymentHash.length)
writer.tag(2, WireType.LengthDelimited).bytes(message.paymentHash); writer.tag(2, WireType.LengthDelimited).bytes(message.paymentHash);
/* uint64 outgoing_requested_chan_id = 7; */ /* uint64 outgoing_requested_chan_id = 7; */
if (message.outgoingRequestedChanId !== 0) if (message.outgoingRequestedChanId !== 0n)
writer.tag(7, WireType.Varint).uint64(message.outgoingRequestedChanId); writer.tag(7, WireType.Varint).uint64(message.outgoingRequestedChanId);
/* uint64 outgoing_amount_msat = 3; */ /* uint64 outgoing_amount_msat = 3; */
if (message.outgoingAmountMsat !== 0) if (message.outgoingAmountMsat !== 0n)
writer.tag(3, WireType.Varint).uint64(message.outgoingAmountMsat); writer.tag(3, WireType.Varint).uint64(message.outgoingAmountMsat);
/* uint32 outgoing_expiry = 4; */ /* uint32 outgoing_expiry = 4; */
if (message.outgoingExpiry !== 0) if (message.outgoingExpiry !== 0)

View file

@ -89,7 +89,19 @@ service LightningPub {
option (http_method) = "post"; option (http_method) = "post";
option (http_route) = "/api/user/auth"; option (http_route) = "/api/user/auth";
} }
// USER rpc GetUserInfo(structs.Empty)returns(structs.UserInfo){
option (auth_type) = "User";
option (http_method) = "post";
option (http_route) = "/api/user/info";
option (nostr) = true;
}
// USER
rpc GetUserOperations(structs.GetUserOperationsRequest) returns (structs.GetUserOperationsResponse) {
option (auth_type) = "User";
option (http_method) = "post";
option (http_route) = "/api/user/operations";
option (nostr) = true;
}
rpc NewAddress(structs.NewAddressRequest) returns (structs.NewAddressResponse) { rpc NewAddress(structs.NewAddressRequest) returns (structs.NewAddressResponse) {
option (auth_type) = "User"; option (auth_type) = "User";
option (http_method) = "post"; option (http_method) = "post";

View file

@ -115,3 +115,36 @@ message AuthUserResponse{
string userId = 1; string userId = 1;
string authToken = 2; string authToken = 2;
} }
message UserInfo{
string userId = 1;
int64 balance = 2;
}
message GetUserOperationsRequest{
int64 latestIncomingInvoice = 1;
int64 latestOutgoingInvoice = 2;
int64 latestIncomingTx = 3;
int64 latestOutgoingTx = 4;
}
enum UserOperationType {
INCOMING_TX =0;
OUTGOING_TX =1;
INCOMING_INVOICE =2;
OUTGOING_INVOICE=3;
}
message UserOperation{
int64 paidAtUnix=1;
UserOperationType type = 2;
bool inbound =3;
int64 amount = 4;
}
message UserOperations {
int64 fromIndex=1;
int64 toIndex=2;
repeated UserOperation operations=3;
}
message GetUserOperationsResponse{
UserOperations latestOutgoingInvoiceOperations=1;
UserOperations latestIncomingInvoiceOperations=2;
UserOperations latestOutgoingTxOperations=3;
UserOperations latestIncomingTxOperations=4;
}

View file

@ -7,6 +7,7 @@ const serverOptions = (mainHandler: Main): ServerOptions => {
GuestAuthGuard: async (_) => ({}), GuestAuthGuard: async (_) => ({}),
encryptCallback: async (_, b) => b, encryptCallback: async (_, b) => b,
decryptCallback: async (_, b) => b, decryptCallback: async (_, b) => b,
throwErrors: true
} }
} }
export default serverOptions export default serverOptions

View file

@ -1,19 +1,19 @@
import 'dotenv/config' import 'dotenv/config'
import NewServer from '../proto/autogenerated/ts/express_server' import NewServer from '../proto/autogenerated/ts/express_server.js'
import GetServerMethods from './services/serverMethods' import GetServerMethods from './services/serverMethods/index.js'
import serverOptions from './auth'; import serverOptions from './auth.js';
import Main, { LoadMainSettingsFromEnv } from './services/main' import Main, { LoadMainSettingsFromEnv } from './services/main/index.js'
import { LoadNosrtSettingsFromEnv } from './services/nostr' import { LoadNosrtSettingsFromEnv } from './services/nostr/index.js'
import nostrMiddleware from './nostrMiddleware.js' import nostrMiddleware from './nostrMiddleware.js'
const start = async () => { const start = async () => {
const mainHandler = new Main(LoadMainSettingsFromEnv()) const mainHandler = new Main(LoadMainSettingsFromEnv())
await mainHandler.storage.Connect() await mainHandler.storage.Connect()
await mainHandler.lnd.Warmup()
const serverMethods = GetServerMethods(mainHandler) const serverMethods = GetServerMethods(mainHandler)
const nostrSettings = LoadNosrtSettingsFromEnv() const nostrSettings = LoadNosrtSettingsFromEnv()
nostrMiddleware(serverMethods, mainHandler, nostrSettings) nostrMiddleware(serverMethods, mainHandler, nostrSettings)
const Server = NewServer(serverMethods, serverOptions(mainHandler)) const Server = NewServer(serverMethods, serverOptions(mainHandler))
Server.Listen(3000) Server.Listen(8080)
} }
start() start()

View file

@ -9,7 +9,7 @@ export default (serverMethods: Types.ServerMethods, mainHandler: Main, nostrSett
const nostrTransport = NewNostrTransport(serverMethods, { const nostrTransport = NewNostrTransport(serverMethods, {
NostrUserAuthGuard: async pub => { NostrUserAuthGuard: async pub => {
if (!pub || !nostrSettings.allowedPubs.includes(pub)) { if (!pub || !nostrSettings.allowedPubs.includes(pub)) {
throw new Error("nostr pub invalid or not allowed") throw new Error("nostr pub invalid or not allowed" + pub)
} }
let nostrUser = await mainHandler.storage.FindNostrUser(pub) let nostrUser = await mainHandler.storage.FindNostrUser(pub)
if (!nostrUser) { // TODO: add POW if (!nostrUser) { // TODO: add POW
@ -19,6 +19,7 @@ export default (serverMethods: Types.ServerMethods, mainHandler: Main, nostrSett
} }
}) })
const nostr = new Nostr(nostrSettings, event => { const nostr = new Nostr(nostrSettings, event => {
console.log(event)
let j: NostrRequest let j: NostrRequest
try { try {
j = JSON.parse(event.content) j = JSON.parse(event.content)

View file

@ -1,34 +1,34 @@
import { OpenChannelRequest, Invoice } from "../../../proto/lnd/lightning"; import { OpenChannelRequest, Invoice } from "../../../proto/lnd/lightning";
export const AddInvoiceReq = (value: number, memo = "", privateHints = false, expiry = 60 * 60): Invoice => ({ export const AddInvoiceReq = (value: number, memo = "", privateHints = false, expiry = 60 * 60): Invoice => ({
expiry: expiry, expiry: BigInt(expiry),
memo: memo, memo: memo,
private: privateHints, private: privateHints,
value: value, value: BigInt(value),
fallbackAddr: "", fallbackAddr: "",
cltvExpiry: 0, cltvExpiry: 0n,
descriptionHash: Buffer.alloc(0), descriptionHash: Buffer.alloc(0),
features: {}, features: {},
isAmp: false, isAmp: false,
rPreimage: Buffer.alloc(0), rPreimage: Buffer.alloc(0),
routeHints: [], routeHints: [],
valueMsat: 0, valueMsat: 0n,
addIndex: 0, addIndex: 0n,
ampInvoiceState: {}, ampInvoiceState: {},
amtPaidMsat: 0, amtPaidMsat: 0n,
amtPaidSat: 0, amtPaidSat: 0n,
creationDate: 0, creationDate: 0n,
htlcs: [], htlcs: [],
isKeysend: false, isKeysend: false,
paymentAddr: Buffer.alloc(0), paymentAddr: Buffer.alloc(0),
paymentRequest: "", paymentRequest: "",
rHash: Buffer.alloc(0), rHash: Buffer.alloc(0),
settleDate: 0, settleDate: 0n,
settleIndex: 0, settleIndex: 0n,
state: 0, state: 0,
amtPaid: 0, amtPaid: 0n,
settled: false, settled: false,
}) })

View file

@ -6,7 +6,7 @@ import * as Types from '../../../proto/autogenerated/ts/types.js'
import { LightningClient } from '../../../proto/lnd/lightning.client.js' import { LightningClient } from '../../../proto/lnd/lightning.client.js'
import { InvoicesClient } from '../../../proto/lnd/invoices.client.js' import { InvoicesClient } from '../../../proto/lnd/invoices.client.js'
import { RouterClient } from '../../../proto/lnd/router.client.js' import { RouterClient } from '../../../proto/lnd/router.client.js'
import { GetInfoResponse, AddressType, NewAddressResponse, AddInvoiceResponse, Invoice_InvoiceState, PayReq, Payment_PaymentStatus, Payment } from '../../../proto/lnd/lightning.js' import { GetInfoResponse, AddressType, NewAddressResponse, AddInvoiceResponse, Invoice_InvoiceState, PayReq, Payment_PaymentStatus, Payment, PaymentFailureReason } from '../../../proto/lnd/lightning.js'
import { OpenChannelReq } from './openChannelReq.js'; import { OpenChannelReq } from './openChannelReq.js';
import { AddInvoiceReq } from './addInvoiceReq.js'; import { AddInvoiceReq } from './addInvoiceReq.js';
import { PayInvoiceReq } from './payInvoiceReq.js'; import { PayInvoiceReq } from './payInvoiceReq.js';
@ -69,6 +69,7 @@ export default class {
this.invoices = new InvoicesClient(transport) this.invoices = new InvoicesClient(transport)
this.router = new RouterClient(transport) this.router = new RouterClient(transport)
this.SubscribeAddressPaid() this.SubscribeAddressPaid()
this.SubscribeInvoicePaid()
} }
Stop() { Stop() {
this.abortController.abort() this.abortController.abort()
@ -107,8 +108,8 @@ export default class {
SubscribeInvoicePaid() { SubscribeInvoicePaid() {
const stream = this.lightning.subscribeInvoices({ const stream = this.lightning.subscribeInvoices({
settleIndex: this.latestKnownSettleIndex, settleIndex: BigInt(this.latestKnownSettleIndex),
addIndex: 0, addIndex: 0n,
}, { abort: this.abortController.signal }) }, { abort: this.abortController.signal })
stream.responses.onMessage(invoice => { stream.responses.onMessage(invoice => {
if (invoice.state === Invoice_InvoiceState.SETTLED) { if (invoice.state === Invoice_InvoiceState.SETTLED) {
@ -162,15 +163,18 @@ export default class {
async PayInvoice(invoice: string, amount: number, feeLimit: number): Promise<Payment> { async PayInvoice(invoice: string, amount: number, feeLimit: number): Promise<Payment> {
this.checkReady() this.checkReady()
const abortController = new AbortController() const abortController = new AbortController()
const stream = this.router.sendPaymentV2(PayInvoiceReq(invoice, amount, feeLimit), { abort: abortController.signal }) const req = PayInvoiceReq(invoice, amount, feeLimit)
console.log(req)
const stream = this.router.sendPaymentV2(req, { abort: abortController.signal })
return new Promise((res, rej) => { return new Promise((res, rej) => {
stream.responses.onError(error => { stream.responses.onError(error => {
rej(error) rej(error)
}) })
stream.responses.onMessage(payment => { stream.responses.onMessage(payment => {
console.log(payment)
switch (payment.status) { switch (payment.status) {
case Payment_PaymentStatus.FAILED: case Payment_PaymentStatus.FAILED:
rej(payment.failureReason) rej(PaymentFailureReason[payment.failureReason])
return return
case Payment_PaymentStatus.SUCCEEDED: case Payment_PaymentStatus.SUCCEEDED:
res(payment) res(payment)
@ -182,7 +186,7 @@ export default class {
async EstimateChainFees(address: string, amount: number, targetConf: number) { async EstimateChainFees(address: string, amount: number, targetConf: number) {
this.checkReady() this.checkReady()
const res = await this.lightning.estimateFee({ const res = await this.lightning.estimateFee({
addrToAmount: { [address]: amount }, addrToAmount: { [address]: BigInt(amount) },
minConfs: 1, minConfs: 1,
spendUnconfirmed: false, spendUnconfirmed: false,
targetConf: targetConf targetConf: targetConf

View file

@ -3,23 +3,23 @@ import { OpenChannelRequest } from "../../../proto/lnd/lightning";
export const OpenChannelReq = (destination: string, closeAddress: string, fundingAmount: number, pushSats: number): OpenChannelRequest => ({ export const OpenChannelReq = (destination: string, closeAddress: string, fundingAmount: number, pushSats: number): OpenChannelRequest => ({
nodePubkey: Buffer.from(destination, 'hex'), nodePubkey: Buffer.from(destination, 'hex'),
closeAddress: closeAddress, closeAddress: closeAddress,
localFundingAmount: fundingAmount, localFundingAmount: BigInt(fundingAmount),
pushSat: pushSats, pushSat: BigInt(pushSats),
satPerVbyte: 0, // TBD satPerVbyte: 0n, // TBD
private: false, private: false,
minConfs: 0, // TBD minConfs: 0, // TBD
baseFee: 0, // TBD baseFee: 0n, // TBD
feeRate: 0, // TBD feeRate: 0n, // TBD
targetConf: 0, targetConf: 0,
zeroConf: false, zeroConf: false,
maxLocalCsv: 0, maxLocalCsv: 0,
remoteCsvDelay: 0, remoteCsvDelay: 0,
spendUnconfirmed: false, spendUnconfirmed: false,
minHtlcMsat: 0, minHtlcMsat: 0n,
remoteChanReserveSat: 0, remoteChanReserveSat: 0n,
remoteMaxHtlcs: 0, remoteMaxHtlcs: 0,
remoteMaxValueInFlightMsat: 0, remoteMaxValueInFlightMsat: 0n,
useBaseFee: false, useBaseFee: false,
useFeeRate: false, useFeeRate: false,
@ -27,7 +27,7 @@ export const OpenChannelReq = (destination: string, closeAddress: string, fundin
commitmentType: 0, commitmentType: 0,
scidAlias: false, scidAlias: false,
nodePubkeyString: "", nodePubkeyString: "",
satPerByte: 0, satPerByte: 0n,
fundingShim: undefined fundingShim: undefined
}) })

View file

@ -2,8 +2,8 @@ import { OpenChannelRequest } from "../../../proto/lnd/lightning";
import { SendPaymentRequest } from "../../../proto/lnd/router"; import { SendPaymentRequest } from "../../../proto/lnd/router";
export const PayInvoiceReq = (invoice: string, amount: number, feeLimit: number): SendPaymentRequest => ({ export const PayInvoiceReq = (invoice: string, amount: number, feeLimit: number): SendPaymentRequest => ({
amt: amount, amt: BigInt(amount),
feeLimitSat: feeLimit, feeLimitSat: BigInt(feeLimit),
noInflightUpdates: true, noInflightUpdates: true,
paymentRequest: invoice, paymentRequest: invoice,
maxParts: 3, maxParts: 3,
@ -11,20 +11,20 @@ export const PayInvoiceReq = (invoice: string, amount: number, feeLimit: number)
allowSelfPayment: false, allowSelfPayment: false,
amp: false, amp: false,
amtMsat: 0, amtMsat: 0n,
cltvLimit: 0, cltvLimit: 0,
dest: Buffer.alloc(0), dest: Buffer.alloc(0),
destCustomRecords: {}, destCustomRecords: {},
destFeatures: [], destFeatures: [],
feeLimitMsat: 0, feeLimitMsat: 0n,
finalCltvDelta: 0, finalCltvDelta: 0,
lastHopPubkey: Buffer.alloc(0), lastHopPubkey: Buffer.alloc(0),
maxShardSizeMsat: 0, maxShardSizeMsat: 0n,
outgoingChanIds: [], outgoingChanIds: [],
paymentAddr: Buffer.alloc(0), paymentAddr: Buffer.alloc(0),
paymentHash: Buffer.alloc(0), paymentHash: Buffer.alloc(0),
routeHints: [], routeHints: [],
timePref: 0, timePref: 0,
outgoingChanId: "" outgoingChanId: '0'
}) })

View file

@ -2,12 +2,12 @@ import { SendCoinsRequest } from "../../../proto/lnd/lightning";
export const SendCoinsReq = (address: string, amount: number, satPerVByte: number, label = ""): SendCoinsRequest => ({ export const SendCoinsReq = (address: string, amount: number, satPerVByte: number, label = ""): SendCoinsRequest => ({
addr: address, addr: address,
amount: amount, amount: BigInt(amount),
label: label, label: label,
satPerVbyte: satPerVByte, satPerVbyte: BigInt(satPerVByte),
targetConf: 0, targetConf: 0,
minConfs: 1, minConfs: 1,
sendAll: false, sendAll: false,
spendUnconfirmed: false, spendUnconfirmed: false,
satPerByte: 0 satPerByte: BigInt(0)
}) })

View file

@ -4,6 +4,8 @@ import Storage, { LoadStorageSettingsFromEnv, StorageSettings } from '../storage
import * as Types from '../../../proto/autogenerated/ts/types.js' import * as Types from '../../../proto/autogenerated/ts/types.js'
import LND, { AddressPaidCb, InvoicePaidCb, LndSettings, LoadLndSettingsFromEnv } from '../lnd/index.js' import LND, { AddressPaidCb, InvoicePaidCb, LndSettings, LoadLndSettingsFromEnv } from '../lnd/index.js'
import { EnvMustBeInteger, EnvMustBeNonEmptyString } from '../helpers/envParser.js' import { EnvMustBeInteger, EnvMustBeNonEmptyString } from '../helpers/envParser.js'
import { UserReceivingInvoice } from '../storage/entity/UserReceivingInvoice.js'
import { Type } from 'typescript'
export type MainSettings = { export type MainSettings = {
storageSettings: StorageSettings, storageSettings: StorageSettings,
lndSettings: LndSettings, lndSettings: LndSettings,
@ -26,32 +28,39 @@ export const LoadMainSettingsFromEnv = (test = false): MainSettings => {
serviceUrl: EnvMustBeNonEmptyString("SERVICE_URL") serviceUrl: EnvMustBeNonEmptyString("SERVICE_URL")
} }
} }
enum ActionType {
INCOMING_TX = "INCOMING_TX",
OUTGOING_TX = "OUTGOING_TX",
INCOMING_INVOICE = "INCOMING_INVOICE",
OUTGOING_INVOICE = "OUTGOING_INVOICE"
type UserOperationsSub = {
id: string
newIncomingInvoice: (operation: Types.UserOperation) => void
newOutgoingInvoice: (operation: Types.UserOperation) => void
newIncomingTx: (operation: Types.UserOperation) => void
newOutgoingTx: (operation: Types.UserOperation) => void
}
interface UserOperationInfo {
serial_id: number
paid_amount: number
paid_at_unix: number
} }
const defaultLnurlPayMetadata = '[["text/plain", "lnurl pay to Lightning.pub"]]' const defaultLnurlPayMetadata = '[["text/plain", "lnurl pay to Lightning.pub"]]'
export default class { export default class {
storage: Storage storage: Storage
lnd: LND lnd: LND
settings: MainSettings settings: MainSettings
userOperationsSub: UserOperationsSub | null = null
constructor(settings: MainSettings) { constructor(settings: MainSettings) {
this.settings = settings this.settings = settings
this.storage = new Storage(settings.storageSettings) this.storage = new Storage(settings.storageSettings)
this.lnd = new LND(settings.lndSettings, this.addressPaidCb, this.invoicePaidCb) this.lnd = new LND(settings.lndSettings, this.addressPaidCb, this.invoicePaidCb)
} }
getServiceFee(action: ActionType, amount: number): number { getServiceFee(action: Types.UserOperationType, amount: number): number {
switch (action) { switch (action) {
case ActionType.INCOMING_TX: case Types.UserOperationType.INCOMING_TX:
return Math.ceil(this.settings.incomingTxFee * amount) return Math.ceil(this.settings.incomingTxFee * amount)
case ActionType.OUTGOING_TX: case Types.UserOperationType.OUTGOING_TX:
return Math.ceil(this.settings.outgoingTxFee * amount) return Math.ceil(this.settings.outgoingTxFee * amount)
case ActionType.INCOMING_INVOICE: case Types.UserOperationType.INCOMING_INVOICE:
return Math.ceil(this.settings.incomingInvoiceFee * amount) return Math.ceil(this.settings.incomingInvoiceFee * amount)
case ActionType.OUTGOING_INVOICE: case Types.UserOperationType.OUTGOING_INVOICE:
return Math.ceil(this.settings.outgoingInvoiceFee * amount) return Math.ceil(this.settings.outgoingInvoiceFee * amount)
default: default:
throw new Error("Unknown service action type") throw new Error("Unknown service action type")
@ -61,21 +70,22 @@ export default class {
this.storage.StartTransaction(async tx => { this.storage.StartTransaction(async tx => {
const userAddress = await this.storage.GetAddressOwner(address, tx) const userAddress = await this.storage.GetAddressOwner(address, tx)
if (!userAddress) { return } if (!userAddress) { return }
const fee = this.getServiceFee(ActionType.INCOMING_TX, amount) const fee = this.getServiceFee(Types.UserOperationType.INCOMING_TX, amount)
try { try {
// This call will fail if the transaction is already registered // This call will fail if the transaction is already registered
const addedTx = await this.storage.AddAddressReceivingTransaction(userAddress, txOutput.hash, txOutput.index, amount, fee, tx) const addedTx = await this.storage.AddAddressReceivingTransaction(userAddress, txOutput.hash, txOutput.index, amount, fee, tx)
await this.storage.IncrementUserBalance(userAddress.user.user_id, addedTx.amount, tx) await this.storage.IncrementUserBalance(userAddress.user.user_id, addedTx.paid_amount, tx)
} catch { } catch {
} }
}) })
} }
invoicePaidCb: InvoicePaidCb = (paymentRequest, amount) => { invoicePaidCb: InvoicePaidCb = (paymentRequest, amount) => {
this.storage.StartTransaction(async tx => { this.storage.StartTransaction(async tx => {
const userInvoice = await this.storage.GetInvoiceOwner(paymentRequest, tx) const userInvoice = await this.storage.GetInvoiceOwner(paymentRequest, tx)
if (!userInvoice || userInvoice.paid) { return } if (!userInvoice || userInvoice.paid_at_unix > 0) { return }
const fee = this.getServiceFee(ActionType.INCOMING_INVOICE, amount) const fee = this.getServiceFee(Types.UserOperationType.INCOMING_INVOICE, amount)
try { try {
// This call will fail if the invoice is already registered // This call will fail if the invoice is already registered
await this.storage.FlagInvoiceAsPaid(userInvoice, amount, fee, tx) await this.storage.FlagInvoiceAsPaid(userInvoice, amount, fee, tx)
@ -134,14 +144,14 @@ export default class {
async PayInvoice(userId: string, req: Types.PayInvoiceRequest): Promise<Types.PayInvoiceResponse> { async PayInvoice(userId: string, req: Types.PayInvoiceRequest): Promise<Types.PayInvoiceResponse> {
const decoded = await this.lnd.DecodeInvoice(req.invoice) const decoded = await this.lnd.DecodeInvoice(req.invoice)
if (decoded.numSatoshis !== 0 && req.amount !== 0) { if (decoded.numSatoshis !== 0n && req.amount !== 0) {
throw new Error("invoice has value, do not provide amount the the request") throw new Error("invoice has value, do not provide amount the the request")
} }
if (decoded.numSatoshis === 0 && req.amount === 0) { if (decoded.numSatoshis === 0n && req.amount === 0) {
throw new Error("invoice has no value, an amount must be provided in the request") throw new Error("invoice has no value, an amount must be provided in the request")
} }
const payAmount = req.amount !== 0 ? req.amount : Number(decoded.numSatoshis) const payAmount = req.amount !== 0 ? req.amount : Number(decoded.numSatoshis)
const serviceFee = this.getServiceFee(ActionType.OUTGOING_INVOICE, payAmount) const serviceFee = this.getServiceFee(Types.UserOperationType.OUTGOING_INVOICE, payAmount)
const totalAmountToDecrement = payAmount + serviceFee const totalAmountToDecrement = payAmount + serviceFee
@ -161,7 +171,7 @@ export default class {
const satPerVByte = Number(estimate.satPerVbyte) const satPerVByte = Number(estimate.satPerVbyte)
const chainFees = Number(estimate.feeSat) const chainFees = Number(estimate.feeSat)
const total = req.amoutSats + chainFees const total = req.amoutSats + chainFees
const serviceFee = this.getServiceFee(ActionType.OUTGOING_INVOICE, req.amoutSats) const serviceFee = this.getServiceFee(Types.UserOperationType.OUTGOING_INVOICE, req.amoutSats)
await this.lockUserWithMinBalance(userId, total + serviceFee) await this.lockUserWithMinBalance(userId, total + serviceFee)
const payment = await this.lnd.PayAddress(req.address, req.amoutSats, satPerVByte) const payment = await this.lnd.PayAddress(req.address, req.amoutSats, satPerVByte)
await this.storage.DecrementUserBalance(userId, total + serviceFee) await this.storage.DecrementUserBalance(userId, total + serviceFee)
@ -243,6 +253,50 @@ export default class {
async OpenChannel(userId: string, req: Types.OpenChannelRequest): Promise<Types.OpenChannelResponse> { throw new Error("WIP") } async OpenChannel(userId: string, req: Types.OpenChannelRequest): Promise<Types.OpenChannelResponse> { throw new Error("WIP") }
mapOperations(operations: UserOperationInfo[], type: Types.UserOperationType, inbound: boolean): Types.UserOperations {
if (operations.length === 0) {
return {
fromIndex: 0,
toIndex: 0,
operations: []
}
}
return {
toIndex: operations[0].serial_id,
fromIndex: operations[operations.length - 1].serial_id,
operations: operations.map((o: UserOperationInfo): Types.UserOperation => ({
inbound,
type,
amount: o.paid_amount,
paidAtUnix: o.paid_at_unix
}))
}
}
async GetUserInfo(userId: string): Promise<Types.UserInfo> {
const user = await this.storage.GetUser(userId)
return {
userId: userId,
balance: user.balance_sats
}
}
async GetUserOperations(userId: string, req: Types.GetUserOperationsRequest): Promise<Types.GetUserOperationsResponse> {
const [outgoingInvoices, outgoingTransactions, incomingInvoices, incomingTransactions] = await Promise.all([
this.storage.GetUserInvoicePayments(userId, req.latestOutgoingInvoice),
this.storage.GetUserTransactionPayments(userId, req.latestOutgoingTx),
this.storage.GetUserInvoicesFlaggedAsPaid(userId, req.latestIncomingInvoice),
this.storage.GetUserReceivingTransactions(userId, req.latestIncomingTx)
])
return {
latestIncomingInvoiceOperations: this.mapOperations(incomingInvoices, Types.UserOperationType.INCOMING_INVOICE, true),
latestIncomingTxOperations: this.mapOperations(incomingTransactions, Types.UserOperationType.INCOMING_TX, true),
latestOutgoingInvoiceOperations: this.mapOperations(outgoingInvoices, Types.UserOperationType.OUTGOING_INVOICE, false),
latestOutgoingTxOperations: this.mapOperations(outgoingTransactions, Types.UserOperationType.OUTGOING_TX, false)
}
}
encodeLnurl(base: string) { encodeLnurl(base: string) {
if (!base || typeof base !== 'string') { if (!base || typeof base !== 'string') {
throw new Error("provided string for lnurl encode is not a string or is an empty string") throw new Error("provided string for lnurl encode is not a string or is an empty string")
@ -250,5 +304,4 @@ export default class {
let words = bech32.toWords(Buffer.from(base, 'utf8')); let words = bech32.toWords(Buffer.from(base, 'utf8'));
return bech32.encode('lnurl', words, 1023); return bech32.encode('lnurl', words, 1023);
} }
} }

View file

@ -119,7 +119,7 @@ export default class Handler {
//@ts-ignore //@ts-ignore
tags: [['p', nostrPub]] tags: [['p', nostrPub]]
}, (status, url) => { }, (status, url) => {
console.log(status, url) // TODO console.log("sent message to", nostrPub) // TODO
}) })
} }
} }

View file

@ -20,6 +20,12 @@ export default (mainHandler: Main): Types.ServerMethods => {
AuthUser: async (ctx, req) => { AuthUser: async (ctx, req) => {
throw new Error("unimplemented") throw new Error("unimplemented")
}, },
GetUserInfo: async (ctx) => {
return mainHandler.GetUserInfo(ctx.user_id)
},
GetUserOperations: async (ctx, req) => {
return mainHandler.GetUserOperations(ctx.user_id, req)
},
OpenChannel: async (ctx, req) => { OpenChannel: async (ctx, req) => {
const err = Types.OpenChannelRequestValidate(req, { const err = Types.OpenChannelRequestValidate(req, {
fundingAmount_CustomCheck: amt => amt > 0, fundingAmount_CustomCheck: amt => amt > 0,
@ -42,10 +48,14 @@ export default (mainHandler: Main): Types.ServerMethods => {
return mainHandler.PayAddress(ctx.user_id, req) return mainHandler.PayAddress(ctx.user_id, req)
}, },
NewInvoice: async (ctx, req) => { NewInvoice: async (ctx, req) => {
throw new Error("unimplemented") return mainHandler.NewInvoice(ctx.user_id, req)
}, },
PayInvoice: async (ctx, req) => { PayInvoice: async (ctx, req) => {
throw new Error("unimplemented") const err = Types.PayInvoiceRequestValidate(req, {
invoice_CustomCheck: invoice => invoice !== ''
})
if (err != null) throw new Error(err.message)
return mainHandler.PayInvoice(ctx.user_id, req)
}, },
GetLnurlWithdrawLink: async (ctx) => { GetLnurlWithdrawLink: async (ctx) => {
return mainHandler.GetLnurlChannelLink(ctx.user_id) return mainHandler.GetLnurlChannelLink(ctx.user_id)

View file

@ -20,8 +20,11 @@ export class AddressReceivingTransaction {
output_index: number output_index: number
@Column() @Column()
amount: number paid_amount: number
@Column() @Column()
service_fee: number service_fee: number
@Column()
paid_at_unix: number
} }

View file

@ -16,11 +16,14 @@ export class UserInvoicePayment {
invoice: string invoice: string
@Column() @Column()
amount: number paid_amount: number
@Column() @Column()
routing_fees: number routing_fees: number
@Column() @Column()
service_fees: number service_fees: number
@Column()
paid_at_unix: number
} }

View file

@ -15,15 +15,15 @@ export class UserReceivingInvoice {
@Index({ unique: true }) @Index({ unique: true })
invoice: string invoice: string
@Column({ default: false }) @Column({ default: 0 })
paid: boolean paid_at_unix: number
@Column() @Column()
callbackUrl: string callbackUrl: string
@Column({ default: 0 }) @Column({ default: 0 })
settle_amount: number paid_amount: number
@Column() @Column({ default: 0 })
service_fee: number service_fee: number
} }

View file

@ -22,11 +22,14 @@ export class UserTransactionPayment {
output_index: number output_index: number
@Column() @Column()
amount: number paid_amount: number
@Column() @Column()
chain_fees: number chain_fees: number
@Column() @Column()
service_fees: number service_fees: number
@Column()
paid_at_unix: number
} }

View file

@ -1,4 +1,4 @@
import { DataSource, EntityManager } from "typeorm" import { DataSource, EntityManager, MoreThan, MoreThanOrEqual } from "typeorm"
import crypto from 'crypto'; import crypto from 'crypto';
import NewDB, { DbSettings, LoadDbSettingsFromEnv } from "./db.js" import NewDB, { DbSettings, LoadDbSettingsFromEnv } from "./db.js"
import { User } from "./entity/User.js" import { User } from "./entity/User.js"
@ -86,12 +86,26 @@ export default class {
user_address: address, user_address: address,
tx_hash: txHash, tx_hash: txHash,
output_index: outputIndex, output_index: outputIndex,
amount: amount, paid_amount: amount,
service_fee: serviceFee service_fee: serviceFee,
paid_at_unix: Math.floor(Date.now() / 1000)
}) })
return entityManager.getRepository(AddressReceivingTransaction).save(newAddressTransaction) return entityManager.getRepository(AddressReceivingTransaction).save(newAddressTransaction)
} }
GetUserReceivingTransactions(userId: string, fromIndex: number, entityManager = this.DB): Promise<AddressReceivingTransaction[]> {
return entityManager.getRepository(AddressReceivingTransaction).find({
where: {
user_address: { user: { user_id: userId } },
serial_id: MoreThanOrEqual(fromIndex),
paid_at_unix: MoreThan(0),
},
order: {
paid_at_unix: 'DESC'
}
})
}
async AddUserAddress(userId: string, address: string, callbackUrl = "", entityManager = this.DB): Promise<UserReceivingAddress> { async AddUserAddress(userId: string, address: string, callbackUrl = "", entityManager = this.DB): Promise<UserReceivingAddress> {
const newUserAddress = entityManager.getRepository(UserReceivingAddress).create({ const newUserAddress = entityManager.getRepository(UserReceivingAddress).create({
address, address,
@ -102,7 +116,22 @@ export default class {
} }
async FlagInvoiceAsPaid(invoice: UserReceivingInvoice, amount: number, serviceFee: number, entityManager = this.DB) { async FlagInvoiceAsPaid(invoice: UserReceivingInvoice, amount: number, serviceFee: number, entityManager = this.DB) {
return entityManager.getRepository(UserReceivingInvoice).update(invoice.serial_id, { paid: true, settle_amount: amount, service_fee: serviceFee }) return entityManager.getRepository(UserReceivingInvoice).update(invoice.serial_id, { paid_at_unix: Math.floor(Date.now() / 1000), paid_amount: amount, service_fee: serviceFee })
}
GetUserInvoicesFlaggedAsPaid(userId: string, fromIndex: number, entityManager = this.DB): Promise<UserReceivingInvoice[]> {
return entityManager.getRepository(UserReceivingInvoice).find({
where: {
user: {
user_id: userId
},
serial_id: MoreThanOrEqual(fromIndex),
paid_at_unix: MoreThan(0),
},
order: {
paid_at_unix: 'DESC'
}
})
} }
async AddUserInvoice(userId: string, invoice: string, callbackUrl = "", entityManager = this.DB): Promise<UserReceivingInvoice> { async AddUserInvoice(userId: string, invoice: string, callbackUrl = "", entityManager = this.DB): Promise<UserReceivingInvoice> {
@ -133,26 +162,58 @@ export default class {
async AddUserInvoicePayment(userId: string, invoice: string, amount: number, routingFees: number, serviceFees: number, entityManager = this.DB): Promise<UserInvoicePayment> { async AddUserInvoicePayment(userId: string, invoice: string, amount: number, routingFees: number, serviceFees: number, entityManager = this.DB): Promise<UserInvoicePayment> {
const newPayment = entityManager.getRepository(UserInvoicePayment).create({ const newPayment = entityManager.getRepository(UserInvoicePayment).create({
user: await this.GetUser(userId), user: await this.GetUser(userId),
amount, paid_amount: amount,
invoice, invoice,
routing_fees: routingFees, routing_fees: routingFees,
service_fees: serviceFees service_fees: serviceFees,
paid_at_unix: Math.floor(Date.now() / 1000)
}) })
return entityManager.getRepository(UserInvoicePayment).save(newPayment) return entityManager.getRepository(UserInvoicePayment).save(newPayment)
} }
GetUserInvoicePayments(userId: string, fromIndex: number, entityManager = this.DB): Promise<UserInvoicePayment[]> {
return entityManager.getRepository(UserInvoicePayment).find({
where: {
user: {
user_id: userId
},
serial_id: MoreThanOrEqual(fromIndex),
paid_at_unix: MoreThan(0),
},
order: {
paid_at_unix: 'DESC'
}
})
}
async AddUserTransactionPayment(userId: string, address: string, txHash: string, txOutput: number, amount: number, chainFees: number, serviceFees: number, entityManager = this.DB): Promise<UserTransactionPayment> { async AddUserTransactionPayment(userId: string, address: string, txHash: string, txOutput: number, amount: number, chainFees: number, serviceFees: number, entityManager = this.DB): Promise<UserTransactionPayment> {
const newTx = entityManager.getRepository(UserTransactionPayment).create({ const newTx = entityManager.getRepository(UserTransactionPayment).create({
user: await this.GetUser(userId), user: await this.GetUser(userId),
address, address,
amount, paid_amount: amount,
chain_fees: chainFees, chain_fees: chainFees,
output_index: txOutput, output_index: txOutput,
tx_hash: txHash, tx_hash: txHash,
service_fees: serviceFees service_fees: serviceFees,
paid_at_unix: Math.floor(Date.now() / 1000)
}) })
return entityManager.getRepository(UserTransactionPayment).save(newTx) return entityManager.getRepository(UserTransactionPayment).save(newTx)
} }
GetUserTransactionPayments(userId: string, fromIndex: number, entityManager = this.DB): Promise<UserTransactionPayment[]> {
return entityManager.getRepository(UserTransactionPayment).find({
where: {
user: {
user_id: userId
},
serial_id: MoreThanOrEqual(fromIndex),
paid_at_unix: MoreThan(0),
},
order: {
paid_at_unix: 'DESC'
}
})
}
async LockUser(userId: string, entityManager = this.DB) { async LockUser(userId: string, entityManager = this.DB) {
const res = await entityManager.getRepository(User).update({ const res = await entityManager.getRepository(User).update({
user_id: userId user_id: userId