From 72f35ed65e0f53588b7ed1c42d2dcd12310ee213 Mon Sep 17 00:00:00 2001 From: michael1011 Date: Thu, 22 Aug 2024 15:41:56 +0200 Subject: [PATCH] refactor: use new hold invoice plugin --- lib/VersionCheck.ts | 4 +- lib/lightning/cln/ClnClient.ts | 151 +- lib/proto/hold/hold_grpc_pb.d.ts | 215 +- lib/proto/hold/hold_grpc_pb.js | 187 +- lib/proto/hold/hold_pb.d.ts | 668 +-- lib/proto/hold/hold_pb.js | 4875 +++++------------- proto/hold/hold.proto | 119 + protos.js | 5 - tools/plugins/hold/__init__.py | 0 tools/plugins/hold/certs.py | 97 - tools/plugins/hold/config.py | 34 - tools/plugins/hold/consts.py | 21 - tools/plugins/hold/datastore.py | 85 - tools/plugins/hold/encoder.py | 108 - tools/plugins/hold/enums.py | 35 - tools/plugins/hold/errors.py | 20 - tools/plugins/hold/grpc_server.py | 110 - tools/plugins/hold/hold.py | 131 - tools/plugins/hold/htlc_handler.py | 181 - tools/plugins/hold/invoice.py | 194 - tools/plugins/hold/plugin.py | 240 - tools/plugins/hold/protos/__init__.py | 4 - tools/plugins/hold/protos/hold.proto | 198 - tools/plugins/hold/protos/hold_pb2.py | 92 - tools/plugins/hold/protos/hold_pb2.pyi | 299 -- tools/plugins/hold/protos/hold_pb2_grpc.py | 491 -- tools/plugins/hold/route_hints.py | 31 - tools/plugins/hold/router.py | 115 - tools/plugins/hold/server.py | 196 - tools/plugins/hold/settler.py | 110 - tools/plugins/hold/tests/__init__.py | 0 tools/plugins/hold/tests/test_certs.py | 42 - tools/plugins/hold/tests/test_encoder.py | 171 - tools/plugins/hold/tests/test_grpc.py | 593 --- tools/plugins/hold/tests/test_plugin.py | 724 --- tools/plugins/hold/tests/test_route_hints.py | 39 - tools/plugins/hold/tests/test_router.py | 63 - tools/plugins/hold/tests/test_server.py | 88 - tools/plugins/hold/tests/test_tracker.py | 116 - tools/plugins/hold/tests/utils.py | 163 - tools/plugins/hold/tracker.py | 88 - tools/plugins/hold/transformers.py | 213 - tools/plugins/hold/utils.py | 30 - 43 files changed, 1714 insertions(+), 9632 deletions(-) create mode 100644 proto/hold/hold.proto delete mode 100644 tools/plugins/hold/__init__.py delete mode 100644 tools/plugins/hold/certs.py delete mode 100644 tools/plugins/hold/config.py delete mode 100644 tools/plugins/hold/consts.py delete mode 100644 tools/plugins/hold/datastore.py delete mode 100644 tools/plugins/hold/encoder.py delete mode 100644 tools/plugins/hold/enums.py delete mode 100644 tools/plugins/hold/errors.py delete mode 100644 tools/plugins/hold/grpc_server.py delete mode 100644 tools/plugins/hold/hold.py delete mode 100644 tools/plugins/hold/htlc_handler.py delete mode 100644 tools/plugins/hold/invoice.py delete mode 100755 tools/plugins/hold/plugin.py delete mode 100644 tools/plugins/hold/protos/__init__.py delete mode 100644 tools/plugins/hold/protos/hold.proto delete mode 100644 tools/plugins/hold/protos/hold_pb2.py delete mode 100644 tools/plugins/hold/protos/hold_pb2.pyi delete mode 100644 tools/plugins/hold/protos/hold_pb2_grpc.py delete mode 100644 tools/plugins/hold/route_hints.py delete mode 100644 tools/plugins/hold/router.py delete mode 100644 tools/plugins/hold/server.py delete mode 100644 tools/plugins/hold/settler.py delete mode 100644 tools/plugins/hold/tests/__init__.py delete mode 100644 tools/plugins/hold/tests/test_certs.py delete mode 100644 tools/plugins/hold/tests/test_encoder.py delete mode 100644 tools/plugins/hold/tests/test_grpc.py delete mode 100644 tools/plugins/hold/tests/test_plugin.py delete mode 100644 tools/plugins/hold/tests/test_route_hints.py delete mode 100644 tools/plugins/hold/tests/test_router.py delete mode 100644 tools/plugins/hold/tests/test_server.py delete mode 100644 tools/plugins/hold/tests/test_tracker.py delete mode 100644 tools/plugins/hold/tests/utils.py delete mode 100644 tools/plugins/hold/tracker.py delete mode 100644 tools/plugins/hold/transformers.py delete mode 100644 tools/plugins/hold/utils.py diff --git a/lib/VersionCheck.ts b/lib/VersionCheck.ts index 30f10fdf..f0586993 100644 --- a/lib/VersionCheck.ts +++ b/lib/VersionCheck.ts @@ -86,8 +86,8 @@ class VersionCheck { maximal: '24.05', }, [ClnClient.serviceNameHold]: { - minimal: '0.0.3', - maximal: '0.0.5', + minimal: '0.1.0', + maximal: '0.1.0', }, [MpayClient.serviceName]: { minimal: '0.1.0', diff --git a/lib/lightning/cln/ClnClient.ts b/lib/lightning/cln/ClnClient.ts index 2a3404a4..eadc1ac6 100644 --- a/lib/lightning/cln/ClnClient.ts +++ b/lib/lightning/cln/ClnClient.ts @@ -21,12 +21,7 @@ import * as primitivesrpc from '../../proto/cln/primitives_pb'; import { HoldClient } from '../../proto/hold/hold_grpc_pb'; import * as holdrpc from '../../proto/hold/hold_pb'; import { WalletBalance } from '../../wallet/providers/WalletProviderInterface'; -import { - msatToSat, - satToMsat, - scidClnToLnd, - scidLndToCln, -} from '../ChannelUtils'; +import { msatToSat, satToMsat, scidClnToLnd } from '../ChannelUtils'; import Errors from '../Errors'; import { grpcOptions, unaryCall } from '../GrpcUtils'; import { @@ -354,14 +349,26 @@ class ClnClient }; public routingHints = async (node: string): Promise => { - const req = new holdrpc.RoutingHintsRequest(); - req.setNode(node); + const req = new noderpc.ListpeerchannelsRequest(); + req.setId(node); - const res = await this.unaryHoldCall< - holdrpc.RoutingHintsRequest, - holdrpc.RoutingHintsResponse.AsObject - >('routingHints', req); - return ClnClient.routingHintsFromGrpc(res.hintsList); + const channels = await this.unaryNodeCall< + noderpc.ListpeerchannelsRequest, + noderpc.ListpeerchannelsResponse.AsObject + >('listPeerChannels', req, true); + + return channels.channelsList + .filter((chan) => chan.pb_private) + .map((channel) => [ + { + nodeId: node, + chanId: scidClnToLnd(getHexString(Buffer.from(channel.channelId))), + feeBaseMsat: channel.updates!.remote!.feeBaseMsat!.msat, + feeProportionalMillionths: + channel.updates!.remote!.feeProportionalMillionths, + cltvExpiryDelta: channel.updates!.remote!.cltvExpiryDelta, + }, + ]); }; public addHoldInvoice = async ( @@ -375,7 +382,7 @@ class ClnClient ): Promise => { const req = new holdrpc.InvoiceRequest(); req.setAmountMsat(satToMsat(value)); - req.setPaymentHash(getHexString(preimageHash)); + req.setPaymentHash(preimageHash); if (cltvExpiry) { req.setMinFinalCltvExpiry(cltvExpiry); @@ -386,11 +393,11 @@ class ClnClient } if (memo) { - req.setDescription(memo); + req.setMemo(memo); } if (descriptionHash) { - req.setDescriptionHash(getHexString(descriptionHash)); + req.setHash(descriptionHash); } if (routingHints) { @@ -407,7 +414,7 @@ class ClnClient public lookupHoldInvoice = async (preimageHash: Buffer): Promise => { const req = new holdrpc.ListRequest(); - req.setPaymentHash(getHexString(preimageHash)); + req.setPaymentHash(preimageHash); const res = await this.unaryHoldCall< holdrpc.ListRequest, @@ -427,7 +434,7 @@ class ClnClient public cancelHoldInvoice = async (preimageHash: Buffer): Promise => { const req = new holdrpc.CancelRequest(); - req.setPaymentHash(getHexString(preimageHash)); + req.setPaymentHash(preimageHash); await this.unaryHoldCall< holdrpc.CancelRequest, @@ -437,7 +444,7 @@ class ClnClient public settleHoldInvoice = async (preimage: Buffer): Promise => { const req = new holdrpc.SettleRequest(); - req.setPaymentPreimage(getHexString(preimage)); + req.setPaymentPreimage(preimage); await this.unaryHoldCall< holdrpc.SettleRequest, @@ -614,7 +621,7 @@ class ClnClient // eslint-disable-next-line @typescript-eslint/no-unused-vars public subscribeSingleInvoice = (_: Buffer): void => { // Just here for interface compatibility; - // with CLN we can subscribe to all hold invoice with one gRPC subscription + // with CLN we can subscribe to all hold invoices with one gRPC subscription return; }; @@ -625,8 +632,8 @@ class ClnClient const routeHint = new holdrpc.RoutingHint(); for (const hint of hints) { const hopHint = new holdrpc.Hop(); - hopHint.setPublicKey(hint.nodeId); - hopHint.setShortChannelId(scidLndToCln(hint.chanId)); + hopHint.setPublicKey(getHexBuffer(hint.nodeId)); + hopHint.setShortChannelId(Number(hint.chanId)); hopHint.setBaseFee(hint.feeBaseMsat); hopHint.setPpmFee(hint.feeProportionalMillionths); hopHint.setCltvExpiryDelta(hint.cltvExpiryDelta); @@ -638,49 +645,39 @@ class ClnClient }); }; - private static routingHintsFromGrpc = ( - routingHints: holdrpc.RoutingHint.AsObject[], - ): HopHint[][] => { - return routingHints.map((hint) => - hint.hopsList.map((hop) => ({ - nodeId: hop.publicKey, - chanId: hop.shortChannelId, - feeBaseMsat: hop.baseFee, - feeProportionalMillionths: hop.ppmFee, - cltvExpiryDelta: hop.cltvExpiryDelta, - })), - ); - }; - private static invoiceStateFromGrpc = ( state: holdrpc.InvoiceState, ): InvoiceState => { switch (state) { - case holdrpc.InvoiceState.INVOICE_UNPAID: + case holdrpc.InvoiceState.UNPAID: return InvoiceState.Open; - case holdrpc.InvoiceState.INVOICE_ACCEPTED: + case holdrpc.InvoiceState.ACCEPTED: return InvoiceState.Accepted; - case holdrpc.InvoiceState.INVOICE_CANCELLED: + case holdrpc.InvoiceState.CANCELLED: return InvoiceState.Cancelled; - case holdrpc.InvoiceState.INVOICE_PAID: + case holdrpc.InvoiceState.PAID: return InvoiceState.Settled; } }; private static htlcFromGrpc = (htlc: holdrpc.Htlc.AsObject): Htlc => { return { - state: ClnClient.htlcStateFromGrpc(htlc.state), valueMsat: htlc.msat, + state: ClnClient.htlcStateFromGrpc(htlc.state), }; }; - private static htlcStateFromGrpc = (state: holdrpc.HtlcState): HtlcState => { + private static htlcStateFromGrpc = ( + state: holdrpc.InvoiceState, + ): HtlcState => { switch (state) { - case holdrpc.HtlcState.HTLC_ACCEPTED: + case holdrpc.InvoiceState.UNPAID: + throw 'invalid HTLC state'; + case holdrpc.InvoiceState.ACCEPTED: return HtlcState.Accepted; - case holdrpc.HtlcState.HTLC_CANCELLED: + case holdrpc.InvoiceState.CANCELLED: return HtlcState.Cancelled; - case holdrpc.HtlcState.HTLC_SETTLED: + case holdrpc.InvoiceState.PAID: return HtlcState.Settled; } }; @@ -721,25 +718,6 @@ class ClnClient }; } - // ... has failed - // TODO: mpay incorrect payment details detection - for (const payStatus of (await this.payStatus(invoice)).statusList) { - for (const attempt of payStatus.attemptsList) { - if ( - attempt.state === - holdrpc.PayStatusResponse.PayStatus.Attempt.AttemptState - .ATTEMPT_PENDING || - attempt.failure === undefined - ) { - continue; - } - - if (ClnClient.errIsIncorrectPaymentDetails(attempt.failure.message)) { - throw attempt.failure.message; - } - } - } - // ... or is still pending const hasPendingPayments = pays.some( (pay) => pay.getStatus() === ListpaysPaysStatus.PENDING, @@ -771,44 +749,13 @@ class ClnClient return undefined; }; - private payStatus = (invoice: string) => { - const req = new holdrpc.PayStatusRequest(); - req.setBolt11(invoice); - - return this.unaryHoldCall< - holdrpc.PayStatusRequest, - holdrpc.PayStatusResponse.AsObject - >('payStatus', req); - }; - private queryRoute = async ( - destination: string, - amt: number, - cltvLimit?: number, - finalCltvDelta?: number, + _destination: string, + _amt: number, + _cltvLimit?: number, + _finalCltvDelta?: number, ): Promise => { - const req = new holdrpc.GetRouteRequest(); - req.setDestination(destination); - req.setRiskFactor(0); - req.setAmountMsat(amt); - - if (cltvLimit) { - req.setMaxCltv(cltvLimit); - } - - if (finalCltvDelta) { - req.setFinalCltvDelta(finalCltvDelta); - } - - const res = await this.unaryHoldCall< - holdrpc.GetRouteRequest, - holdrpc.GetRouteResponse.AsObject - >('getRoute', req); - - return { - ctlv: res.hopsList[0].delay, - feesMsat: res.feesMsat, - }; + throw 'not implemented'; }; private subscribeTrackHoldInvoices = () => { @@ -822,7 +769,7 @@ class ClnClient this.trackAllSubscription.on('data', (update: holdrpc.TrackAllResponse) => { switch (update.getState()) { - case holdrpc.InvoiceState.INVOICE_ACCEPTED: + case holdrpc.InvoiceState.ACCEPTED: this.logger.debug( `${ClnClient.serviceName} ${ this.symbol @@ -832,7 +779,7 @@ class ClnClient this.emit('htlc.accepted', update.getBolt11()); break; - case holdrpc.InvoiceState.INVOICE_PAID: + case holdrpc.InvoiceState.PAID: this.logger.debug( `${ClnClient.serviceName} ${ this.symbol diff --git a/lib/proto/hold/hold_grpc_pb.d.ts b/lib/proto/hold/hold_grpc_pb.d.ts index 47dc6d02..6c361080 100644 --- a/lib/proto/hold/hold_grpc_pb.d.ts +++ b/lib/proto/hold/hold_grpc_pb.d.ts @@ -1,190 +1,139 @@ // package: hold -// file: hold.proto +// file: hold/hold.proto /* tslint:disable */ /* eslint-disable */ import * as grpc from "@grpc/grpc-js"; -import * as hold_pb from "./hold_pb"; +import * as hold_hold_pb from "../hold/hold_pb"; interface IHoldService extends grpc.ServiceDefinition { getInfo: IHoldService_IGetInfo; invoice: IHoldService_IInvoice; - routingHints: IHoldService_IRoutingHints; list: IHoldService_IList; settle: IHoldService_ISettle; cancel: IHoldService_ICancel; track: IHoldService_ITrack; trackAll: IHoldService_ITrackAll; - payStatus: IHoldService_IPayStatus; - getRoute: IHoldService_IGetRoute; } -interface IHoldService_IGetInfo extends grpc.MethodDefinition { +interface IHoldService_IGetInfo extends grpc.MethodDefinition { path: "/hold.Hold/GetInfo"; requestStream: false; responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; } -interface IHoldService_IInvoice extends grpc.MethodDefinition { +interface IHoldService_IInvoice extends grpc.MethodDefinition { path: "/hold.Hold/Invoice"; requestStream: false; responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; } -interface IHoldService_IRoutingHints extends grpc.MethodDefinition { - path: "/hold.Hold/RoutingHints"; - requestStream: false; - responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} -interface IHoldService_IList extends grpc.MethodDefinition { +interface IHoldService_IList extends grpc.MethodDefinition { path: "/hold.Hold/List"; requestStream: false; responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; } -interface IHoldService_ISettle extends grpc.MethodDefinition { +interface IHoldService_ISettle extends grpc.MethodDefinition { path: "/hold.Hold/Settle"; requestStream: false; responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; } -interface IHoldService_ICancel extends grpc.MethodDefinition { +interface IHoldService_ICancel extends grpc.MethodDefinition { path: "/hold.Hold/Cancel"; requestStream: false; responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; } -interface IHoldService_ITrack extends grpc.MethodDefinition { +interface IHoldService_ITrack extends grpc.MethodDefinition { path: "/hold.Hold/Track"; requestStream: false; responseStream: true; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; } -interface IHoldService_ITrackAll extends grpc.MethodDefinition { +interface IHoldService_ITrackAll extends grpc.MethodDefinition { path: "/hold.Hold/TrackAll"; requestStream: false; responseStream: true; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} -interface IHoldService_IPayStatus extends grpc.MethodDefinition { - path: "/hold.Hold/PayStatus"; - requestStream: false; - responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} -interface IHoldService_IGetRoute extends grpc.MethodDefinition { - path: "/hold.Hold/GetRoute"; - requestStream: false; - responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; } export const HoldService: IHoldService; export interface IHoldServer extends grpc.UntypedServiceImplementation { - getInfo: grpc.handleUnaryCall; - invoice: grpc.handleUnaryCall; - routingHints: grpc.handleUnaryCall; - list: grpc.handleUnaryCall; - settle: grpc.handleUnaryCall; - cancel: grpc.handleUnaryCall; - track: grpc.handleServerStreamingCall; - trackAll: grpc.handleServerStreamingCall; - payStatus: grpc.handleUnaryCall; - getRoute: grpc.handleUnaryCall; + getInfo: grpc.handleUnaryCall; + invoice: grpc.handleUnaryCall; + list: grpc.handleUnaryCall; + settle: grpc.handleUnaryCall; + cancel: grpc.handleUnaryCall; + track: grpc.handleServerStreamingCall; + trackAll: grpc.handleServerStreamingCall; } export interface IHoldClient { - getInfo(request: hold_pb.GetInfoRequest, callback: (error: grpc.ServiceError | null, response: hold_pb.GetInfoResponse) => void): grpc.ClientUnaryCall; - getInfo(request: hold_pb.GetInfoRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_pb.GetInfoResponse) => void): grpc.ClientUnaryCall; - getInfo(request: hold_pb.GetInfoRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_pb.GetInfoResponse) => void): grpc.ClientUnaryCall; - invoice(request: hold_pb.InvoiceRequest, callback: (error: grpc.ServiceError | null, response: hold_pb.InvoiceResponse) => void): grpc.ClientUnaryCall; - invoice(request: hold_pb.InvoiceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_pb.InvoiceResponse) => void): grpc.ClientUnaryCall; - invoice(request: hold_pb.InvoiceRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_pb.InvoiceResponse) => void): grpc.ClientUnaryCall; - routingHints(request: hold_pb.RoutingHintsRequest, callback: (error: grpc.ServiceError | null, response: hold_pb.RoutingHintsResponse) => void): grpc.ClientUnaryCall; - routingHints(request: hold_pb.RoutingHintsRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_pb.RoutingHintsResponse) => void): grpc.ClientUnaryCall; - routingHints(request: hold_pb.RoutingHintsRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_pb.RoutingHintsResponse) => void): grpc.ClientUnaryCall; - list(request: hold_pb.ListRequest, callback: (error: grpc.ServiceError | null, response: hold_pb.ListResponse) => void): grpc.ClientUnaryCall; - list(request: hold_pb.ListRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_pb.ListResponse) => void): grpc.ClientUnaryCall; - list(request: hold_pb.ListRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_pb.ListResponse) => void): grpc.ClientUnaryCall; - settle(request: hold_pb.SettleRequest, callback: (error: grpc.ServiceError | null, response: hold_pb.SettleResponse) => void): grpc.ClientUnaryCall; - settle(request: hold_pb.SettleRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_pb.SettleResponse) => void): grpc.ClientUnaryCall; - settle(request: hold_pb.SettleRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_pb.SettleResponse) => void): grpc.ClientUnaryCall; - cancel(request: hold_pb.CancelRequest, callback: (error: grpc.ServiceError | null, response: hold_pb.CancelResponse) => void): grpc.ClientUnaryCall; - cancel(request: hold_pb.CancelRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_pb.CancelResponse) => void): grpc.ClientUnaryCall; - cancel(request: hold_pb.CancelRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_pb.CancelResponse) => void): grpc.ClientUnaryCall; - track(request: hold_pb.TrackRequest, options?: Partial): grpc.ClientReadableStream; - track(request: hold_pb.TrackRequest, metadata?: grpc.Metadata, options?: Partial): grpc.ClientReadableStream; - trackAll(request: hold_pb.TrackAllRequest, options?: Partial): grpc.ClientReadableStream; - trackAll(request: hold_pb.TrackAllRequest, metadata?: grpc.Metadata, options?: Partial): grpc.ClientReadableStream; - payStatus(request: hold_pb.PayStatusRequest, callback: (error: grpc.ServiceError | null, response: hold_pb.PayStatusResponse) => void): grpc.ClientUnaryCall; - payStatus(request: hold_pb.PayStatusRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_pb.PayStatusResponse) => void): grpc.ClientUnaryCall; - payStatus(request: hold_pb.PayStatusRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_pb.PayStatusResponse) => void): grpc.ClientUnaryCall; - getRoute(request: hold_pb.GetRouteRequest, callback: (error: grpc.ServiceError | null, response: hold_pb.GetRouteResponse) => void): grpc.ClientUnaryCall; - getRoute(request: hold_pb.GetRouteRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_pb.GetRouteResponse) => void): grpc.ClientUnaryCall; - getRoute(request: hold_pb.GetRouteRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_pb.GetRouteResponse) => void): grpc.ClientUnaryCall; + getInfo(request: hold_hold_pb.GetInfoRequest, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.GetInfoResponse) => void): grpc.ClientUnaryCall; + getInfo(request: hold_hold_pb.GetInfoRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.GetInfoResponse) => void): grpc.ClientUnaryCall; + getInfo(request: hold_hold_pb.GetInfoRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.GetInfoResponse) => void): grpc.ClientUnaryCall; + invoice(request: hold_hold_pb.InvoiceRequest, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.InvoiceResponse) => void): grpc.ClientUnaryCall; + invoice(request: hold_hold_pb.InvoiceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.InvoiceResponse) => void): grpc.ClientUnaryCall; + invoice(request: hold_hold_pb.InvoiceRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.InvoiceResponse) => void): grpc.ClientUnaryCall; + list(request: hold_hold_pb.ListRequest, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.ListResponse) => void): grpc.ClientUnaryCall; + list(request: hold_hold_pb.ListRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.ListResponse) => void): grpc.ClientUnaryCall; + list(request: hold_hold_pb.ListRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.ListResponse) => void): grpc.ClientUnaryCall; + settle(request: hold_hold_pb.SettleRequest, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.SettleResponse) => void): grpc.ClientUnaryCall; + settle(request: hold_hold_pb.SettleRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.SettleResponse) => void): grpc.ClientUnaryCall; + settle(request: hold_hold_pb.SettleRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.SettleResponse) => void): grpc.ClientUnaryCall; + cancel(request: hold_hold_pb.CancelRequest, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.CancelResponse) => void): grpc.ClientUnaryCall; + cancel(request: hold_hold_pb.CancelRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.CancelResponse) => void): grpc.ClientUnaryCall; + cancel(request: hold_hold_pb.CancelRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.CancelResponse) => void): grpc.ClientUnaryCall; + track(request: hold_hold_pb.TrackRequest, options?: Partial): grpc.ClientReadableStream; + track(request: hold_hold_pb.TrackRequest, metadata?: grpc.Metadata, options?: Partial): grpc.ClientReadableStream; + trackAll(request: hold_hold_pb.TrackAllRequest, options?: Partial): grpc.ClientReadableStream; + trackAll(request: hold_hold_pb.TrackAllRequest, metadata?: grpc.Metadata, options?: Partial): grpc.ClientReadableStream; } export class HoldClient extends grpc.Client implements IHoldClient { constructor(address: string, credentials: grpc.ChannelCredentials, options?: Partial); - public getInfo(request: hold_pb.GetInfoRequest, callback: (error: grpc.ServiceError | null, response: hold_pb.GetInfoResponse) => void): grpc.ClientUnaryCall; - public getInfo(request: hold_pb.GetInfoRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_pb.GetInfoResponse) => void): grpc.ClientUnaryCall; - public getInfo(request: hold_pb.GetInfoRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_pb.GetInfoResponse) => void): grpc.ClientUnaryCall; - public invoice(request: hold_pb.InvoiceRequest, callback: (error: grpc.ServiceError | null, response: hold_pb.InvoiceResponse) => void): grpc.ClientUnaryCall; - public invoice(request: hold_pb.InvoiceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_pb.InvoiceResponse) => void): grpc.ClientUnaryCall; - public invoice(request: hold_pb.InvoiceRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_pb.InvoiceResponse) => void): grpc.ClientUnaryCall; - public routingHints(request: hold_pb.RoutingHintsRequest, callback: (error: grpc.ServiceError | null, response: hold_pb.RoutingHintsResponse) => void): grpc.ClientUnaryCall; - public routingHints(request: hold_pb.RoutingHintsRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_pb.RoutingHintsResponse) => void): grpc.ClientUnaryCall; - public routingHints(request: hold_pb.RoutingHintsRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_pb.RoutingHintsResponse) => void): grpc.ClientUnaryCall; - public list(request: hold_pb.ListRequest, callback: (error: grpc.ServiceError | null, response: hold_pb.ListResponse) => void): grpc.ClientUnaryCall; - public list(request: hold_pb.ListRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_pb.ListResponse) => void): grpc.ClientUnaryCall; - public list(request: hold_pb.ListRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_pb.ListResponse) => void): grpc.ClientUnaryCall; - public settle(request: hold_pb.SettleRequest, callback: (error: grpc.ServiceError | null, response: hold_pb.SettleResponse) => void): grpc.ClientUnaryCall; - public settle(request: hold_pb.SettleRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_pb.SettleResponse) => void): grpc.ClientUnaryCall; - public settle(request: hold_pb.SettleRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_pb.SettleResponse) => void): grpc.ClientUnaryCall; - public cancel(request: hold_pb.CancelRequest, callback: (error: grpc.ServiceError | null, response: hold_pb.CancelResponse) => void): grpc.ClientUnaryCall; - public cancel(request: hold_pb.CancelRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_pb.CancelResponse) => void): grpc.ClientUnaryCall; - public cancel(request: hold_pb.CancelRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_pb.CancelResponse) => void): grpc.ClientUnaryCall; - public track(request: hold_pb.TrackRequest, options?: Partial): grpc.ClientReadableStream; - public track(request: hold_pb.TrackRequest, metadata?: grpc.Metadata, options?: Partial): grpc.ClientReadableStream; - public trackAll(request: hold_pb.TrackAllRequest, options?: Partial): grpc.ClientReadableStream; - public trackAll(request: hold_pb.TrackAllRequest, metadata?: grpc.Metadata, options?: Partial): grpc.ClientReadableStream; - public payStatus(request: hold_pb.PayStatusRequest, callback: (error: grpc.ServiceError | null, response: hold_pb.PayStatusResponse) => void): grpc.ClientUnaryCall; - public payStatus(request: hold_pb.PayStatusRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_pb.PayStatusResponse) => void): grpc.ClientUnaryCall; - public payStatus(request: hold_pb.PayStatusRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_pb.PayStatusResponse) => void): grpc.ClientUnaryCall; - public getRoute(request: hold_pb.GetRouteRequest, callback: (error: grpc.ServiceError | null, response: hold_pb.GetRouteResponse) => void): grpc.ClientUnaryCall; - public getRoute(request: hold_pb.GetRouteRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_pb.GetRouteResponse) => void): grpc.ClientUnaryCall; - public getRoute(request: hold_pb.GetRouteRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_pb.GetRouteResponse) => void): grpc.ClientUnaryCall; + public getInfo(request: hold_hold_pb.GetInfoRequest, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.GetInfoResponse) => void): grpc.ClientUnaryCall; + public getInfo(request: hold_hold_pb.GetInfoRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.GetInfoResponse) => void): grpc.ClientUnaryCall; + public getInfo(request: hold_hold_pb.GetInfoRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.GetInfoResponse) => void): grpc.ClientUnaryCall; + public invoice(request: hold_hold_pb.InvoiceRequest, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.InvoiceResponse) => void): grpc.ClientUnaryCall; + public invoice(request: hold_hold_pb.InvoiceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.InvoiceResponse) => void): grpc.ClientUnaryCall; + public invoice(request: hold_hold_pb.InvoiceRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.InvoiceResponse) => void): grpc.ClientUnaryCall; + public list(request: hold_hold_pb.ListRequest, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.ListResponse) => void): grpc.ClientUnaryCall; + public list(request: hold_hold_pb.ListRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.ListResponse) => void): grpc.ClientUnaryCall; + public list(request: hold_hold_pb.ListRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.ListResponse) => void): grpc.ClientUnaryCall; + public settle(request: hold_hold_pb.SettleRequest, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.SettleResponse) => void): grpc.ClientUnaryCall; + public settle(request: hold_hold_pb.SettleRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.SettleResponse) => void): grpc.ClientUnaryCall; + public settle(request: hold_hold_pb.SettleRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.SettleResponse) => void): grpc.ClientUnaryCall; + public cancel(request: hold_hold_pb.CancelRequest, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.CancelResponse) => void): grpc.ClientUnaryCall; + public cancel(request: hold_hold_pb.CancelRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.CancelResponse) => void): grpc.ClientUnaryCall; + public cancel(request: hold_hold_pb.CancelRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: hold_hold_pb.CancelResponse) => void): grpc.ClientUnaryCall; + public track(request: hold_hold_pb.TrackRequest, options?: Partial): grpc.ClientReadableStream; + public track(request: hold_hold_pb.TrackRequest, metadata?: grpc.Metadata, options?: Partial): grpc.ClientReadableStream; + public trackAll(request: hold_hold_pb.TrackAllRequest, options?: Partial): grpc.ClientReadableStream; + public trackAll(request: hold_hold_pb.TrackAllRequest, metadata?: grpc.Metadata, options?: Partial): grpc.ClientReadableStream; } diff --git a/lib/proto/hold/hold_grpc_pb.js b/lib/proto/hold/hold_grpc_pb.js index d892a51a..6d1ece42 100644 --- a/lib/proto/hold/hold_grpc_pb.js +++ b/lib/proto/hold/hold_grpc_pb.js @@ -2,226 +2,160 @@ 'use strict'; var grpc = require('@grpc/grpc-js'); -var hold_pb = require('./hold_pb.js'); +var hold_hold_pb = require('../hold/hold_pb.js'); function serialize_hold_CancelRequest(arg) { - if (!(arg instanceof hold_pb.CancelRequest)) { + if (!(arg instanceof hold_hold_pb.CancelRequest)) { throw new Error('Expected argument of type hold.CancelRequest'); } return Buffer.from(arg.serializeBinary()); } function deserialize_hold_CancelRequest(buffer_arg) { - return hold_pb.CancelRequest.deserializeBinary(new Uint8Array(buffer_arg)); + return hold_hold_pb.CancelRequest.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_hold_CancelResponse(arg) { - if (!(arg instanceof hold_pb.CancelResponse)) { + if (!(arg instanceof hold_hold_pb.CancelResponse)) { throw new Error('Expected argument of type hold.CancelResponse'); } return Buffer.from(arg.serializeBinary()); } function deserialize_hold_CancelResponse(buffer_arg) { - return hold_pb.CancelResponse.deserializeBinary(new Uint8Array(buffer_arg)); + return hold_hold_pb.CancelResponse.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_hold_GetInfoRequest(arg) { - if (!(arg instanceof hold_pb.GetInfoRequest)) { + if (!(arg instanceof hold_hold_pb.GetInfoRequest)) { throw new Error('Expected argument of type hold.GetInfoRequest'); } return Buffer.from(arg.serializeBinary()); } function deserialize_hold_GetInfoRequest(buffer_arg) { - return hold_pb.GetInfoRequest.deserializeBinary(new Uint8Array(buffer_arg)); + return hold_hold_pb.GetInfoRequest.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_hold_GetInfoResponse(arg) { - if (!(arg instanceof hold_pb.GetInfoResponse)) { + if (!(arg instanceof hold_hold_pb.GetInfoResponse)) { throw new Error('Expected argument of type hold.GetInfoResponse'); } return Buffer.from(arg.serializeBinary()); } function deserialize_hold_GetInfoResponse(buffer_arg) { - return hold_pb.GetInfoResponse.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_hold_GetRouteRequest(arg) { - if (!(arg instanceof hold_pb.GetRouteRequest)) { - throw new Error('Expected argument of type hold.GetRouteRequest'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_hold_GetRouteRequest(buffer_arg) { - return hold_pb.GetRouteRequest.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_hold_GetRouteResponse(arg) { - if (!(arg instanceof hold_pb.GetRouteResponse)) { - throw new Error('Expected argument of type hold.GetRouteResponse'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_hold_GetRouteResponse(buffer_arg) { - return hold_pb.GetRouteResponse.deserializeBinary(new Uint8Array(buffer_arg)); + return hold_hold_pb.GetInfoResponse.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_hold_InvoiceRequest(arg) { - if (!(arg instanceof hold_pb.InvoiceRequest)) { + if (!(arg instanceof hold_hold_pb.InvoiceRequest)) { throw new Error('Expected argument of type hold.InvoiceRequest'); } return Buffer.from(arg.serializeBinary()); } function deserialize_hold_InvoiceRequest(buffer_arg) { - return hold_pb.InvoiceRequest.deserializeBinary(new Uint8Array(buffer_arg)); + return hold_hold_pb.InvoiceRequest.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_hold_InvoiceResponse(arg) { - if (!(arg instanceof hold_pb.InvoiceResponse)) { + if (!(arg instanceof hold_hold_pb.InvoiceResponse)) { throw new Error('Expected argument of type hold.InvoiceResponse'); } return Buffer.from(arg.serializeBinary()); } function deserialize_hold_InvoiceResponse(buffer_arg) { - return hold_pb.InvoiceResponse.deserializeBinary(new Uint8Array(buffer_arg)); + return hold_hold_pb.InvoiceResponse.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_hold_ListRequest(arg) { - if (!(arg instanceof hold_pb.ListRequest)) { + if (!(arg instanceof hold_hold_pb.ListRequest)) { throw new Error('Expected argument of type hold.ListRequest'); } return Buffer.from(arg.serializeBinary()); } function deserialize_hold_ListRequest(buffer_arg) { - return hold_pb.ListRequest.deserializeBinary(new Uint8Array(buffer_arg)); + return hold_hold_pb.ListRequest.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_hold_ListResponse(arg) { - if (!(arg instanceof hold_pb.ListResponse)) { + if (!(arg instanceof hold_hold_pb.ListResponse)) { throw new Error('Expected argument of type hold.ListResponse'); } return Buffer.from(arg.serializeBinary()); } function deserialize_hold_ListResponse(buffer_arg) { - return hold_pb.ListResponse.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_hold_PayStatusRequest(arg) { - if (!(arg instanceof hold_pb.PayStatusRequest)) { - throw new Error('Expected argument of type hold.PayStatusRequest'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_hold_PayStatusRequest(buffer_arg) { - return hold_pb.PayStatusRequest.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_hold_PayStatusResponse(arg) { - if (!(arg instanceof hold_pb.PayStatusResponse)) { - throw new Error('Expected argument of type hold.PayStatusResponse'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_hold_PayStatusResponse(buffer_arg) { - return hold_pb.PayStatusResponse.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_hold_RoutingHintsRequest(arg) { - if (!(arg instanceof hold_pb.RoutingHintsRequest)) { - throw new Error('Expected argument of type hold.RoutingHintsRequest'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_hold_RoutingHintsRequest(buffer_arg) { - return hold_pb.RoutingHintsRequest.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_hold_RoutingHintsResponse(arg) { - if (!(arg instanceof hold_pb.RoutingHintsResponse)) { - throw new Error('Expected argument of type hold.RoutingHintsResponse'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_hold_RoutingHintsResponse(buffer_arg) { - return hold_pb.RoutingHintsResponse.deserializeBinary(new Uint8Array(buffer_arg)); + return hold_hold_pb.ListResponse.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_hold_SettleRequest(arg) { - if (!(arg instanceof hold_pb.SettleRequest)) { + if (!(arg instanceof hold_hold_pb.SettleRequest)) { throw new Error('Expected argument of type hold.SettleRequest'); } return Buffer.from(arg.serializeBinary()); } function deserialize_hold_SettleRequest(buffer_arg) { - return hold_pb.SettleRequest.deserializeBinary(new Uint8Array(buffer_arg)); + return hold_hold_pb.SettleRequest.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_hold_SettleResponse(arg) { - if (!(arg instanceof hold_pb.SettleResponse)) { + if (!(arg instanceof hold_hold_pb.SettleResponse)) { throw new Error('Expected argument of type hold.SettleResponse'); } return Buffer.from(arg.serializeBinary()); } function deserialize_hold_SettleResponse(buffer_arg) { - return hold_pb.SettleResponse.deserializeBinary(new Uint8Array(buffer_arg)); + return hold_hold_pb.SettleResponse.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_hold_TrackAllRequest(arg) { - if (!(arg instanceof hold_pb.TrackAllRequest)) { + if (!(arg instanceof hold_hold_pb.TrackAllRequest)) { throw new Error('Expected argument of type hold.TrackAllRequest'); } return Buffer.from(arg.serializeBinary()); } function deserialize_hold_TrackAllRequest(buffer_arg) { - return hold_pb.TrackAllRequest.deserializeBinary(new Uint8Array(buffer_arg)); + return hold_hold_pb.TrackAllRequest.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_hold_TrackAllResponse(arg) { - if (!(arg instanceof hold_pb.TrackAllResponse)) { + if (!(arg instanceof hold_hold_pb.TrackAllResponse)) { throw new Error('Expected argument of type hold.TrackAllResponse'); } return Buffer.from(arg.serializeBinary()); } function deserialize_hold_TrackAllResponse(buffer_arg) { - return hold_pb.TrackAllResponse.deserializeBinary(new Uint8Array(buffer_arg)); + return hold_hold_pb.TrackAllResponse.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_hold_TrackRequest(arg) { - if (!(arg instanceof hold_pb.TrackRequest)) { + if (!(arg instanceof hold_hold_pb.TrackRequest)) { throw new Error('Expected argument of type hold.TrackRequest'); } return Buffer.from(arg.serializeBinary()); } function deserialize_hold_TrackRequest(buffer_arg) { - return hold_pb.TrackRequest.deserializeBinary(new Uint8Array(buffer_arg)); + return hold_hold_pb.TrackRequest.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_hold_TrackResponse(arg) { - if (!(arg instanceof hold_pb.TrackResponse)) { + if (!(arg instanceof hold_hold_pb.TrackResponse)) { throw new Error('Expected argument of type hold.TrackResponse'); } return Buffer.from(arg.serializeBinary()); } function deserialize_hold_TrackResponse(buffer_arg) { - return hold_pb.TrackResponse.deserializeBinary(new Uint8Array(buffer_arg)); + return hold_hold_pb.TrackResponse.deserializeBinary(new Uint8Array(buffer_arg)); } @@ -230,8 +164,8 @@ var HoldService = exports.HoldService = { path: '/hold.Hold/GetInfo', requestStream: false, responseStream: false, - requestType: hold_pb.GetInfoRequest, - responseType: hold_pb.GetInfoResponse, + requestType: hold_hold_pb.GetInfoRequest, + responseType: hold_hold_pb.GetInfoResponse, requestSerialize: serialize_hold_GetInfoRequest, requestDeserialize: deserialize_hold_GetInfoRequest, responseSerialize: serialize_hold_GetInfoResponse, @@ -241,30 +175,19 @@ var HoldService = exports.HoldService = { path: '/hold.Hold/Invoice', requestStream: false, responseStream: false, - requestType: hold_pb.InvoiceRequest, - responseType: hold_pb.InvoiceResponse, + requestType: hold_hold_pb.InvoiceRequest, + responseType: hold_hold_pb.InvoiceResponse, requestSerialize: serialize_hold_InvoiceRequest, requestDeserialize: deserialize_hold_InvoiceRequest, responseSerialize: serialize_hold_InvoiceResponse, responseDeserialize: deserialize_hold_InvoiceResponse, }, - routingHints: { - path: '/hold.Hold/RoutingHints', - requestStream: false, - responseStream: false, - requestType: hold_pb.RoutingHintsRequest, - responseType: hold_pb.RoutingHintsResponse, - requestSerialize: serialize_hold_RoutingHintsRequest, - requestDeserialize: deserialize_hold_RoutingHintsRequest, - responseSerialize: serialize_hold_RoutingHintsResponse, - responseDeserialize: deserialize_hold_RoutingHintsResponse, - }, list: { path: '/hold.Hold/List', requestStream: false, responseStream: false, - requestType: hold_pb.ListRequest, - responseType: hold_pb.ListResponse, + requestType: hold_hold_pb.ListRequest, + responseType: hold_hold_pb.ListResponse, requestSerialize: serialize_hold_ListRequest, requestDeserialize: deserialize_hold_ListRequest, responseSerialize: serialize_hold_ListResponse, @@ -274,8 +197,8 @@ var HoldService = exports.HoldService = { path: '/hold.Hold/Settle', requestStream: false, responseStream: false, - requestType: hold_pb.SettleRequest, - responseType: hold_pb.SettleResponse, + requestType: hold_hold_pb.SettleRequest, + responseType: hold_hold_pb.SettleResponse, requestSerialize: serialize_hold_SettleRequest, requestDeserialize: deserialize_hold_SettleRequest, responseSerialize: serialize_hold_SettleResponse, @@ -285,8 +208,8 @@ var HoldService = exports.HoldService = { path: '/hold.Hold/Cancel', requestStream: false, responseStream: false, - requestType: hold_pb.CancelRequest, - responseType: hold_pb.CancelResponse, + requestType: hold_hold_pb.CancelRequest, + responseType: hold_hold_pb.CancelResponse, requestSerialize: serialize_hold_CancelRequest, requestDeserialize: deserialize_hold_CancelRequest, responseSerialize: serialize_hold_CancelResponse, @@ -296,8 +219,8 @@ var HoldService = exports.HoldService = { path: '/hold.Hold/Track', requestStream: false, responseStream: true, - requestType: hold_pb.TrackRequest, - responseType: hold_pb.TrackResponse, + requestType: hold_hold_pb.TrackRequest, + responseType: hold_hold_pb.TrackResponse, requestSerialize: serialize_hold_TrackRequest, requestDeserialize: deserialize_hold_TrackRequest, responseSerialize: serialize_hold_TrackResponse, @@ -307,37 +230,13 @@ var HoldService = exports.HoldService = { path: '/hold.Hold/TrackAll', requestStream: false, responseStream: true, - requestType: hold_pb.TrackAllRequest, - responseType: hold_pb.TrackAllResponse, + requestType: hold_hold_pb.TrackAllRequest, + responseType: hold_hold_pb.TrackAllResponse, requestSerialize: serialize_hold_TrackAllRequest, requestDeserialize: deserialize_hold_TrackAllRequest, responseSerialize: serialize_hold_TrackAllResponse, responseDeserialize: deserialize_hold_TrackAllResponse, }, - // Workaround to expose the paystatus command via gRPC, since CLN doesn't -payStatus: { - path: '/hold.Hold/PayStatus', - requestStream: false, - responseStream: false, - requestType: hold_pb.PayStatusRequest, - responseType: hold_pb.PayStatusResponse, - requestSerialize: serialize_hold_PayStatusRequest, - requestDeserialize: deserialize_hold_PayStatusRequest, - responseSerialize: serialize_hold_PayStatusResponse, - responseDeserialize: deserialize_hold_PayStatusResponse, - }, - // Custom algorithm that allows specifying a max delay -getRoute: { - path: '/hold.Hold/GetRoute', - requestStream: false, - responseStream: false, - requestType: hold_pb.GetRouteRequest, - responseType: hold_pb.GetRouteResponse, - requestSerialize: serialize_hold_GetRouteRequest, - requestDeserialize: deserialize_hold_GetRouteRequest, - responseSerialize: serialize_hold_GetRouteResponse, - responseDeserialize: deserialize_hold_GetRouteResponse, - }, }; exports.HoldClient = grpc.makeGenericClientConstructor(HoldService); diff --git a/lib/proto/hold/hold_pb.d.ts b/lib/proto/hold/hold_pb.d.ts index 7fdd561e..0008ab25 100644 --- a/lib/proto/hold/hold_pb.d.ts +++ b/lib/proto/hold/hold_pb.d.ts @@ -1,5 +1,5 @@ // package: hold -// file: hold.proto +// file: hold/hold.proto /* tslint:disable */ /* eslint-disable */ @@ -43,21 +43,81 @@ export namespace GetInfoResponse { } } +export class Hop extends jspb.Message { + getPublicKey(): Uint8Array | string; + getPublicKey_asU8(): Uint8Array; + getPublicKey_asB64(): string; + setPublicKey(value: Uint8Array | string): Hop; + getShortChannelId(): number; + setShortChannelId(value: number): Hop; + getBaseFee(): number; + setBaseFee(value: number): Hop; + getPpmFee(): number; + setPpmFee(value: number): Hop; + getCltvExpiryDelta(): number; + setCltvExpiryDelta(value: number): Hop; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): Hop.AsObject; + static toObject(includeInstance: boolean, msg: Hop): Hop.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: Hop, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): Hop; + static deserializeBinaryFromReader(message: Hop, reader: jspb.BinaryReader): Hop; +} + +export namespace Hop { + export type AsObject = { + publicKey: Uint8Array | string, + shortChannelId: number, + baseFee: number, + ppmFee: number, + cltvExpiryDelta: number, + } +} + +export class RoutingHint extends jspb.Message { + clearHopsList(): void; + getHopsList(): Array; + setHopsList(value: Array): RoutingHint; + addHops(value?: Hop, index?: number): Hop; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): RoutingHint.AsObject; + static toObject(includeInstance: boolean, msg: RoutingHint): RoutingHint.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: RoutingHint, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): RoutingHint; + static deserializeBinaryFromReader(message: RoutingHint, reader: jspb.BinaryReader): RoutingHint; +} + +export namespace RoutingHint { + export type AsObject = { + hopsList: Array, + } +} + export class InvoiceRequest extends jspb.Message { - getPaymentHash(): string; - setPaymentHash(value: string): InvoiceRequest; + getPaymentHash(): Uint8Array | string; + getPaymentHash_asU8(): Uint8Array; + getPaymentHash_asB64(): string; + setPaymentHash(value: Uint8Array | string): InvoiceRequest; getAmountMsat(): number; setAmountMsat(value: number): InvoiceRequest; - hasDescription(): boolean; - clearDescription(): void; - getDescription(): string | undefined; - setDescription(value: string): InvoiceRequest; + hasMemo(): boolean; + clearMemo(): void; + getMemo(): string; + setMemo(value: string): InvoiceRequest; - hasDescriptionHash(): boolean; - clearDescriptionHash(): void; - getDescriptionHash(): string | undefined; - setDescriptionHash(value: string): InvoiceRequest; + hasHash(): boolean; + clearHash(): void; + getHash(): Uint8Array | string; + getHash_asU8(): Uint8Array; + getHash_asB64(): string; + setHash(value: Uint8Array | string): InvoiceRequest; hasExpiry(): boolean; clearExpiry(): void; @@ -73,6 +133,8 @@ export class InvoiceRequest extends jspb.Message { setRoutingHintsList(value: Array): InvoiceRequest; addRoutingHints(value?: RoutingHint, index?: number): RoutingHint; + getDescriptionCase(): InvoiceRequest.DescriptionCase; + serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): InvoiceRequest.AsObject; static toObject(includeInstance: boolean, msg: InvoiceRequest): InvoiceRequest.AsObject; @@ -85,14 +147,21 @@ export class InvoiceRequest extends jspb.Message { export namespace InvoiceRequest { export type AsObject = { - paymentHash: string, + paymentHash: Uint8Array | string, amountMsat: number, - description?: string, - descriptionHash?: string, + memo: string, + hash: Uint8Array | string, expiry?: number, minFinalCltvExpiry?: number, routingHintsList: Array, } + + export enum DescriptionCase { + DESCRIPTION_NOT_SET = 0, + MEMO = 3, + HASH = 4, + } + } export class InvoiceResponse extends jspb.Message { @@ -115,136 +184,84 @@ export namespace InvoiceResponse { } } -export class RoutingHintsRequest extends jspb.Message { - getNode(): string; - setNode(value: string): RoutingHintsRequest; +export class ListRequest extends jspb.Message { - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): RoutingHintsRequest.AsObject; - static toObject(includeInstance: boolean, msg: RoutingHintsRequest): RoutingHintsRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: RoutingHintsRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): RoutingHintsRequest; - static deserializeBinaryFromReader(message: RoutingHintsRequest, reader: jspb.BinaryReader): RoutingHintsRequest; -} + hasPaymentHash(): boolean; + clearPaymentHash(): void; + getPaymentHash(): Uint8Array | string; + getPaymentHash_asU8(): Uint8Array; + getPaymentHash_asB64(): string; + setPaymentHash(value: Uint8Array | string): ListRequest; -export namespace RoutingHintsRequest { - export type AsObject = { - node: string, - } -} + hasPagination(): boolean; + clearPagination(): void; + getPagination(): ListRequest.Pagination | undefined; + setPagination(value?: ListRequest.Pagination): ListRequest; -export class Hop extends jspb.Message { - getPublicKey(): string; - setPublicKey(value: string): Hop; - getShortChannelId(): string; - setShortChannelId(value: string): Hop; - getBaseFee(): number; - setBaseFee(value: number): Hop; - getPpmFee(): number; - setPpmFee(value: number): Hop; - getCltvExpiryDelta(): number; - setCltvExpiryDelta(value: number): Hop; + getConstraintCase(): ListRequest.ConstraintCase; serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): Hop.AsObject; - static toObject(includeInstance: boolean, msg: Hop): Hop.AsObject; + toObject(includeInstance?: boolean): ListRequest.AsObject; + static toObject(includeInstance: boolean, msg: ListRequest): ListRequest.AsObject; static extensions: {[key: number]: jspb.ExtensionFieldInfo}; static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: Hop, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): Hop; - static deserializeBinaryFromReader(message: Hop, reader: jspb.BinaryReader): Hop; + static serializeBinaryToWriter(message: ListRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ListRequest; + static deserializeBinaryFromReader(message: ListRequest, reader: jspb.BinaryReader): ListRequest; } -export namespace Hop { +export namespace ListRequest { export type AsObject = { - publicKey: string, - shortChannelId: string, - baseFee: number, - ppmFee: number, - cltvExpiryDelta: number, + paymentHash: Uint8Array | string, + pagination?: ListRequest.Pagination.AsObject, } -} -export class RoutingHint extends jspb.Message { - clearHopsList(): void; - getHopsList(): Array; - setHopsList(value: Array): RoutingHint; - addHops(value?: Hop, index?: number): Hop; - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): RoutingHint.AsObject; - static toObject(includeInstance: boolean, msg: RoutingHint): RoutingHint.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: RoutingHint, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): RoutingHint; - static deserializeBinaryFromReader(message: RoutingHint, reader: jspb.BinaryReader): RoutingHint; -} + export class Pagination extends jspb.Message { + getIndexStart(): number; + setIndexStart(value: number): Pagination; + getLimit(): number; + setLimit(value: number): Pagination; -export namespace RoutingHint { - export type AsObject = { - hopsList: Array, + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): Pagination.AsObject; + static toObject(includeInstance: boolean, msg: Pagination): Pagination.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: Pagination, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): Pagination; + static deserializeBinaryFromReader(message: Pagination, reader: jspb.BinaryReader): Pagination; } -} - -export class RoutingHintsResponse extends jspb.Message { - clearHintsList(): void; - getHintsList(): Array; - setHintsList(value: Array): RoutingHintsResponse; - addHints(value?: RoutingHint, index?: number): RoutingHint; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): RoutingHintsResponse.AsObject; - static toObject(includeInstance: boolean, msg: RoutingHintsResponse): RoutingHintsResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: RoutingHintsResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): RoutingHintsResponse; - static deserializeBinaryFromReader(message: RoutingHintsResponse, reader: jspb.BinaryReader): RoutingHintsResponse; -} -export namespace RoutingHintsResponse { - export type AsObject = { - hintsList: Array, + export namespace Pagination { + export type AsObject = { + indexStart: number, + limit: number, + } } -} -export class ListRequest extends jspb.Message { - - hasPaymentHash(): boolean; - clearPaymentHash(): void; - getPaymentHash(): string | undefined; - setPaymentHash(value: string): ListRequest; - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): ListRequest.AsObject; - static toObject(includeInstance: boolean, msg: ListRequest): ListRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: ListRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): ListRequest; - static deserializeBinaryFromReader(message: ListRequest, reader: jspb.BinaryReader): ListRequest; -} - -export namespace ListRequest { - export type AsObject = { - paymentHash?: string, + export enum ConstraintCase { + CONSTRAINT_NOT_SET = 0, + PAYMENT_HASH = 1, + PAGINATION = 2, } + } export class Htlc extends jspb.Message { - getState(): HtlcState; - setState(value: HtlcState): Htlc; + getId(): number; + setId(value: number): Htlc; + getState(): InvoiceState; + setState(value: InvoiceState): Htlc; + getScid(): string; + setScid(value: string): Htlc; + getChannelId(): number; + setChannelId(value: number): Htlc; getMsat(): number; setMsat(value: number): Htlc; getCreatedAt(): number; setCreatedAt(value: number): Htlc; - getShortChannelId(): string; - setShortChannelId(value: string): Htlc; - getId(): number; - setId(value: number): Htlc; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Htlc.AsObject; @@ -258,34 +275,39 @@ export class Htlc extends jspb.Message { export namespace Htlc { export type AsObject = { - state: HtlcState, + id: number, + state: InvoiceState, + scid: string, + channelId: number, msat: number, createdAt: number, - shortChannelId: string, - id: number, } } export class Invoice extends jspb.Message { - getPaymentHash(): string; - setPaymentHash(value: string): Invoice; - - hasPaymentPreimage(): boolean; - clearPaymentPreimage(): void; - getPaymentPreimage(): string | undefined; - setPaymentPreimage(value: string): Invoice; - getState(): InvoiceState; - setState(value: InvoiceState): Invoice; + getId(): number; + setId(value: number): Invoice; + getPaymentHash(): Uint8Array | string; + getPaymentHash_asU8(): Uint8Array; + getPaymentHash_asB64(): string; + setPaymentHash(value: Uint8Array | string): Invoice; + + hasPreimage(): boolean; + clearPreimage(): void; + getPreimage(): Uint8Array | string; + getPreimage_asU8(): Uint8Array; + getPreimage_asB64(): string; + setPreimage(value: Uint8Array | string): Invoice; getBolt11(): string; setBolt11(value: string): Invoice; + getState(): InvoiceState; + setState(value: InvoiceState): Invoice; getCreatedAt(): number; setCreatedAt(value: number): Invoice; clearHtlcsList(): void; getHtlcsList(): Array; setHtlcsList(value: Array): Invoice; addHtlcs(value?: Htlc, index?: number): Htlc; - getAmountMsat(): number; - setAmountMsat(value: number): Invoice; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): Invoice.AsObject; @@ -299,13 +321,13 @@ export class Invoice extends jspb.Message { export namespace Invoice { export type AsObject = { - paymentHash: string, - paymentPreimage?: string, - state: InvoiceState, + id: number, + paymentHash: Uint8Array | string, + preimage: Uint8Array | string, bolt11: string, + state: InvoiceState, createdAt: number, htlcsList: Array, - amountMsat: number, } } @@ -332,8 +354,10 @@ export namespace ListResponse { } export class SettleRequest extends jspb.Message { - getPaymentPreimage(): string; - setPaymentPreimage(value: string): SettleRequest; + getPaymentPreimage(): Uint8Array | string; + getPaymentPreimage_asU8(): Uint8Array; + getPaymentPreimage_asB64(): string; + setPaymentPreimage(value: Uint8Array | string): SettleRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): SettleRequest.AsObject; @@ -347,7 +371,7 @@ export class SettleRequest extends jspb.Message { export namespace SettleRequest { export type AsObject = { - paymentPreimage: string, + paymentPreimage: Uint8Array | string, } } @@ -369,8 +393,10 @@ export namespace SettleResponse { } export class CancelRequest extends jspb.Message { - getPaymentHash(): string; - setPaymentHash(value: string): CancelRequest; + getPaymentHash(): Uint8Array | string; + getPaymentHash_asU8(): Uint8Array; + getPaymentHash_asB64(): string; + setPaymentHash(value: Uint8Array | string): CancelRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): CancelRequest.AsObject; @@ -384,7 +410,7 @@ export class CancelRequest extends jspb.Message { export namespace CancelRequest { export type AsObject = { - paymentHash: string, + paymentHash: Uint8Array | string, } } @@ -406,8 +432,10 @@ export namespace CancelResponse { } export class TrackRequest extends jspb.Message { - getPaymentHash(): string; - setPaymentHash(value: string): TrackRequest; + getPaymentHash(): Uint8Array | string; + getPaymentHash_asU8(): Uint8Array; + getPaymentHash_asB64(): string; + setPaymentHash(value: Uint8Array | string): TrackRequest; serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): TrackRequest.AsObject; @@ -421,7 +449,7 @@ export class TrackRequest extends jspb.Message { export namespace TrackRequest { export type AsObject = { - paymentHash: string, + paymentHash: Uint8Array | string, } } @@ -463,8 +491,10 @@ export namespace TrackAllRequest { } export class TrackAllResponse extends jspb.Message { - getPaymentHash(): string; - setPaymentHash(value: string): TrackAllResponse; + getPaymentHash(): Uint8Array | string; + getPaymentHash_asU8(): Uint8Array; + getPaymentHash_asB64(): string; + setPaymentHash(value: Uint8Array | string): TrackAllResponse; getBolt11(): string; setBolt11(value: string): TrackAllResponse; getState(): InvoiceState; @@ -482,351 +512,15 @@ export class TrackAllResponse extends jspb.Message { export namespace TrackAllResponse { export type AsObject = { - paymentHash: string, + paymentHash: Uint8Array | string, bolt11: string, state: InvoiceState, } } -export class PayStatusRequest extends jspb.Message { - - hasBolt11(): boolean; - clearBolt11(): void; - getBolt11(): string | undefined; - setBolt11(value: string): PayStatusRequest; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): PayStatusRequest.AsObject; - static toObject(includeInstance: boolean, msg: PayStatusRequest): PayStatusRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: PayStatusRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): PayStatusRequest; - static deserializeBinaryFromReader(message: PayStatusRequest, reader: jspb.BinaryReader): PayStatusRequest; -} - -export namespace PayStatusRequest { - export type AsObject = { - bolt11?: string, - } -} - -export class PayStatusResponse extends jspb.Message { - clearStatusList(): void; - getStatusList(): Array; - setStatusList(value: Array): PayStatusResponse; - addStatus(value?: PayStatusResponse.PayStatus, index?: number): PayStatusResponse.PayStatus; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): PayStatusResponse.AsObject; - static toObject(includeInstance: boolean, msg: PayStatusResponse): PayStatusResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: PayStatusResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): PayStatusResponse; - static deserializeBinaryFromReader(message: PayStatusResponse, reader: jspb.BinaryReader): PayStatusResponse; -} - -export namespace PayStatusResponse { - export type AsObject = { - statusList: Array, - } - - - export class PayStatus extends jspb.Message { - getBolt11(): string; - setBolt11(value: string): PayStatus; - getAmountMsat(): number; - setAmountMsat(value: number): PayStatus; - getDestination(): string; - setDestination(value: string): PayStatus; - clearAttemptsList(): void; - getAttemptsList(): Array; - setAttemptsList(value: Array): PayStatus; - addAttempts(value?: PayStatusResponse.PayStatus.Attempt, index?: number): PayStatusResponse.PayStatus.Attempt; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): PayStatus.AsObject; - static toObject(includeInstance: boolean, msg: PayStatus): PayStatus.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: PayStatus, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): PayStatus; - static deserializeBinaryFromReader(message: PayStatus, reader: jspb.BinaryReader): PayStatus; - } - - export namespace PayStatus { - export type AsObject = { - bolt11: string, - amountMsat: number, - destination: string, - attemptsList: Array, - } - - - export class Attempt extends jspb.Message { - getStrategy(): string; - setStrategy(value: string): Attempt; - getStartTime(): number; - setStartTime(value: number): Attempt; - getAgeInSeconds(): number; - setAgeInSeconds(value: number): Attempt; - - hasEndTime(): boolean; - clearEndTime(): void; - getEndTime(): number | undefined; - setEndTime(value: number): Attempt; - getState(): PayStatusResponse.PayStatus.Attempt.AttemptState; - setState(value: PayStatusResponse.PayStatus.Attempt.AttemptState): Attempt; - - hasSuccess(): boolean; - clearSuccess(): void; - getSuccess(): PayStatusResponse.PayStatus.Attempt.Success | undefined; - setSuccess(value?: PayStatusResponse.PayStatus.Attempt.Success): Attempt; - - hasFailure(): boolean; - clearFailure(): void; - getFailure(): PayStatusResponse.PayStatus.Attempt.Failure | undefined; - setFailure(value?: PayStatusResponse.PayStatus.Attempt.Failure): Attempt; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): Attempt.AsObject; - static toObject(includeInstance: boolean, msg: Attempt): Attempt.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: Attempt, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): Attempt; - static deserializeBinaryFromReader(message: Attempt, reader: jspb.BinaryReader): Attempt; - } - - export namespace Attempt { - export type AsObject = { - strategy: string, - startTime: number, - ageInSeconds: number, - endTime?: number, - state: PayStatusResponse.PayStatus.Attempt.AttemptState, - success?: PayStatusResponse.PayStatus.Attempt.Success.AsObject, - failure?: PayStatusResponse.PayStatus.Attempt.Failure.AsObject, - } - - - export class Success extends jspb.Message { - getId(): number; - setId(value: number): Success; - getPaymentPreimage(): string; - setPaymentPreimage(value: string): Success; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): Success.AsObject; - static toObject(includeInstance: boolean, msg: Success): Success.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: Success, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): Success; - static deserializeBinaryFromReader(message: Success, reader: jspb.BinaryReader): Success; - } - - export namespace Success { - export type AsObject = { - id: number, - paymentPreimage: string, - } - } - - export class Failure extends jspb.Message { - getMessage(): string; - setMessage(value: string): Failure; - getCode(): number; - setCode(value: number): Failure; - - hasData(): boolean; - clearData(): void; - getData(): PayStatusResponse.PayStatus.Attempt.Failure.Data | undefined; - setData(value?: PayStatusResponse.PayStatus.Attempt.Failure.Data): Failure; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): Failure.AsObject; - static toObject(includeInstance: boolean, msg: Failure): Failure.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: Failure, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): Failure; - static deserializeBinaryFromReader(message: Failure, reader: jspb.BinaryReader): Failure; - } - - export namespace Failure { - export type AsObject = { - message: string, - code: number, - data?: PayStatusResponse.PayStatus.Attempt.Failure.Data.AsObject, - } - - - export class Data extends jspb.Message { - getId(): number; - setId(value: number): Data; - getRawMessage(): string; - setRawMessage(value: string): Data; - getFailCode(): number; - setFailCode(value: number): Data; - getFailCodename(): string; - setFailCodename(value: string): Data; - getErringIndex(): number; - setErringIndex(value: number): Data; - getErringNode(): string; - setErringNode(value: string): Data; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): Data.AsObject; - static toObject(includeInstance: boolean, msg: Data): Data.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: Data, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): Data; - static deserializeBinaryFromReader(message: Data, reader: jspb.BinaryReader): Data; - } - - export namespace Data { - export type AsObject = { - id: number, - rawMessage: string, - failCode: number, - failCodename: string, - erringIndex: number, - erringNode: string, - } - } - - } - - - export enum AttemptState { - ATTEMPT_PENDING = 0, - ATTEMPT_COMPLETED = 1, - } - - } - - } - -} - -export class GetRouteRequest extends jspb.Message { - getDestination(): string; - setDestination(value: string): GetRouteRequest; - getAmountMsat(): number; - setAmountMsat(value: number): GetRouteRequest; - getMaxRetries(): number; - setMaxRetries(value: number): GetRouteRequest; - - hasRiskFactor(): boolean; - clearRiskFactor(): void; - getRiskFactor(): number | undefined; - setRiskFactor(value: number): GetRouteRequest; - - hasMaxCltv(): boolean; - clearMaxCltv(): void; - getMaxCltv(): number | undefined; - setMaxCltv(value: number): GetRouteRequest; - - hasFinalCltvDelta(): boolean; - clearFinalCltvDelta(): void; - getFinalCltvDelta(): number | undefined; - setFinalCltvDelta(value: number): GetRouteRequest; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): GetRouteRequest.AsObject; - static toObject(includeInstance: boolean, msg: GetRouteRequest): GetRouteRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: GetRouteRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): GetRouteRequest; - static deserializeBinaryFromReader(message: GetRouteRequest, reader: jspb.BinaryReader): GetRouteRequest; -} - -export namespace GetRouteRequest { - export type AsObject = { - destination: string, - amountMsat: number, - maxRetries: number, - riskFactor?: number, - maxCltv?: number, - finalCltvDelta?: number, - } -} - -export class GetRouteResponse extends jspb.Message { - clearHopsList(): void; - getHopsList(): Array; - setHopsList(value: Array): GetRouteResponse; - addHops(value?: GetRouteResponse.Hop, index?: number): GetRouteResponse.Hop; - getFeesMsat(): number; - setFeesMsat(value: number): GetRouteResponse; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): GetRouteResponse.AsObject; - static toObject(includeInstance: boolean, msg: GetRouteResponse): GetRouteResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: GetRouteResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): GetRouteResponse; - static deserializeBinaryFromReader(message: GetRouteResponse, reader: jspb.BinaryReader): GetRouteResponse; -} - -export namespace GetRouteResponse { - export type AsObject = { - hopsList: Array, - feesMsat: number, - } - - - export class Hop extends jspb.Message { - getId(): string; - setId(value: string): Hop; - getChannel(): string; - setChannel(value: string): Hop; - getDirection(): number; - setDirection(value: number): Hop; - getAmountMsat(): number; - setAmountMsat(value: number): Hop; - getDelay(): number; - setDelay(value: number): Hop; - getStyle(): string; - setStyle(value: string): Hop; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): Hop.AsObject; - static toObject(includeInstance: boolean, msg: Hop): Hop.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: Hop, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): Hop; - static deserializeBinaryFromReader(message: Hop, reader: jspb.BinaryReader): Hop; - } - - export namespace Hop { - export type AsObject = { - id: string, - channel: string, - direction: number, - amountMsat: number, - delay: number, - style: string, - } - } - -} - export enum InvoiceState { - INVOICE_UNPAID = 0, - INVOICE_ACCEPTED = 1, - INVOICE_PAID = 2, - INVOICE_CANCELLED = 3, -} - -export enum HtlcState { - HTLC_ACCEPTED = 0, - HTLC_SETTLED = 1, - HTLC_CANCELLED = 2, + UNPAID = 0, + ACCEPTED = 1, + PAID = 2, + CANCELLED = 3, } diff --git a/lib/proto/hold/hold_pb.js b/lib/proto/hold/hold_pb.js index 828f1a03..d4f44747 100644 --- a/lib/proto/hold/hold_pb.js +++ b/lib/proto/hold/hold_pb.js @@ -1,4 +1,4 @@ -// source: hold.proto +// source: hold/hold.proto /** * @fileoverview * @enhanceable @@ -25,29 +25,18 @@ goog.exportSymbol('proto.hold.CancelRequest', null, global); goog.exportSymbol('proto.hold.CancelResponse', null, global); goog.exportSymbol('proto.hold.GetInfoRequest', null, global); goog.exportSymbol('proto.hold.GetInfoResponse', null, global); -goog.exportSymbol('proto.hold.GetRouteRequest', null, global); -goog.exportSymbol('proto.hold.GetRouteResponse', null, global); -goog.exportSymbol('proto.hold.GetRouteResponse.Hop', null, global); goog.exportSymbol('proto.hold.Hop', null, global); goog.exportSymbol('proto.hold.Htlc', null, global); -goog.exportSymbol('proto.hold.HtlcState', null, global); goog.exportSymbol('proto.hold.Invoice', null, global); goog.exportSymbol('proto.hold.InvoiceRequest', null, global); +goog.exportSymbol('proto.hold.InvoiceRequest.DescriptionCase', null, global); goog.exportSymbol('proto.hold.InvoiceResponse', null, global); goog.exportSymbol('proto.hold.InvoiceState', null, global); goog.exportSymbol('proto.hold.ListRequest', null, global); +goog.exportSymbol('proto.hold.ListRequest.ConstraintCase', null, global); +goog.exportSymbol('proto.hold.ListRequest.Pagination', null, global); goog.exportSymbol('proto.hold.ListResponse', null, global); -goog.exportSymbol('proto.hold.PayStatusRequest', null, global); -goog.exportSymbol('proto.hold.PayStatusResponse', null, global); -goog.exportSymbol('proto.hold.PayStatusResponse.PayStatus', null, global); -goog.exportSymbol('proto.hold.PayStatusResponse.PayStatus.Attempt', null, global); -goog.exportSymbol('proto.hold.PayStatusResponse.PayStatus.Attempt.AttemptState', null, global); -goog.exportSymbol('proto.hold.PayStatusResponse.PayStatus.Attempt.Failure', null, global); -goog.exportSymbol('proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data', null, global); -goog.exportSymbol('proto.hold.PayStatusResponse.PayStatus.Attempt.Success', null, global); goog.exportSymbol('proto.hold.RoutingHint', null, global); -goog.exportSymbol('proto.hold.RoutingHintsRequest', null, global); -goog.exportSymbol('proto.hold.RoutingHintsResponse', null, global); goog.exportSymbol('proto.hold.SettleRequest', null, global); goog.exportSymbol('proto.hold.SettleResponse', null, global); goog.exportSymbol('proto.hold.TrackAllRequest', null, global); @@ -106,37 +95,16 @@ if (goog.DEBUG && !COMPILED) { * @extends {jspb.Message} * @constructor */ -proto.hold.InvoiceRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, proto.hold.InvoiceRequest.repeatedFields_, null); -}; -goog.inherits(proto.hold.InvoiceRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.hold.InvoiceRequest.displayName = 'proto.hold.InvoiceRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.hold.InvoiceResponse = function(opt_data) { +proto.hold.Hop = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; -goog.inherits(proto.hold.InvoiceResponse, jspb.Message); +goog.inherits(proto.hold.Hop, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ - proto.hold.InvoiceResponse.displayName = 'proto.hold.InvoiceResponse'; + proto.hold.Hop.displayName = 'proto.hold.Hop'; } /** * Generated by JsPbCodeGenerator. @@ -148,16 +116,16 @@ if (goog.DEBUG && !COMPILED) { * @extends {jspb.Message} * @constructor */ -proto.hold.RoutingHintsRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); +proto.hold.RoutingHint = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.hold.RoutingHint.repeatedFields_, null); }; -goog.inherits(proto.hold.RoutingHintsRequest, jspb.Message); +goog.inherits(proto.hold.RoutingHint, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ - proto.hold.RoutingHintsRequest.displayName = 'proto.hold.RoutingHintsRequest'; + proto.hold.RoutingHint.displayName = 'proto.hold.RoutingHint'; } /** * Generated by JsPbCodeGenerator. @@ -169,16 +137,16 @@ if (goog.DEBUG && !COMPILED) { * @extends {jspb.Message} * @constructor */ -proto.hold.Hop = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); +proto.hold.InvoiceRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.hold.InvoiceRequest.repeatedFields_, proto.hold.InvoiceRequest.oneofGroups_); }; -goog.inherits(proto.hold.Hop, jspb.Message); +goog.inherits(proto.hold.InvoiceRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ - proto.hold.Hop.displayName = 'proto.hold.Hop'; + proto.hold.InvoiceRequest.displayName = 'proto.hold.InvoiceRequest'; } /** * Generated by JsPbCodeGenerator. @@ -190,16 +158,16 @@ if (goog.DEBUG && !COMPILED) { * @extends {jspb.Message} * @constructor */ -proto.hold.RoutingHint = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, proto.hold.RoutingHint.repeatedFields_, null); +proto.hold.InvoiceResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; -goog.inherits(proto.hold.RoutingHint, jspb.Message); +goog.inherits(proto.hold.InvoiceResponse, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ - proto.hold.RoutingHint.displayName = 'proto.hold.RoutingHint'; + proto.hold.InvoiceResponse.displayName = 'proto.hold.InvoiceResponse'; } /** * Generated by JsPbCodeGenerator. @@ -211,16 +179,16 @@ if (goog.DEBUG && !COMPILED) { * @extends {jspb.Message} * @constructor */ -proto.hold.RoutingHintsResponse = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, proto.hold.RoutingHintsResponse.repeatedFields_, null); +proto.hold.ListRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.hold.ListRequest.oneofGroups_); }; -goog.inherits(proto.hold.RoutingHintsResponse, jspb.Message); +goog.inherits(proto.hold.ListRequest, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ - proto.hold.RoutingHintsResponse.displayName = 'proto.hold.RoutingHintsResponse'; + proto.hold.ListRequest.displayName = 'proto.hold.ListRequest'; } /** * Generated by JsPbCodeGenerator. @@ -232,16 +200,16 @@ if (goog.DEBUG && !COMPILED) { * @extends {jspb.Message} * @constructor */ -proto.hold.ListRequest = function(opt_data) { +proto.hold.ListRequest.Pagination = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; -goog.inherits(proto.hold.ListRequest, jspb.Message); +goog.inherits(proto.hold.ListRequest.Pagination, jspb.Message); if (goog.DEBUG && !COMPILED) { /** * @public * @override */ - proto.hold.ListRequest.displayName = 'proto.hold.ListRequest'; + proto.hold.ListRequest.Pagination.displayName = 'proto.hold.ListRequest.Pagination'; } /** * Generated by JsPbCodeGenerator. @@ -474,216 +442,6 @@ if (goog.DEBUG && !COMPILED) { */ proto.hold.TrackAllResponse.displayName = 'proto.hold.TrackAllResponse'; } -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.hold.PayStatusRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.hold.PayStatusRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.hold.PayStatusRequest.displayName = 'proto.hold.PayStatusRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.hold.PayStatusResponse = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, proto.hold.PayStatusResponse.repeatedFields_, null); -}; -goog.inherits(proto.hold.PayStatusResponse, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.hold.PayStatusResponse.displayName = 'proto.hold.PayStatusResponse'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.hold.PayStatusResponse.PayStatus = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, proto.hold.PayStatusResponse.PayStatus.repeatedFields_, null); -}; -goog.inherits(proto.hold.PayStatusResponse.PayStatus, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.hold.PayStatusResponse.PayStatus.displayName = 'proto.hold.PayStatusResponse.PayStatus'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.hold.PayStatusResponse.PayStatus.Attempt = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.hold.PayStatusResponse.PayStatus.Attempt, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.hold.PayStatusResponse.PayStatus.Attempt.displayName = 'proto.hold.PayStatusResponse.PayStatus.Attempt'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Success = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.hold.PayStatusResponse.PayStatus.Attempt.Success, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.hold.PayStatusResponse.PayStatus.Attempt.Success.displayName = 'proto.hold.PayStatusResponse.PayStatus.Attempt.Success'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.hold.PayStatusResponse.PayStatus.Attempt.Failure, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.displayName = 'proto.hold.PayStatusResponse.PayStatus.Attempt.Failure'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.displayName = 'proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.hold.GetRouteRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.hold.GetRouteRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.hold.GetRouteRequest.displayName = 'proto.hold.GetRouteRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.hold.GetRouteResponse = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, proto.hold.GetRouteResponse.repeatedFields_, null); -}; -goog.inherits(proto.hold.GetRouteResponse, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.hold.GetRouteResponse.displayName = 'proto.hold.GetRouteResponse'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.hold.GetRouteResponse.Hop = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.hold.GetRouteResponse.Hop, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.hold.GetRouteResponse.Hop.displayName = 'proto.hold.GetRouteResponse.Hop'; -} @@ -916,13 +674,6 @@ proto.hold.GetInfoResponse.prototype.setVersion = function(value) { -/** - * List of repeated fields within this message type. - * @private {!Array} - * @const - */ -proto.hold.InvoiceRequest.repeatedFields_ = [6]; - if (jspb.Message.GENERATE_TO_OBJECT) { @@ -938,8 +689,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.hold.InvoiceRequest.prototype.toObject = function(opt_includeInstance) { - return proto.hold.InvoiceRequest.toObject(opt_includeInstance, this); +proto.hold.Hop.prototype.toObject = function(opt_includeInstance) { + return proto.hold.Hop.toObject(opt_includeInstance, this); }; @@ -948,20 +699,17 @@ proto.hold.InvoiceRequest.prototype.toObject = function(opt_includeInstance) { * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.hold.InvoiceRequest} msg The msg instance to transform. + * @param {!proto.hold.Hop} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.InvoiceRequest.toObject = function(includeInstance, msg) { +proto.hold.Hop.toObject = function(includeInstance, msg) { var f, obj = { - paymentHash: jspb.Message.getFieldWithDefault(msg, 1, ""), - amountMsat: jspb.Message.getFieldWithDefault(msg, 2, 0), - description: jspb.Message.getFieldWithDefault(msg, 3, ""), - descriptionHash: jspb.Message.getFieldWithDefault(msg, 7, ""), - expiry: jspb.Message.getFieldWithDefault(msg, 4, 0), - minFinalCltvExpiry: jspb.Message.getFieldWithDefault(msg, 5, 0), - routingHintsList: jspb.Message.toObjectList(msg.getRoutingHintsList(), - proto.hold.RoutingHint.toObject, includeInstance) + publicKey: msg.getPublicKey_asB64(), + shortChannelId: jspb.Message.getFieldWithDefault(msg, 2, 0), + baseFee: jspb.Message.getFieldWithDefault(msg, 3, 0), + ppmFee: jspb.Message.getFieldWithDefault(msg, 4, 0), + cltvExpiryDelta: jspb.Message.getFieldWithDefault(msg, 5, 0) }; if (includeInstance) { @@ -975,23 +723,23 @@ proto.hold.InvoiceRequest.toObject = function(includeInstance, msg) { /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.InvoiceRequest} + * @return {!proto.hold.Hop} */ -proto.hold.InvoiceRequest.deserializeBinary = function(bytes) { +proto.hold.Hop.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.InvoiceRequest; - return proto.hold.InvoiceRequest.deserializeBinaryFromReader(msg, reader); -}; + var msg = new proto.hold.Hop; + return proto.hold.Hop.deserializeBinaryFromReader(msg, reader); +}; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.hold.InvoiceRequest} msg The message object to deserialize into. + * @param {!proto.hold.Hop} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.InvoiceRequest} + * @return {!proto.hold.Hop} */ -proto.hold.InvoiceRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.hold.Hop.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -999,33 +747,24 @@ proto.hold.InvoiceRequest.deserializeBinaryFromReader = function(msg, reader) { var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setPaymentHash(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setPublicKey(value); break; case 2: var value = /** @type {number} */ (reader.readUint64()); - msg.setAmountMsat(value); + msg.setShortChannelId(value); break; case 3: - var value = /** @type {string} */ (reader.readString()); - msg.setDescription(value); - break; - case 7: - var value = /** @type {string} */ (reader.readString()); - msg.setDescriptionHash(value); + var value = /** @type {number} */ (reader.readUint64()); + msg.setBaseFee(value); break; case 4: var value = /** @type {number} */ (reader.readUint64()); - msg.setExpiry(value); + msg.setPpmFee(value); break; case 5: var value = /** @type {number} */ (reader.readUint64()); - msg.setMinFinalCltvExpiry(value); - break; - case 6: - var value = new proto.hold.RoutingHint; - reader.readMessage(value,proto.hold.RoutingHint.deserializeBinaryFromReader); - msg.addRoutingHints(value); + msg.setCltvExpiryDelta(value); break; default: reader.skipField(); @@ -1040,9 +779,9 @@ proto.hold.InvoiceRequest.deserializeBinaryFromReader = function(msg, reader) { * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.hold.InvoiceRequest.prototype.serializeBinary = function() { +proto.hold.Hop.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.hold.InvoiceRequest.serializeBinaryToWriter(this, writer); + proto.hold.Hop.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -1050,283 +789,171 @@ proto.hold.InvoiceRequest.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.hold.InvoiceRequest} message + * @param {!proto.hold.Hop} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.InvoiceRequest.serializeBinaryToWriter = function(message, writer) { +proto.hold.Hop.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getPaymentHash(); + f = message.getPublicKey_asU8(); if (f.length > 0) { - writer.writeString( + writer.writeBytes( 1, f ); } - f = message.getAmountMsat(); + f = message.getShortChannelId(); if (f !== 0) { writer.writeUint64( 2, f ); } - f = /** @type {string} */ (jspb.Message.getField(message, 3)); - if (f != null) { - writer.writeString( + f = message.getBaseFee(); + if (f !== 0) { + writer.writeUint64( 3, f ); } - f = /** @type {string} */ (jspb.Message.getField(message, 7)); - if (f != null) { - writer.writeString( - 7, - f - ); - } - f = /** @type {number} */ (jspb.Message.getField(message, 4)); - if (f != null) { + f = message.getPpmFee(); + if (f !== 0) { writer.writeUint64( 4, f ); } - f = /** @type {number} */ (jspb.Message.getField(message, 5)); - if (f != null) { + f = message.getCltvExpiryDelta(); + if (f !== 0) { writer.writeUint64( 5, f ); } - f = message.getRoutingHintsList(); - if (f.length > 0) { - writer.writeRepeatedMessage( - 6, - f, - proto.hold.RoutingHint.serializeBinaryToWriter - ); - } -}; - - -/** - * optional string payment_hash = 1; - * @return {string} - */ -proto.hold.InvoiceRequest.prototype.getPaymentHash = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hold.InvoiceRequest} returns this - */ -proto.hold.InvoiceRequest.prototype.setPaymentHash = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * optional uint64 amount_msat = 2; - * @return {number} - */ -proto.hold.InvoiceRequest.prototype.getAmountMsat = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; /** - * @param {number} value - * @return {!proto.hold.InvoiceRequest} returns this + * optional bytes public_key = 1; + * @return {!(string|Uint8Array)} */ -proto.hold.InvoiceRequest.prototype.setAmountMsat = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); +proto.hold.Hop.prototype.getPublicKey = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional string description = 3; + * optional bytes public_key = 1; + * This is a type-conversion wrapper around `getPublicKey()` * @return {string} */ -proto.hold.InvoiceRequest.prototype.getDescription = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hold.InvoiceRequest} returns this - */ -proto.hold.InvoiceRequest.prototype.setDescription = function(value) { - return jspb.Message.setField(this, 3, value); +proto.hold.Hop.prototype.getPublicKey_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getPublicKey())); }; /** - * Clears the field making it undefined. - * @return {!proto.hold.InvoiceRequest} returns this + * optional bytes public_key = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getPublicKey()` + * @return {!Uint8Array} */ -proto.hold.InvoiceRequest.prototype.clearDescription = function() { - return jspb.Message.setField(this, 3, undefined); +proto.hold.Hop.prototype.getPublicKey_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getPublicKey())); }; /** - * Returns whether this field is set. - * @return {boolean} + * @param {!(string|Uint8Array)} value + * @return {!proto.hold.Hop} returns this */ -proto.hold.InvoiceRequest.prototype.hasDescription = function() { - return jspb.Message.getField(this, 3) != null; +proto.hold.Hop.prototype.setPublicKey = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional string description_hash = 7; - * @return {string} + * optional uint64 short_channel_id = 2; + * @return {number} */ -proto.hold.InvoiceRequest.prototype.getDescriptionHash = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 7, "")); +proto.hold.Hop.prototype.getShortChannelId = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; /** - * @param {string} value - * @return {!proto.hold.InvoiceRequest} returns this + * @param {number} value + * @return {!proto.hold.Hop} returns this */ -proto.hold.InvoiceRequest.prototype.setDescriptionHash = function(value) { - return jspb.Message.setField(this, 7, value); +proto.hold.Hop.prototype.setShortChannelId = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); }; /** - * Clears the field making it undefined. - * @return {!proto.hold.InvoiceRequest} returns this + * optional uint64 base_fee = 3; + * @return {number} */ -proto.hold.InvoiceRequest.prototype.clearDescriptionHash = function() { - return jspb.Message.setField(this, 7, undefined); +proto.hold.Hop.prototype.getBaseFee = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); }; /** - * Returns whether this field is set. - * @return {boolean} + * @param {number} value + * @return {!proto.hold.Hop} returns this */ -proto.hold.InvoiceRequest.prototype.hasDescriptionHash = function() { - return jspb.Message.getField(this, 7) != null; +proto.hold.Hop.prototype.setBaseFee = function(value) { + return jspb.Message.setProto3IntField(this, 3, value); }; /** - * optional uint64 expiry = 4; + * optional uint64 ppm_fee = 4; * @return {number} */ -proto.hold.InvoiceRequest.prototype.getExpiry = function() { +proto.hold.Hop.prototype.getPpmFee = function() { return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); }; /** * @param {number} value - * @return {!proto.hold.InvoiceRequest} returns this - */ -proto.hold.InvoiceRequest.prototype.setExpiry = function(value) { - return jspb.Message.setField(this, 4, value); -}; - - -/** - * Clears the field making it undefined. - * @return {!proto.hold.InvoiceRequest} returns this - */ -proto.hold.InvoiceRequest.prototype.clearExpiry = function() { - return jspb.Message.setField(this, 4, undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} + * @return {!proto.hold.Hop} returns this */ -proto.hold.InvoiceRequest.prototype.hasExpiry = function() { - return jspb.Message.getField(this, 4) != null; +proto.hold.Hop.prototype.setPpmFee = function(value) { + return jspb.Message.setProto3IntField(this, 4, value); }; /** - * optional uint64 min_final_cltv_expiry = 5; + * optional uint64 cltv_expiry_delta = 5; * @return {number} */ -proto.hold.InvoiceRequest.prototype.getMinFinalCltvExpiry = function() { +proto.hold.Hop.prototype.getCltvExpiryDelta = function() { return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); }; /** * @param {number} value - * @return {!proto.hold.InvoiceRequest} returns this - */ -proto.hold.InvoiceRequest.prototype.setMinFinalCltvExpiry = function(value) { - return jspb.Message.setField(this, 5, value); -}; - - -/** - * Clears the field making it undefined. - * @return {!proto.hold.InvoiceRequest} returns this - */ -proto.hold.InvoiceRequest.prototype.clearMinFinalCltvExpiry = function() { - return jspb.Message.setField(this, 5, undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.hold.InvoiceRequest.prototype.hasMinFinalCltvExpiry = function() { - return jspb.Message.getField(this, 5) != null; -}; - - -/** - * repeated RoutingHint routing_hints = 6; - * @return {!Array} + * @return {!proto.hold.Hop} returns this */ -proto.hold.InvoiceRequest.prototype.getRoutingHintsList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.hold.RoutingHint, 6)); -}; - - -/** - * @param {!Array} value - * @return {!proto.hold.InvoiceRequest} returns this -*/ -proto.hold.InvoiceRequest.prototype.setRoutingHintsList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 6, value); +proto.hold.Hop.prototype.setCltvExpiryDelta = function(value) { + return jspb.Message.setProto3IntField(this, 5, value); }; -/** - * @param {!proto.hold.RoutingHint=} opt_value - * @param {number=} opt_index - * @return {!proto.hold.RoutingHint} - */ -proto.hold.InvoiceRequest.prototype.addRoutingHints = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 6, opt_value, proto.hold.RoutingHint, opt_index); -}; - /** - * Clears the list making it empty but non-null. - * @return {!proto.hold.InvoiceRequest} returns this + * List of repeated fields within this message type. + * @private {!Array} + * @const */ -proto.hold.InvoiceRequest.prototype.clearRoutingHintsList = function() { - return this.setRoutingHintsList([]); -}; - - +proto.hold.RoutingHint.repeatedFields_ = [1]; @@ -1343,8 +970,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.hold.InvoiceResponse.prototype.toObject = function(opt_includeInstance) { - return proto.hold.InvoiceResponse.toObject(opt_includeInstance, this); +proto.hold.RoutingHint.prototype.toObject = function(opt_includeInstance) { + return proto.hold.RoutingHint.toObject(opt_includeInstance, this); }; @@ -1353,13 +980,14 @@ proto.hold.InvoiceResponse.prototype.toObject = function(opt_includeInstance) { * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.hold.InvoiceResponse} msg The msg instance to transform. + * @param {!proto.hold.RoutingHint} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.InvoiceResponse.toObject = function(includeInstance, msg) { +proto.hold.RoutingHint.toObject = function(includeInstance, msg) { var f, obj = { - bolt11: jspb.Message.getFieldWithDefault(msg, 1, "") + hopsList: jspb.Message.toObjectList(msg.getHopsList(), + proto.hold.Hop.toObject, includeInstance) }; if (includeInstance) { @@ -1373,23 +1001,23 @@ proto.hold.InvoiceResponse.toObject = function(includeInstance, msg) { /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.InvoiceResponse} + * @return {!proto.hold.RoutingHint} */ -proto.hold.InvoiceResponse.deserializeBinary = function(bytes) { +proto.hold.RoutingHint.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.InvoiceResponse; - return proto.hold.InvoiceResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.hold.RoutingHint; + return proto.hold.RoutingHint.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.hold.InvoiceResponse} msg The message object to deserialize into. + * @param {!proto.hold.RoutingHint} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.InvoiceResponse} + * @return {!proto.hold.RoutingHint} */ -proto.hold.InvoiceResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.hold.RoutingHint.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -1397,8 +1025,9 @@ proto.hold.InvoiceResponse.deserializeBinaryFromReader = function(msg, reader) { var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setBolt11(value); + var value = new proto.hold.Hop; + reader.readMessage(value,proto.hold.Hop.deserializeBinaryFromReader); + msg.addHops(value); break; default: reader.skipField(); @@ -1413,9 +1042,9 @@ proto.hold.InvoiceResponse.deserializeBinaryFromReader = function(msg, reader) { * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.hold.InvoiceResponse.prototype.serializeBinary = function() { +proto.hold.RoutingHint.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.hold.InvoiceResponse.serializeBinaryToWriter(this, writer); + proto.hold.RoutingHint.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -1423,173 +1052,97 @@ proto.hold.InvoiceResponse.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.hold.InvoiceResponse} message + * @param {!proto.hold.RoutingHint} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.InvoiceResponse.serializeBinaryToWriter = function(message, writer) { +proto.hold.RoutingHint.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getBolt11(); + f = message.getHopsList(); if (f.length > 0) { - writer.writeString( + writer.writeRepeatedMessage( 1, - f + f, + proto.hold.Hop.serializeBinaryToWriter ); } }; /** - * optional string bolt11 = 1; - * @return {string} - */ -proto.hold.InvoiceResponse.prototype.getBolt11 = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hold.InvoiceResponse} returns this + * repeated Hop hops = 1; + * @return {!Array} */ -proto.hold.InvoiceResponse.prototype.setBolt11 = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); +proto.hold.RoutingHint.prototype.getHopsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.hold.Hop, 1)); }; - - - -if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hold.RoutingHintsRequest.prototype.toObject = function(opt_includeInstance) { - return proto.hold.RoutingHintsRequest.toObject(opt_includeInstance, this); + * @param {!Array} value + * @return {!proto.hold.RoutingHint} returns this +*/ +proto.hold.RoutingHint.prototype.setHopsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); }; /** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hold.RoutingHintsRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages + * @param {!proto.hold.Hop=} opt_value + * @param {number=} opt_index + * @return {!proto.hold.Hop} */ -proto.hold.RoutingHintsRequest.toObject = function(includeInstance, msg) { - var f, obj = { - node: jspb.Message.getFieldWithDefault(msg, 1, "") - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; +proto.hold.RoutingHint.prototype.addHops = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.hold.Hop, opt_index); }; -} /** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.RoutingHintsRequest} + * Clears the list making it empty but non-null. + * @return {!proto.hold.RoutingHint} returns this */ -proto.hold.RoutingHintsRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.RoutingHintsRequest; - return proto.hold.RoutingHintsRequest.deserializeBinaryFromReader(msg, reader); +proto.hold.RoutingHint.prototype.clearHopsList = function() { + return this.setHopsList([]); }; -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hold.RoutingHintsRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.RoutingHintsRequest} - */ -proto.hold.RoutingHintsRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setNode(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - /** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} + * List of repeated fields within this message type. + * @private {!Array} + * @const */ -proto.hold.RoutingHintsRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hold.RoutingHintsRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - +proto.hold.InvoiceRequest.repeatedFields_ = [7]; /** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hold.RoutingHintsRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.hold.RoutingHintsRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getNode(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } -}; - +proto.hold.InvoiceRequest.oneofGroups_ = [[3,4]]; /** - * optional string node = 1; - * @return {string} + * @enum {number} */ -proto.hold.RoutingHintsRequest.prototype.getNode = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.hold.InvoiceRequest.DescriptionCase = { + DESCRIPTION_NOT_SET: 0, + MEMO: 3, + HASH: 4 }; - /** - * @param {string} value - * @return {!proto.hold.RoutingHintsRequest} returns this + * @return {proto.hold.InvoiceRequest.DescriptionCase} */ -proto.hold.RoutingHintsRequest.prototype.setNode = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); +proto.hold.InvoiceRequest.prototype.getDescriptionCase = function() { + return /** @type {proto.hold.InvoiceRequest.DescriptionCase} */(jspb.Message.computeOneofCase(this, proto.hold.InvoiceRequest.oneofGroups_[0])); }; - - if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. @@ -1603,8 +1156,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.hold.Hop.prototype.toObject = function(opt_includeInstance) { - return proto.hold.Hop.toObject(opt_includeInstance, this); +proto.hold.InvoiceRequest.prototype.toObject = function(opt_includeInstance) { + return proto.hold.InvoiceRequest.toObject(opt_includeInstance, this); }; @@ -1613,17 +1166,20 @@ proto.hold.Hop.prototype.toObject = function(opt_includeInstance) { * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.hold.Hop} msg The msg instance to transform. + * @param {!proto.hold.InvoiceRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.Hop.toObject = function(includeInstance, msg) { +proto.hold.InvoiceRequest.toObject = function(includeInstance, msg) { var f, obj = { - publicKey: jspb.Message.getFieldWithDefault(msg, 1, ""), - shortChannelId: jspb.Message.getFieldWithDefault(msg, 2, ""), - baseFee: jspb.Message.getFieldWithDefault(msg, 3, 0), - ppmFee: jspb.Message.getFieldWithDefault(msg, 4, 0), - cltvExpiryDelta: jspb.Message.getFieldWithDefault(msg, 5, 0) + paymentHash: msg.getPaymentHash_asB64(), + amountMsat: jspb.Message.getFieldWithDefault(msg, 2, 0), + memo: jspb.Message.getFieldWithDefault(msg, 3, ""), + hash: msg.getHash_asB64(), + expiry: jspb.Message.getFieldWithDefault(msg, 5, 0), + minFinalCltvExpiry: jspb.Message.getFieldWithDefault(msg, 6, 0), + routingHintsList: jspb.Message.toObjectList(msg.getRoutingHintsList(), + proto.hold.RoutingHint.toObject, includeInstance) }; if (includeInstance) { @@ -1637,23 +1193,23 @@ proto.hold.Hop.toObject = function(includeInstance, msg) { /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.Hop} + * @return {!proto.hold.InvoiceRequest} */ -proto.hold.Hop.deserializeBinary = function(bytes) { +proto.hold.InvoiceRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.Hop; - return proto.hold.Hop.deserializeBinaryFromReader(msg, reader); + var msg = new proto.hold.InvoiceRequest; + return proto.hold.InvoiceRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.hold.Hop} msg The message object to deserialize into. + * @param {!proto.hold.InvoiceRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.Hop} + * @return {!proto.hold.InvoiceRequest} */ -proto.hold.Hop.deserializeBinaryFromReader = function(msg, reader) { +proto.hold.InvoiceRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -1661,24 +1217,33 @@ proto.hold.Hop.deserializeBinaryFromReader = function(msg, reader) { var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setPublicKey(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setPaymentHash(value); break; case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setShortChannelId(value); + var value = /** @type {number} */ (reader.readUint64()); + msg.setAmountMsat(value); break; case 3: - var value = /** @type {number} */ (reader.readUint64()); - msg.setBaseFee(value); + var value = /** @type {string} */ (reader.readString()); + msg.setMemo(value); break; case 4: - var value = /** @type {number} */ (reader.readUint64()); - msg.setPpmFee(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setHash(value); break; case 5: var value = /** @type {number} */ (reader.readUint64()); - msg.setCltvExpiryDelta(value); + msg.setExpiry(value); + break; + case 6: + var value = /** @type {number} */ (reader.readUint64()); + msg.setMinFinalCltvExpiry(value); + break; + case 7: + var value = new proto.hold.RoutingHint; + reader.readMessage(value,proto.hold.RoutingHint.deserializeBinaryFromReader); + msg.addRoutingHints(value); break; default: reader.skipField(); @@ -1693,9 +1258,9 @@ proto.hold.Hop.deserializeBinaryFromReader = function(msg, reader) { * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.hold.Hop.prototype.serializeBinary = function() { +proto.hold.InvoiceRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.hold.Hop.serializeBinaryToWriter(this, writer); + proto.hold.InvoiceRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -1703,147 +1268,331 @@ proto.hold.Hop.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.hold.Hop} message + * @param {!proto.hold.InvoiceRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.Hop.serializeBinaryToWriter = function(message, writer) { +proto.hold.InvoiceRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getPublicKey(); + f = message.getPaymentHash_asU8(); if (f.length > 0) { - writer.writeString( + writer.writeBytes( 1, f ); } - f = message.getShortChannelId(); - if (f.length > 0) { - writer.writeString( + f = message.getAmountMsat(); + if (f !== 0) { + writer.writeUint64( 2, f ); } - f = message.getBaseFee(); - if (f !== 0) { - writer.writeUint64( + f = /** @type {string} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeString( 3, f ); } - f = message.getPpmFee(); - if (f !== 0) { - writer.writeUint64( + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeBytes( 4, f ); } - f = message.getCltvExpiryDelta(); - if (f !== 0) { + f = /** @type {number} */ (jspb.Message.getField(message, 5)); + if (f != null) { writer.writeUint64( 5, f ); } + f = /** @type {number} */ (jspb.Message.getField(message, 6)); + if (f != null) { + writer.writeUint64( + 6, + f + ); + } + f = message.getRoutingHintsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 7, + f, + proto.hold.RoutingHint.serializeBinaryToWriter + ); + } }; /** - * optional string public_key = 1; - * @return {string} + * optional bytes payment_hash = 1; + * @return {!(string|Uint8Array)} */ -proto.hold.Hop.prototype.getPublicKey = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.hold.InvoiceRequest.prototype.getPaymentHash = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * @param {string} value - * @return {!proto.hold.Hop} returns this + * optional bytes payment_hash = 1; + * This is a type-conversion wrapper around `getPaymentHash()` + * @return {string} */ -proto.hold.Hop.prototype.setPublicKey = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); +proto.hold.InvoiceRequest.prototype.getPaymentHash_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getPaymentHash())); }; /** - * optional string short_channel_id = 2; - * @return {string} + * optional bytes payment_hash = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getPaymentHash()` + * @return {!Uint8Array} */ -proto.hold.Hop.prototype.getShortChannelId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +proto.hold.InvoiceRequest.prototype.getPaymentHash_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getPaymentHash())); }; /** - * @param {string} value - * @return {!proto.hold.Hop} returns this + * @param {!(string|Uint8Array)} value + * @return {!proto.hold.InvoiceRequest} returns this */ -proto.hold.Hop.prototype.setShortChannelId = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); +proto.hold.InvoiceRequest.prototype.setPaymentHash = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional uint64 base_fee = 3; + * optional uint64 amount_msat = 2; * @return {number} */ -proto.hold.Hop.prototype.getBaseFee = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +proto.hold.InvoiceRequest.prototype.getAmountMsat = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; /** * @param {number} value - * @return {!proto.hold.Hop} returns this + * @return {!proto.hold.InvoiceRequest} returns this */ -proto.hold.Hop.prototype.setBaseFee = function(value) { - return jspb.Message.setProto3IntField(this, 3, value); -}; +proto.hold.InvoiceRequest.prototype.setAmountMsat = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; /** - * optional uint64 ppm_fee = 4; + * optional string memo = 3; + * @return {string} + */ +proto.hold.InvoiceRequest.prototype.getMemo = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.hold.InvoiceRequest} returns this + */ +proto.hold.InvoiceRequest.prototype.setMemo = function(value) { + return jspb.Message.setOneofField(this, 3, proto.hold.InvoiceRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.hold.InvoiceRequest} returns this + */ +proto.hold.InvoiceRequest.prototype.clearMemo = function() { + return jspb.Message.setOneofField(this, 3, proto.hold.InvoiceRequest.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.hold.InvoiceRequest.prototype.hasMemo = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional bytes hash = 4; + * @return {!(string|Uint8Array)} + */ +proto.hold.InvoiceRequest.prototype.getHash = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * optional bytes hash = 4; + * This is a type-conversion wrapper around `getHash()` + * @return {string} + */ +proto.hold.InvoiceRequest.prototype.getHash_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getHash())); +}; + + +/** + * optional bytes hash = 4; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getHash()` + * @return {!Uint8Array} + */ +proto.hold.InvoiceRequest.prototype.getHash_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getHash())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.hold.InvoiceRequest} returns this + */ +proto.hold.InvoiceRequest.prototype.setHash = function(value) { + return jspb.Message.setOneofField(this, 4, proto.hold.InvoiceRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.hold.InvoiceRequest} returns this + */ +proto.hold.InvoiceRequest.prototype.clearHash = function() { + return jspb.Message.setOneofField(this, 4, proto.hold.InvoiceRequest.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.hold.InvoiceRequest.prototype.hasHash = function() { + return jspb.Message.getField(this, 4) != null; +}; + + +/** + * optional uint64 expiry = 5; * @return {number} */ -proto.hold.Hop.prototype.getPpmFee = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +proto.hold.InvoiceRequest.prototype.getExpiry = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); }; /** * @param {number} value - * @return {!proto.hold.Hop} returns this + * @return {!proto.hold.InvoiceRequest} returns this */ -proto.hold.Hop.prototype.setPpmFee = function(value) { - return jspb.Message.setProto3IntField(this, 4, value); +proto.hold.InvoiceRequest.prototype.setExpiry = function(value) { + return jspb.Message.setField(this, 5, value); }; /** - * optional uint64 cltv_expiry_delta = 5; + * Clears the field making it undefined. + * @return {!proto.hold.InvoiceRequest} returns this + */ +proto.hold.InvoiceRequest.prototype.clearExpiry = function() { + return jspb.Message.setField(this, 5, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.hold.InvoiceRequest.prototype.hasExpiry = function() { + return jspb.Message.getField(this, 5) != null; +}; + + +/** + * optional uint64 min_final_cltv_expiry = 6; * @return {number} */ -proto.hold.Hop.prototype.getCltvExpiryDelta = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); +proto.hold.InvoiceRequest.prototype.getMinFinalCltvExpiry = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 6, 0)); }; /** * @param {number} value - * @return {!proto.hold.Hop} returns this + * @return {!proto.hold.InvoiceRequest} returns this */ -proto.hold.Hop.prototype.setCltvExpiryDelta = function(value) { - return jspb.Message.setProto3IntField(this, 5, value); +proto.hold.InvoiceRequest.prototype.setMinFinalCltvExpiry = function(value) { + return jspb.Message.setField(this, 6, value); }; +/** + * Clears the field making it undefined. + * @return {!proto.hold.InvoiceRequest} returns this + */ +proto.hold.InvoiceRequest.prototype.clearMinFinalCltvExpiry = function() { + return jspb.Message.setField(this, 6, undefined); +}; + /** - * List of repeated fields within this message type. - * @private {!Array} - * @const + * Returns whether this field is set. + * @return {boolean} */ -proto.hold.RoutingHint.repeatedFields_ = [1]; +proto.hold.InvoiceRequest.prototype.hasMinFinalCltvExpiry = function() { + return jspb.Message.getField(this, 6) != null; +}; + + +/** + * repeated RoutingHint routing_hints = 7; + * @return {!Array} + */ +proto.hold.InvoiceRequest.prototype.getRoutingHintsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.hold.RoutingHint, 7)); +}; + + +/** + * @param {!Array} value + * @return {!proto.hold.InvoiceRequest} returns this +*/ +proto.hold.InvoiceRequest.prototype.setRoutingHintsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 7, value); +}; + + +/** + * @param {!proto.hold.RoutingHint=} opt_value + * @param {number=} opt_index + * @return {!proto.hold.RoutingHint} + */ +proto.hold.InvoiceRequest.prototype.addRoutingHints = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 7, opt_value, proto.hold.RoutingHint, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.hold.InvoiceRequest} returns this + */ +proto.hold.InvoiceRequest.prototype.clearRoutingHintsList = function() { + return this.setRoutingHintsList([]); +}; + + @@ -1860,8 +1609,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.hold.RoutingHint.prototype.toObject = function(opt_includeInstance) { - return proto.hold.RoutingHint.toObject(opt_includeInstance, this); +proto.hold.InvoiceResponse.prototype.toObject = function(opt_includeInstance) { + return proto.hold.InvoiceResponse.toObject(opt_includeInstance, this); }; @@ -1870,14 +1619,13 @@ proto.hold.RoutingHint.prototype.toObject = function(opt_includeInstance) { * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.hold.RoutingHint} msg The msg instance to transform. + * @param {!proto.hold.InvoiceResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.RoutingHint.toObject = function(includeInstance, msg) { +proto.hold.InvoiceResponse.toObject = function(includeInstance, msg) { var f, obj = { - hopsList: jspb.Message.toObjectList(msg.getHopsList(), - proto.hold.Hop.toObject, includeInstance) + bolt11: jspb.Message.getFieldWithDefault(msg, 1, "") }; if (includeInstance) { @@ -1891,23 +1639,23 @@ proto.hold.RoutingHint.toObject = function(includeInstance, msg) { /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.RoutingHint} + * @return {!proto.hold.InvoiceResponse} */ -proto.hold.RoutingHint.deserializeBinary = function(bytes) { +proto.hold.InvoiceResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.RoutingHint; - return proto.hold.RoutingHint.deserializeBinaryFromReader(msg, reader); + var msg = new proto.hold.InvoiceResponse; + return proto.hold.InvoiceResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.hold.RoutingHint} msg The message object to deserialize into. + * @param {!proto.hold.InvoiceResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.RoutingHint} + * @return {!proto.hold.InvoiceResponse} */ -proto.hold.RoutingHint.deserializeBinaryFromReader = function(msg, reader) { +proto.hold.InvoiceResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -1915,9 +1663,8 @@ proto.hold.RoutingHint.deserializeBinaryFromReader = function(msg, reader) { var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.hold.Hop; - reader.readMessage(value,proto.hold.Hop.deserializeBinaryFromReader); - msg.addHops(value); + var value = /** @type {string} */ (reader.readString()); + msg.setBolt11(value); break; default: reader.skipField(); @@ -1932,9 +1679,9 @@ proto.hold.RoutingHint.deserializeBinaryFromReader = function(msg, reader) { * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.hold.RoutingHint.prototype.serializeBinary = function() { +proto.hold.InvoiceResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.hold.RoutingHint.serializeBinaryToWriter(this, writer); + proto.hold.InvoiceResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -1942,68 +1689,66 @@ proto.hold.RoutingHint.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.hold.RoutingHint} message + * @param {!proto.hold.InvoiceResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.RoutingHint.serializeBinaryToWriter = function(message, writer) { +proto.hold.InvoiceResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getHopsList(); + f = message.getBolt11(); if (f.length > 0) { - writer.writeRepeatedMessage( + writer.writeString( 1, - f, - proto.hold.Hop.serializeBinaryToWriter + f ); } }; /** - * repeated Hop hops = 1; - * @return {!Array} + * optional string bolt11 = 1; + * @return {string} */ -proto.hold.RoutingHint.prototype.getHopsList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.hold.Hop, 1)); +proto.hold.InvoiceResponse.prototype.getBolt11 = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * @param {!Array} value - * @return {!proto.hold.RoutingHint} returns this -*/ -proto.hold.RoutingHint.prototype.setHopsList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 1, value); + * @param {string} value + * @return {!proto.hold.InvoiceResponse} returns this + */ +proto.hold.InvoiceResponse.prototype.setBolt11 = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); }; + /** - * @param {!proto.hold.Hop=} opt_value - * @param {number=} opt_index - * @return {!proto.hold.Hop} + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const */ -proto.hold.RoutingHint.prototype.addHops = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.hold.Hop, opt_index); -}; - +proto.hold.ListRequest.oneofGroups_ = [[1,2]]; /** - * Clears the list making it empty but non-null. - * @return {!proto.hold.RoutingHint} returns this + * @enum {number} */ -proto.hold.RoutingHint.prototype.clearHopsList = function() { - return this.setHopsList([]); +proto.hold.ListRequest.ConstraintCase = { + CONSTRAINT_NOT_SET: 0, + PAYMENT_HASH: 1, + PAGINATION: 2 }; - - /** - * List of repeated fields within this message type. - * @private {!Array} - * @const + * @return {proto.hold.ListRequest.ConstraintCase} */ -proto.hold.RoutingHintsResponse.repeatedFields_ = [1]; +proto.hold.ListRequest.prototype.getConstraintCase = function() { + return /** @type {proto.hold.ListRequest.ConstraintCase} */(jspb.Message.computeOneofCase(this, proto.hold.ListRequest.oneofGroups_[0])); +}; @@ -2020,8 +1765,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.hold.RoutingHintsResponse.prototype.toObject = function(opt_includeInstance) { - return proto.hold.RoutingHintsResponse.toObject(opt_includeInstance, this); +proto.hold.ListRequest.prototype.toObject = function(opt_includeInstance) { + return proto.hold.ListRequest.toObject(opt_includeInstance, this); }; @@ -2030,14 +1775,14 @@ proto.hold.RoutingHintsResponse.prototype.toObject = function(opt_includeInstanc * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.hold.RoutingHintsResponse} msg The msg instance to transform. + * @param {!proto.hold.ListRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.RoutingHintsResponse.toObject = function(includeInstance, msg) { +proto.hold.ListRequest.toObject = function(includeInstance, msg) { var f, obj = { - hintsList: jspb.Message.toObjectList(msg.getHintsList(), - proto.hold.RoutingHint.toObject, includeInstance) + paymentHash: msg.getPaymentHash_asB64(), + pagination: (f = msg.getPagination()) && proto.hold.ListRequest.Pagination.toObject(includeInstance, f) }; if (includeInstance) { @@ -2051,23 +1796,23 @@ proto.hold.RoutingHintsResponse.toObject = function(includeInstance, msg) { /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.RoutingHintsResponse} + * @return {!proto.hold.ListRequest} */ -proto.hold.RoutingHintsResponse.deserializeBinary = function(bytes) { +proto.hold.ListRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.RoutingHintsResponse; - return proto.hold.RoutingHintsResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.hold.ListRequest; + return proto.hold.ListRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.hold.RoutingHintsResponse} msg The message object to deserialize into. + * @param {!proto.hold.ListRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.RoutingHintsResponse} + * @return {!proto.hold.ListRequest} */ -proto.hold.RoutingHintsResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.hold.ListRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -2075,9 +1820,13 @@ proto.hold.RoutingHintsResponse.deserializeBinaryFromReader = function(msg, read var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new proto.hold.RoutingHint; - reader.readMessage(value,proto.hold.RoutingHint.deserializeBinaryFromReader); - msg.addHints(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setPaymentHash(value); + break; + case 2: + var value = new proto.hold.ListRequest.Pagination; + reader.readMessage(value,proto.hold.ListRequest.Pagination.deserializeBinaryFromReader); + msg.setPagination(value); break; default: reader.skipField(); @@ -2092,9 +1841,9 @@ proto.hold.RoutingHintsResponse.deserializeBinaryFromReader = function(msg, read * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.hold.RoutingHintsResponse.prototype.serializeBinary = function() { +proto.hold.ListRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.hold.RoutingHintsResponse.serializeBinaryToWriter(this, writer); + proto.hold.ListRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -2102,61 +1851,30 @@ proto.hold.RoutingHintsResponse.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.hold.RoutingHintsResponse} message + * @param {!proto.hold.ListRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.RoutingHintsResponse.serializeBinaryToWriter = function(message, writer) { +proto.hold.ListRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getHintsList(); - if (f.length > 0) { - writer.writeRepeatedMessage( + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeBytes( 1, + f + ); + } + f = message.getPagination(); + if (f != null) { + writer.writeMessage( + 2, f, - proto.hold.RoutingHint.serializeBinaryToWriter + proto.hold.ListRequest.Pagination.serializeBinaryToWriter ); } }; -/** - * repeated RoutingHint hints = 1; - * @return {!Array} - */ -proto.hold.RoutingHintsResponse.prototype.getHintsList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.hold.RoutingHint, 1)); -}; - - -/** - * @param {!Array} value - * @return {!proto.hold.RoutingHintsResponse} returns this -*/ -proto.hold.RoutingHintsResponse.prototype.setHintsList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 1, value); -}; - - -/** - * @param {!proto.hold.RoutingHint=} opt_value - * @param {number=} opt_index - * @return {!proto.hold.RoutingHint} - */ -proto.hold.RoutingHintsResponse.prototype.addHints = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.hold.RoutingHint, opt_index); -}; - - -/** - * Clears the list making it empty but non-null. - * @return {!proto.hold.RoutingHintsResponse} returns this - */ -proto.hold.RoutingHintsResponse.prototype.clearHintsList = function() { - return this.setHintsList([]); -}; - - @@ -2173,8 +1891,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.hold.ListRequest.prototype.toObject = function(opt_includeInstance) { - return proto.hold.ListRequest.toObject(opt_includeInstance, this); +proto.hold.ListRequest.Pagination.prototype.toObject = function(opt_includeInstance) { + return proto.hold.ListRequest.Pagination.toObject(opt_includeInstance, this); }; @@ -2183,13 +1901,14 @@ proto.hold.ListRequest.prototype.toObject = function(opt_includeInstance) { * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.hold.ListRequest} msg The msg instance to transform. + * @param {!proto.hold.ListRequest.Pagination} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.ListRequest.toObject = function(includeInstance, msg) { +proto.hold.ListRequest.Pagination.toObject = function(includeInstance, msg) { var f, obj = { - paymentHash: jspb.Message.getFieldWithDefault(msg, 1, "") + indexStart: jspb.Message.getFieldWithDefault(msg, 1, 0), + limit: jspb.Message.getFieldWithDefault(msg, 2, 0) }; if (includeInstance) { @@ -2203,23 +1922,23 @@ proto.hold.ListRequest.toObject = function(includeInstance, msg) { /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.ListRequest} + * @return {!proto.hold.ListRequest.Pagination} */ -proto.hold.ListRequest.deserializeBinary = function(bytes) { +proto.hold.ListRequest.Pagination.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.ListRequest; - return proto.hold.ListRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.hold.ListRequest.Pagination; + return proto.hold.ListRequest.Pagination.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.hold.ListRequest} msg The message object to deserialize into. + * @param {!proto.hold.ListRequest.Pagination} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.ListRequest} + * @return {!proto.hold.ListRequest.Pagination} */ -proto.hold.ListRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.hold.ListRequest.Pagination.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -2227,8 +1946,12 @@ proto.hold.ListRequest.deserializeBinaryFromReader = function(msg, reader) { var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setPaymentHash(value); + var value = /** @type {number} */ (reader.readInt64()); + msg.setIndexStart(value); + break; + case 2: + var value = /** @type {number} */ (reader.readUint64()); + msg.setLimit(value); break; default: reader.skipField(); @@ -2243,9 +1966,9 @@ proto.hold.ListRequest.deserializeBinaryFromReader = function(msg, reader) { * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.hold.ListRequest.prototype.serializeBinary = function() { +proto.hold.ListRequest.Pagination.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.hold.ListRequest.serializeBinaryToWriter(this, writer); + proto.hold.ListRequest.Pagination.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -2253,37 +1976,104 @@ proto.hold.ListRequest.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.hold.ListRequest} message + * @param {!proto.hold.ListRequest.Pagination} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.ListRequest.serializeBinaryToWriter = function(message, writer) { +proto.hold.ListRequest.Pagination.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = /** @type {string} */ (jspb.Message.getField(message, 1)); - if (f != null) { - writer.writeString( + f = message.getIndexStart(); + if (f !== 0) { + writer.writeInt64( 1, f ); } + f = message.getLimit(); + if (f !== 0) { + writer.writeUint64( + 2, + f + ); + } }; /** - * optional string payment_hash = 1; - * @return {string} + * optional int64 index_start = 1; + * @return {number} + */ +proto.hold.ListRequest.Pagination.prototype.getIndexStart = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.hold.ListRequest.Pagination} returns this + */ +proto.hold.ListRequest.Pagination.prototype.setIndexStart = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); +}; + + +/** + * optional uint64 limit = 2; + * @return {number} + */ +proto.hold.ListRequest.Pagination.prototype.getLimit = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.hold.ListRequest.Pagination} returns this + */ +proto.hold.ListRequest.Pagination.prototype.setLimit = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; + + +/** + * optional bytes payment_hash = 1; + * @return {!(string|Uint8Array)} */ proto.hold.ListRequest.prototype.getPaymentHash = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * @param {string} value + * optional bytes payment_hash = 1; + * This is a type-conversion wrapper around `getPaymentHash()` + * @return {string} + */ +proto.hold.ListRequest.prototype.getPaymentHash_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getPaymentHash())); +}; + + +/** + * optional bytes payment_hash = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getPaymentHash()` + * @return {!Uint8Array} + */ +proto.hold.ListRequest.prototype.getPaymentHash_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getPaymentHash())); +}; + + +/** + * @param {!(string|Uint8Array)} value * @return {!proto.hold.ListRequest} returns this */ proto.hold.ListRequest.prototype.setPaymentHash = function(value) { - return jspb.Message.setField(this, 1, value); + return jspb.Message.setOneofField(this, 1, proto.hold.ListRequest.oneofGroups_[0], value); }; @@ -2292,7 +2082,7 @@ proto.hold.ListRequest.prototype.setPaymentHash = function(value) { * @return {!proto.hold.ListRequest} returns this */ proto.hold.ListRequest.prototype.clearPaymentHash = function() { - return jspb.Message.setField(this, 1, undefined); + return jspb.Message.setOneofField(this, 1, proto.hold.ListRequest.oneofGroups_[0], undefined); }; @@ -2305,6 +2095,43 @@ proto.hold.ListRequest.prototype.hasPaymentHash = function() { }; +/** + * optional Pagination pagination = 2; + * @return {?proto.hold.ListRequest.Pagination} + */ +proto.hold.ListRequest.prototype.getPagination = function() { + return /** @type{?proto.hold.ListRequest.Pagination} */ ( + jspb.Message.getWrapperField(this, proto.hold.ListRequest.Pagination, 2)); +}; + + +/** + * @param {?proto.hold.ListRequest.Pagination|undefined} value + * @return {!proto.hold.ListRequest} returns this +*/ +proto.hold.ListRequest.prototype.setPagination = function(value) { + return jspb.Message.setOneofWrapperField(this, 2, proto.hold.ListRequest.oneofGroups_[0], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.hold.ListRequest} returns this + */ +proto.hold.ListRequest.prototype.clearPagination = function() { + return this.setPagination(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.hold.ListRequest.prototype.hasPagination = function() { + return jspb.Message.getField(this, 2) != null; +}; + + @@ -2337,11 +2164,12 @@ proto.hold.Htlc.prototype.toObject = function(opt_includeInstance) { */ proto.hold.Htlc.toObject = function(includeInstance, msg) { var f, obj = { - state: jspb.Message.getFieldWithDefault(msg, 1, 0), - msat: jspb.Message.getFieldWithDefault(msg, 2, 0), - createdAt: jspb.Message.getFieldWithDefault(msg, 3, 0), - shortChannelId: jspb.Message.getFieldWithDefault(msg, 4, ""), - id: jspb.Message.getFieldWithDefault(msg, 5, 0) + id: jspb.Message.getFieldWithDefault(msg, 1, 0), + state: jspb.Message.getFieldWithDefault(msg, 2, 0), + scid: jspb.Message.getFieldWithDefault(msg, 3, ""), + channelId: jspb.Message.getFieldWithDefault(msg, 4, 0), + msat: jspb.Message.getFieldWithDefault(msg, 5, 0), + createdAt: jspb.Message.getFieldWithDefault(msg, 6, 0) }; if (includeInstance) { @@ -2379,24 +2207,28 @@ proto.hold.Htlc.deserializeBinaryFromReader = function(msg, reader) { var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {!proto.hold.HtlcState} */ (reader.readEnum()); - msg.setState(value); + var value = /** @type {number} */ (reader.readInt64()); + msg.setId(value); break; case 2: - var value = /** @type {number} */ (reader.readUint64()); - msg.setMsat(value); + var value = /** @type {!proto.hold.InvoiceState} */ (reader.readEnum()); + msg.setState(value); break; case 3: - var value = /** @type {number} */ (reader.readUint64()); - msg.setCreatedAt(value); + var value = /** @type {string} */ (reader.readString()); + msg.setScid(value); break; case 4: - var value = /** @type {string} */ (reader.readString()); - msg.setShortChannelId(value); + var value = /** @type {number} */ (reader.readUint64()); + msg.setChannelId(value); break; case 5: var value = /** @type {number} */ (reader.readUint64()); - msg.setId(value); + msg.setMsat(value); + break; + case 6: + var value = /** @type {number} */ (reader.readUint64()); + msg.setCreatedAt(value); break; default: reader.skipField(); @@ -2427,86 +2259,111 @@ proto.hold.Htlc.prototype.serializeBinary = function() { */ proto.hold.Htlc.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getState(); - if (f !== 0.0) { - writer.writeEnum( + f = message.getId(); + if (f !== 0) { + writer.writeInt64( 1, f ); } - f = message.getMsat(); - if (f !== 0) { - writer.writeUint64( + f = message.getState(); + if (f !== 0.0) { + writer.writeEnum( 2, f ); } - f = message.getCreatedAt(); - if (f !== 0) { - writer.writeUint64( + f = message.getScid(); + if (f.length > 0) { + writer.writeString( 3, f ); } - f = message.getShortChannelId(); - if (f.length > 0) { - writer.writeString( + f = message.getChannelId(); + if (f !== 0) { + writer.writeUint64( 4, f ); } - f = message.getId(); + f = message.getMsat(); if (f !== 0) { writer.writeUint64( 5, f ); } + f = message.getCreatedAt(); + if (f !== 0) { + writer.writeUint64( + 6, + f + ); + } +}; + + +/** + * optional int64 id = 1; + * @return {number} + */ +proto.hold.Htlc.prototype.getId = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.hold.Htlc} returns this + */ +proto.hold.Htlc.prototype.setId = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); }; /** - * optional HtlcState state = 1; - * @return {!proto.hold.HtlcState} + * optional InvoiceState state = 2; + * @return {!proto.hold.InvoiceState} */ proto.hold.Htlc.prototype.getState = function() { - return /** @type {!proto.hold.HtlcState} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); + return /** @type {!proto.hold.InvoiceState} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; /** - * @param {!proto.hold.HtlcState} value + * @param {!proto.hold.InvoiceState} value * @return {!proto.hold.Htlc} returns this */ proto.hold.Htlc.prototype.setState = function(value) { - return jspb.Message.setProto3EnumField(this, 1, value); + return jspb.Message.setProto3EnumField(this, 2, value); }; /** - * optional uint64 msat = 2; - * @return {number} + * optional string scid = 3; + * @return {string} */ -proto.hold.Htlc.prototype.getMsat = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +proto.hold.Htlc.prototype.getScid = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); }; /** - * @param {number} value + * @param {string} value * @return {!proto.hold.Htlc} returns this */ -proto.hold.Htlc.prototype.setMsat = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); +proto.hold.Htlc.prototype.setScid = function(value) { + return jspb.Message.setProto3StringField(this, 3, value); }; /** - * optional uint64 created_at = 3; + * optional uint64 channel_id = 4; * @return {number} */ -proto.hold.Htlc.prototype.getCreatedAt = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +proto.hold.Htlc.prototype.getChannelId = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); }; @@ -2514,35 +2371,35 @@ proto.hold.Htlc.prototype.getCreatedAt = function() { * @param {number} value * @return {!proto.hold.Htlc} returns this */ -proto.hold.Htlc.prototype.setCreatedAt = function(value) { - return jspb.Message.setProto3IntField(this, 3, value); +proto.hold.Htlc.prototype.setChannelId = function(value) { + return jspb.Message.setProto3IntField(this, 4, value); }; /** - * optional string short_channel_id = 4; - * @return {string} + * optional uint64 msat = 5; + * @return {number} */ -proto.hold.Htlc.prototype.getShortChannelId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +proto.hold.Htlc.prototype.getMsat = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); }; /** - * @param {string} value + * @param {number} value * @return {!proto.hold.Htlc} returns this */ -proto.hold.Htlc.prototype.setShortChannelId = function(value) { - return jspb.Message.setProto3StringField(this, 4, value); +proto.hold.Htlc.prototype.setMsat = function(value) { + return jspb.Message.setProto3IntField(this, 5, value); }; /** - * optional uint64 id = 5; + * optional uint64 created_at = 6; * @return {number} */ -proto.hold.Htlc.prototype.getId = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); +proto.hold.Htlc.prototype.getCreatedAt = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 6, 0)); }; @@ -2550,8 +2407,8 @@ proto.hold.Htlc.prototype.getId = function() { * @param {number} value * @return {!proto.hold.Htlc} returns this */ -proto.hold.Htlc.prototype.setId = function(value) { - return jspb.Message.setProto3IntField(this, 5, value); +proto.hold.Htlc.prototype.setCreatedAt = function(value) { + return jspb.Message.setProto3IntField(this, 6, value); }; @@ -2561,7 +2418,7 @@ proto.hold.Htlc.prototype.setId = function(value) { * @private {!Array} * @const */ -proto.hold.Invoice.repeatedFields_ = [6]; +proto.hold.Invoice.repeatedFields_ = [7]; @@ -2594,14 +2451,14 @@ proto.hold.Invoice.prototype.toObject = function(opt_includeInstance) { */ proto.hold.Invoice.toObject = function(includeInstance, msg) { var f, obj = { - paymentHash: jspb.Message.getFieldWithDefault(msg, 1, ""), - paymentPreimage: jspb.Message.getFieldWithDefault(msg, 2, ""), - state: jspb.Message.getFieldWithDefault(msg, 3, 0), + id: jspb.Message.getFieldWithDefault(msg, 1, 0), + paymentHash: msg.getPaymentHash_asB64(), + preimage: msg.getPreimage_asB64(), bolt11: jspb.Message.getFieldWithDefault(msg, 4, ""), - createdAt: jspb.Message.getFieldWithDefault(msg, 5, 0), + state: jspb.Message.getFieldWithDefault(msg, 5, 0), + createdAt: jspb.Message.getFieldWithDefault(msg, 6, 0), htlcsList: jspb.Message.toObjectList(msg.getHtlcsList(), - proto.hold.Htlc.toObject, includeInstance), - amountMsat: jspb.Message.getFieldWithDefault(msg, 7, 0) + proto.hold.Htlc.toObject, includeInstance) }; if (includeInstance) { @@ -2639,34 +2496,34 @@ proto.hold.Invoice.deserializeBinaryFromReader = function(msg, reader) { var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setPaymentHash(value); + var value = /** @type {number} */ (reader.readInt64()); + msg.setId(value); break; case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setPaymentPreimage(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setPaymentHash(value); break; case 3: - var value = /** @type {!proto.hold.InvoiceState} */ (reader.readEnum()); - msg.setState(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setPreimage(value); break; case 4: var value = /** @type {string} */ (reader.readString()); msg.setBolt11(value); break; case 5: + var value = /** @type {!proto.hold.InvoiceState} */ (reader.readEnum()); + msg.setState(value); + break; + case 6: var value = /** @type {number} */ (reader.readUint64()); msg.setCreatedAt(value); break; - case 6: + case 7: var value = new proto.hold.Htlc; reader.readMessage(value,proto.hold.Htlc.deserializeBinaryFromReader); msg.addHtlcs(value); break; - case 7: - var value = /** @type {number} */ (reader.readUint64()); - msg.setAmountMsat(value); - break; default: reader.skipField(); break; @@ -2696,23 +2553,23 @@ proto.hold.Invoice.prototype.serializeBinary = function() { */ proto.hold.Invoice.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getPaymentHash(); - if (f.length > 0) { - writer.writeString( + f = message.getId(); + if (f !== 0) { + writer.writeInt64( 1, f ); } - f = /** @type {string} */ (jspb.Message.getField(message, 2)); - if (f != null) { - writer.writeString( + f = message.getPaymentHash_asU8(); + if (f.length > 0) { + writer.writeBytes( 2, f ); } - f = message.getState(); - if (f !== 0.0) { - writer.writeEnum( + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeBytes( 3, f ); @@ -2724,100 +2581,148 @@ proto.hold.Invoice.serializeBinaryToWriter = function(message, writer) { f ); } + f = message.getState(); + if (f !== 0.0) { + writer.writeEnum( + 5, + f + ); + } f = message.getCreatedAt(); if (f !== 0) { writer.writeUint64( - 5, + 6, f ); } f = message.getHtlcsList(); if (f.length > 0) { writer.writeRepeatedMessage( - 6, + 7, f, proto.hold.Htlc.serializeBinaryToWriter ); } - f = message.getAmountMsat(); - if (f !== 0) { - writer.writeUint64( - 7, - f - ); - } }; /** - * optional string payment_hash = 1; - * @return {string} + * optional int64 id = 1; + * @return {number} */ -proto.hold.Invoice.prototype.getPaymentHash = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +proto.hold.Invoice.prototype.getId = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); }; /** - * @param {string} value + * @param {number} value * @return {!proto.hold.Invoice} returns this */ -proto.hold.Invoice.prototype.setPaymentHash = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); +proto.hold.Invoice.prototype.setId = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); +}; + + +/** + * optional bytes payment_hash = 2; + * @return {!(string|Uint8Array)} + */ +proto.hold.Invoice.prototype.getPaymentHash = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** - * optional string payment_preimage = 2; + * optional bytes payment_hash = 2; + * This is a type-conversion wrapper around `getPaymentHash()` * @return {string} */ -proto.hold.Invoice.prototype.getPaymentPreimage = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +proto.hold.Invoice.prototype.getPaymentHash_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getPaymentHash())); }; /** - * @param {string} value - * @return {!proto.hold.Invoice} returns this + * optional bytes payment_hash = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getPaymentHash()` + * @return {!Uint8Array} */ -proto.hold.Invoice.prototype.setPaymentPreimage = function(value) { - return jspb.Message.setField(this, 2, value); +proto.hold.Invoice.prototype.getPaymentHash_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getPaymentHash())); }; /** - * Clears the field making it undefined. + * @param {!(string|Uint8Array)} value * @return {!proto.hold.Invoice} returns this */ -proto.hold.Invoice.prototype.clearPaymentPreimage = function() { - return jspb.Message.setField(this, 2, undefined); +proto.hold.Invoice.prototype.setPaymentHash = function(value) { + return jspb.Message.setProto3BytesField(this, 2, value); }; /** - * Returns whether this field is set. - * @return {boolean} + * optional bytes preimage = 3; + * @return {!(string|Uint8Array)} */ -proto.hold.Invoice.prototype.hasPaymentPreimage = function() { - return jspb.Message.getField(this, 2) != null; +proto.hold.Invoice.prototype.getPreimage = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 3, "")); }; /** - * optional InvoiceState state = 3; - * @return {!proto.hold.InvoiceState} + * optional bytes preimage = 3; + * This is a type-conversion wrapper around `getPreimage()` + * @return {string} */ -proto.hold.Invoice.prototype.getState = function() { - return /** @type {!proto.hold.InvoiceState} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +proto.hold.Invoice.prototype.getPreimage_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getPreimage())); }; /** - * @param {!proto.hold.InvoiceState} value + * optional bytes preimage = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getPreimage()` + * @return {!Uint8Array} + */ +proto.hold.Invoice.prototype.getPreimage_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getPreimage())); +}; + + +/** + * @param {!(string|Uint8Array)} value * @return {!proto.hold.Invoice} returns this */ -proto.hold.Invoice.prototype.setState = function(value) { - return jspb.Message.setProto3EnumField(this, 3, value); +proto.hold.Invoice.prototype.setPreimage = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.hold.Invoice} returns this + */ +proto.hold.Invoice.prototype.clearPreimage = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.hold.Invoice.prototype.hasPreimage = function() { + return jspb.Message.getField(this, 3) != null; }; @@ -2840,11 +2745,29 @@ proto.hold.Invoice.prototype.setBolt11 = function(value) { /** - * optional uint64 created_at = 5; + * optional InvoiceState state = 5; + * @return {!proto.hold.InvoiceState} + */ +proto.hold.Invoice.prototype.getState = function() { + return /** @type {!proto.hold.InvoiceState} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); +}; + + +/** + * @param {!proto.hold.InvoiceState} value + * @return {!proto.hold.Invoice} returns this + */ +proto.hold.Invoice.prototype.setState = function(value) { + return jspb.Message.setProto3EnumField(this, 5, value); +}; + + +/** + * optional uint64 created_at = 6; * @return {number} */ proto.hold.Invoice.prototype.getCreatedAt = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 6, 0)); }; @@ -2853,17 +2776,17 @@ proto.hold.Invoice.prototype.getCreatedAt = function() { * @return {!proto.hold.Invoice} returns this */ proto.hold.Invoice.prototype.setCreatedAt = function(value) { - return jspb.Message.setProto3IntField(this, 5, value); + return jspb.Message.setProto3IntField(this, 6, value); }; /** - * repeated Htlc htlcs = 6; + * repeated Htlc htlcs = 7; * @return {!Array} */ proto.hold.Invoice.prototype.getHtlcsList = function() { return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.hold.Htlc, 6)); + jspb.Message.getRepeatedWrapperField(this, proto.hold.Htlc, 7)); }; @@ -2872,7 +2795,7 @@ proto.hold.Invoice.prototype.getHtlcsList = function() { * @return {!proto.hold.Invoice} returns this */ proto.hold.Invoice.prototype.setHtlcsList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 6, value); + return jspb.Message.setRepeatedWrapperField(this, 7, value); }; @@ -2882,7 +2805,7 @@ proto.hold.Invoice.prototype.setHtlcsList = function(value) { * @return {!proto.hold.Htlc} */ proto.hold.Invoice.prototype.addHtlcs = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 6, opt_value, proto.hold.Htlc, opt_index); + return jspb.Message.addToRepeatedWrapperField(this, 7, opt_value, proto.hold.Htlc, opt_index); }; @@ -2895,24 +2818,6 @@ proto.hold.Invoice.prototype.clearHtlcsList = function() { }; -/** - * optional uint64 amount_msat = 7; - * @return {number} - */ -proto.hold.Invoice.prototype.getAmountMsat = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 7, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.hold.Invoice} returns this - */ -proto.hold.Invoice.prototype.setAmountMsat = function(value) { - return jspb.Message.setProto3IntField(this, 7, value); -}; - - /** * List of repeated fields within this message type. @@ -3105,7 +3010,7 @@ proto.hold.SettleRequest.prototype.toObject = function(opt_includeInstance) { */ proto.hold.SettleRequest.toObject = function(includeInstance, msg) { var f, obj = { - paymentPreimage: jspb.Message.getFieldWithDefault(msg, 1, "") + paymentPreimage: msg.getPaymentPreimage_asB64() }; if (includeInstance) { @@ -3143,7 +3048,7 @@ proto.hold.SettleRequest.deserializeBinaryFromReader = function(msg, reader) { var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {string} */ (reader.readString()); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); msg.setPaymentPreimage(value); break; default: @@ -3175,9 +3080,9 @@ proto.hold.SettleRequest.prototype.serializeBinary = function() { */ proto.hold.SettleRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getPaymentPreimage(); + f = message.getPaymentPreimage_asU8(); if (f.length > 0) { - writer.writeString( + writer.writeBytes( 1, f ); @@ -3186,20 +3091,44 @@ proto.hold.SettleRequest.serializeBinaryToWriter = function(message, writer) { /** - * optional string payment_preimage = 1; - * @return {string} + * optional bytes payment_preimage = 1; + * @return {!(string|Uint8Array)} */ proto.hold.SettleRequest.prototype.getPaymentPreimage = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * @param {string} value + * optional bytes payment_preimage = 1; + * This is a type-conversion wrapper around `getPaymentPreimage()` + * @return {string} + */ +proto.hold.SettleRequest.prototype.getPaymentPreimage_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getPaymentPreimage())); +}; + + +/** + * optional bytes payment_preimage = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getPaymentPreimage()` + * @return {!Uint8Array} + */ +proto.hold.SettleRequest.prototype.getPaymentPreimage_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getPaymentPreimage())); +}; + + +/** + * @param {!(string|Uint8Array)} value * @return {!proto.hold.SettleRequest} returns this */ proto.hold.SettleRequest.prototype.setPaymentPreimage = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); + return jspb.Message.setProto3BytesField(this, 1, value); }; @@ -3336,7 +3265,7 @@ proto.hold.CancelRequest.prototype.toObject = function(opt_includeInstance) { */ proto.hold.CancelRequest.toObject = function(includeInstance, msg) { var f, obj = { - paymentHash: jspb.Message.getFieldWithDefault(msg, 1, "") + paymentHash: msg.getPaymentHash_asB64() }; if (includeInstance) { @@ -3374,7 +3303,7 @@ proto.hold.CancelRequest.deserializeBinaryFromReader = function(msg, reader) { var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {string} */ (reader.readString()); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); msg.setPaymentHash(value); break; default: @@ -3406,2270 +3335,156 @@ proto.hold.CancelRequest.prototype.serializeBinary = function() { */ proto.hold.CancelRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getPaymentHash(); + f = message.getPaymentHash_asU8(); if (f.length > 0) { - writer.writeString( + writer.writeBytes( 1, - f - ); - } -}; - - -/** - * optional string payment_hash = 1; - * @return {string} - */ -proto.hold.CancelRequest.prototype.getPaymentHash = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hold.CancelRequest} returns this - */ -proto.hold.CancelRequest.prototype.setPaymentHash = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hold.CancelResponse.prototype.toObject = function(opt_includeInstance) { - return proto.hold.CancelResponse.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hold.CancelResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.CancelResponse.toObject = function(includeInstance, msg) { - var f, obj = { - - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.CancelResponse} - */ -proto.hold.CancelResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.CancelResponse; - return proto.hold.CancelResponse.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hold.CancelResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.CancelResponse} - */ -proto.hold.CancelResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hold.CancelResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hold.CancelResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hold.CancelResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.CancelResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hold.TrackRequest.prototype.toObject = function(opt_includeInstance) { - return proto.hold.TrackRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hold.TrackRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.TrackRequest.toObject = function(includeInstance, msg) { - var f, obj = { - paymentHash: jspb.Message.getFieldWithDefault(msg, 1, "") - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.TrackRequest} - */ -proto.hold.TrackRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.TrackRequest; - return proto.hold.TrackRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hold.TrackRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.TrackRequest} - */ -proto.hold.TrackRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setPaymentHash(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hold.TrackRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hold.TrackRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hold.TrackRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.TrackRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getPaymentHash(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } -}; - - -/** - * optional string payment_hash = 1; - * @return {string} - */ -proto.hold.TrackRequest.prototype.getPaymentHash = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hold.TrackRequest} returns this - */ -proto.hold.TrackRequest.prototype.setPaymentHash = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hold.TrackResponse.prototype.toObject = function(opt_includeInstance) { - return proto.hold.TrackResponse.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hold.TrackResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.TrackResponse.toObject = function(includeInstance, msg) { - var f, obj = { - state: jspb.Message.getFieldWithDefault(msg, 1, 0) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.TrackResponse} - */ -proto.hold.TrackResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.TrackResponse; - return proto.hold.TrackResponse.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hold.TrackResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.TrackResponse} - */ -proto.hold.TrackResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {!proto.hold.InvoiceState} */ (reader.readEnum()); - msg.setState(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hold.TrackResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hold.TrackResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hold.TrackResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.TrackResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getState(); - if (f !== 0.0) { - writer.writeEnum( - 1, - f - ); - } -}; - - -/** - * optional InvoiceState state = 1; - * @return {!proto.hold.InvoiceState} - */ -proto.hold.TrackResponse.prototype.getState = function() { - return /** @type {!proto.hold.InvoiceState} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); -}; - - -/** - * @param {!proto.hold.InvoiceState} value - * @return {!proto.hold.TrackResponse} returns this - */ -proto.hold.TrackResponse.prototype.setState = function(value) { - return jspb.Message.setProto3EnumField(this, 1, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hold.TrackAllRequest.prototype.toObject = function(opt_includeInstance) { - return proto.hold.TrackAllRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hold.TrackAllRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.TrackAllRequest.toObject = function(includeInstance, msg) { - var f, obj = { - - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.TrackAllRequest} - */ -proto.hold.TrackAllRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.TrackAllRequest; - return proto.hold.TrackAllRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hold.TrackAllRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.TrackAllRequest} - */ -proto.hold.TrackAllRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hold.TrackAllRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hold.TrackAllRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hold.TrackAllRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.TrackAllRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hold.TrackAllResponse.prototype.toObject = function(opt_includeInstance) { - return proto.hold.TrackAllResponse.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hold.TrackAllResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.TrackAllResponse.toObject = function(includeInstance, msg) { - var f, obj = { - paymentHash: jspb.Message.getFieldWithDefault(msg, 1, ""), - bolt11: jspb.Message.getFieldWithDefault(msg, 2, ""), - state: jspb.Message.getFieldWithDefault(msg, 3, 0) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.TrackAllResponse} - */ -proto.hold.TrackAllResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.TrackAllResponse; - return proto.hold.TrackAllResponse.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hold.TrackAllResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.TrackAllResponse} - */ -proto.hold.TrackAllResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setPaymentHash(value); - break; - case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setBolt11(value); - break; - case 3: - var value = /** @type {!proto.hold.InvoiceState} */ (reader.readEnum()); - msg.setState(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hold.TrackAllResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hold.TrackAllResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hold.TrackAllResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.TrackAllResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getPaymentHash(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } - f = message.getBolt11(); - if (f.length > 0) { - writer.writeString( - 2, - f - ); - } - f = message.getState(); - if (f !== 0.0) { - writer.writeEnum( - 3, - f - ); - } -}; - - -/** - * optional string payment_hash = 1; - * @return {string} - */ -proto.hold.TrackAllResponse.prototype.getPaymentHash = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hold.TrackAllResponse} returns this - */ -proto.hold.TrackAllResponse.prototype.setPaymentHash = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * optional string bolt11 = 2; - * @return {string} - */ -proto.hold.TrackAllResponse.prototype.getBolt11 = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hold.TrackAllResponse} returns this - */ -proto.hold.TrackAllResponse.prototype.setBolt11 = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); -}; - - -/** - * optional InvoiceState state = 3; - * @return {!proto.hold.InvoiceState} - */ -proto.hold.TrackAllResponse.prototype.getState = function() { - return /** @type {!proto.hold.InvoiceState} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); -}; - - -/** - * @param {!proto.hold.InvoiceState} value - * @return {!proto.hold.TrackAllResponse} returns this - */ -proto.hold.TrackAllResponse.prototype.setState = function(value) { - return jspb.Message.setProto3EnumField(this, 3, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hold.PayStatusRequest.prototype.toObject = function(opt_includeInstance) { - return proto.hold.PayStatusRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hold.PayStatusRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.PayStatusRequest.toObject = function(includeInstance, msg) { - var f, obj = { - bolt11: jspb.Message.getFieldWithDefault(msg, 1, "") - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.PayStatusRequest} - */ -proto.hold.PayStatusRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.PayStatusRequest; - return proto.hold.PayStatusRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hold.PayStatusRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.PayStatusRequest} - */ -proto.hold.PayStatusRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setBolt11(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hold.PayStatusRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hold.PayStatusRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hold.PayStatusRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.PayStatusRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = /** @type {string} */ (jspb.Message.getField(message, 1)); - if (f != null) { - writer.writeString( - 1, - f - ); - } -}; - - -/** - * optional string bolt11 = 1; - * @return {string} - */ -proto.hold.PayStatusRequest.prototype.getBolt11 = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hold.PayStatusRequest} returns this - */ -proto.hold.PayStatusRequest.prototype.setBolt11 = function(value) { - return jspb.Message.setField(this, 1, value); -}; - - -/** - * Clears the field making it undefined. - * @return {!proto.hold.PayStatusRequest} returns this - */ -proto.hold.PayStatusRequest.prototype.clearBolt11 = function() { - return jspb.Message.setField(this, 1, undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.hold.PayStatusRequest.prototype.hasBolt11 = function() { - return jspb.Message.getField(this, 1) != null; -}; - - - -/** - * List of repeated fields within this message type. - * @private {!Array} - * @const - */ -proto.hold.PayStatusResponse.repeatedFields_ = [1]; - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hold.PayStatusResponse.prototype.toObject = function(opt_includeInstance) { - return proto.hold.PayStatusResponse.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hold.PayStatusResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.PayStatusResponse.toObject = function(includeInstance, msg) { - var f, obj = { - statusList: jspb.Message.toObjectList(msg.getStatusList(), - proto.hold.PayStatusResponse.PayStatus.toObject, includeInstance) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.PayStatusResponse} - */ -proto.hold.PayStatusResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.PayStatusResponse; - return proto.hold.PayStatusResponse.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hold.PayStatusResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.PayStatusResponse} - */ -proto.hold.PayStatusResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.hold.PayStatusResponse.PayStatus; - reader.readMessage(value,proto.hold.PayStatusResponse.PayStatus.deserializeBinaryFromReader); - msg.addStatus(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hold.PayStatusResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hold.PayStatusResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hold.PayStatusResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.PayStatusResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getStatusList(); - if (f.length > 0) { - writer.writeRepeatedMessage( - 1, - f, - proto.hold.PayStatusResponse.PayStatus.serializeBinaryToWriter - ); - } -}; - - - -/** - * List of repeated fields within this message type. - * @private {!Array} - * @const - */ -proto.hold.PayStatusResponse.PayStatus.repeatedFields_ = [4]; - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hold.PayStatusResponse.PayStatus.prototype.toObject = function(opt_includeInstance) { - return proto.hold.PayStatusResponse.PayStatus.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hold.PayStatusResponse.PayStatus} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.PayStatusResponse.PayStatus.toObject = function(includeInstance, msg) { - var f, obj = { - bolt11: jspb.Message.getFieldWithDefault(msg, 1, ""), - amountMsat: jspb.Message.getFieldWithDefault(msg, 2, 0), - destination: jspb.Message.getFieldWithDefault(msg, 3, ""), - attemptsList: jspb.Message.toObjectList(msg.getAttemptsList(), - proto.hold.PayStatusResponse.PayStatus.Attempt.toObject, includeInstance) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.PayStatusResponse.PayStatus} - */ -proto.hold.PayStatusResponse.PayStatus.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.PayStatusResponse.PayStatus; - return proto.hold.PayStatusResponse.PayStatus.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hold.PayStatusResponse.PayStatus} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.PayStatusResponse.PayStatus} - */ -proto.hold.PayStatusResponse.PayStatus.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setBolt11(value); - break; - case 2: - var value = /** @type {number} */ (reader.readUint64()); - msg.setAmountMsat(value); - break; - case 3: - var value = /** @type {string} */ (reader.readString()); - msg.setDestination(value); - break; - case 4: - var value = new proto.hold.PayStatusResponse.PayStatus.Attempt; - reader.readMessage(value,proto.hold.PayStatusResponse.PayStatus.Attempt.deserializeBinaryFromReader); - msg.addAttempts(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hold.PayStatusResponse.PayStatus.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hold.PayStatusResponse.PayStatus.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hold.PayStatusResponse.PayStatus} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.PayStatusResponse.PayStatus.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getBolt11(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } - f = message.getAmountMsat(); - if (f !== 0) { - writer.writeUint64( - 2, - f - ); - } - f = message.getDestination(); - if (f.length > 0) { - writer.writeString( - 3, - f - ); - } - f = message.getAttemptsList(); - if (f.length > 0) { - writer.writeRepeatedMessage( - 4, - f, - proto.hold.PayStatusResponse.PayStatus.Attempt.serializeBinaryToWriter - ); - } -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.toObject = function(opt_includeInstance) { - return proto.hold.PayStatusResponse.PayStatus.Attempt.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hold.PayStatusResponse.PayStatus.Attempt} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.toObject = function(includeInstance, msg) { - var f, obj = { - strategy: jspb.Message.getFieldWithDefault(msg, 1, ""), - startTime: jspb.Message.getFieldWithDefault(msg, 2, 0), - ageInSeconds: jspb.Message.getFieldWithDefault(msg, 3, 0), - endTime: jspb.Message.getFieldWithDefault(msg, 4, 0), - state: jspb.Message.getFieldWithDefault(msg, 5, 0), - success: (f = msg.getSuccess()) && proto.hold.PayStatusResponse.PayStatus.Attempt.Success.toObject(includeInstance, f), - failure: (f = msg.getFailure()) && proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.toObject(includeInstance, f) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.PayStatusResponse.PayStatus.Attempt; - return proto.hold.PayStatusResponse.PayStatus.Attempt.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hold.PayStatusResponse.PayStatus.Attempt} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setStrategy(value); - break; - case 2: - var value = /** @type {number} */ (reader.readUint64()); - msg.setStartTime(value); - break; - case 3: - var value = /** @type {number} */ (reader.readUint64()); - msg.setAgeInSeconds(value); - break; - case 4: - var value = /** @type {number} */ (reader.readUint64()); - msg.setEndTime(value); - break; - case 5: - var value = /** @type {!proto.hold.PayStatusResponse.PayStatus.Attempt.AttemptState} */ (reader.readEnum()); - msg.setState(value); - break; - case 6: - var value = new proto.hold.PayStatusResponse.PayStatus.Attempt.Success; - reader.readMessage(value,proto.hold.PayStatusResponse.PayStatus.Attempt.Success.deserializeBinaryFromReader); - msg.setSuccess(value); - break; - case 7: - var value = new proto.hold.PayStatusResponse.PayStatus.Attempt.Failure; - reader.readMessage(value,proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.deserializeBinaryFromReader); - msg.setFailure(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hold.PayStatusResponse.PayStatus.Attempt.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hold.PayStatusResponse.PayStatus.Attempt} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getStrategy(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } - f = message.getStartTime(); - if (f !== 0) { - writer.writeUint64( - 2, - f - ); - } - f = message.getAgeInSeconds(); - if (f !== 0) { - writer.writeUint64( - 3, - f - ); - } - f = /** @type {number} */ (jspb.Message.getField(message, 4)); - if (f != null) { - writer.writeUint64( - 4, - f - ); - } - f = message.getState(); - if (f !== 0.0) { - writer.writeEnum( - 5, - f - ); - } - f = message.getSuccess(); - if (f != null) { - writer.writeMessage( - 6, - f, - proto.hold.PayStatusResponse.PayStatus.Attempt.Success.serializeBinaryToWriter - ); - } - f = message.getFailure(); - if (f != null) { - writer.writeMessage( - 7, - f, - proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.serializeBinaryToWriter - ); - } -}; - - -/** - * @enum {number} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.AttemptState = { - ATTEMPT_PENDING: 0, - ATTEMPT_COMPLETED: 1 -}; - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Success.prototype.toObject = function(opt_includeInstance) { - return proto.hold.PayStatusResponse.PayStatus.Attempt.Success.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hold.PayStatusResponse.PayStatus.Attempt.Success} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Success.toObject = function(includeInstance, msg) { - var f, obj = { - id: jspb.Message.getFieldWithDefault(msg, 1, 0), - paymentPreimage: jspb.Message.getFieldWithDefault(msg, 2, "") - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.Success} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Success.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.PayStatusResponse.PayStatus.Attempt.Success; - return proto.hold.PayStatusResponse.PayStatus.Attempt.Success.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hold.PayStatusResponse.PayStatus.Attempt.Success} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.Success} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Success.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {number} */ (reader.readUint64()); - msg.setId(value); - break; - case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setPaymentPreimage(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Success.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hold.PayStatusResponse.PayStatus.Attempt.Success.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hold.PayStatusResponse.PayStatus.Attempt.Success} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Success.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getId(); - if (f !== 0) { - writer.writeUint64( - 1, - f - ); - } - f = message.getPaymentPreimage(); - if (f.length > 0) { - writer.writeString( - 2, - f - ); - } -}; - - -/** - * optional uint64 id = 1; - * @return {number} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Success.prototype.getId = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.Success} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Success.prototype.setId = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); -}; - - -/** - * optional string payment_preimage = 2; - * @return {string} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Success.prototype.getPaymentPreimage = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.Success} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Success.prototype.setPaymentPreimage = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.prototype.toObject = function(opt_includeInstance) { - return proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.toObject = function(includeInstance, msg) { - var f, obj = { - message: jspb.Message.getFieldWithDefault(msg, 1, ""), - code: jspb.Message.getFieldWithDefault(msg, 2, 0), - data: (f = msg.getData()) && proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.toObject(includeInstance, f) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.PayStatusResponse.PayStatus.Attempt.Failure; - return proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setMessage(value); - break; - case 2: - var value = /** @type {number} */ (reader.readUint64()); - msg.setCode(value); - break; - case 3: - var value = new proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data; - reader.readMessage(value,proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.deserializeBinaryFromReader); - msg.setData(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getMessage(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } - f = message.getCode(); - if (f !== 0) { - writer.writeUint64( - 2, - f - ); - } - f = message.getData(); - if (f != null) { - writer.writeMessage( - 3, - f, - proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.serializeBinaryToWriter - ); - } -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.prototype.toObject = function(opt_includeInstance) { - return proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.toObject = function(includeInstance, msg) { - var f, obj = { - id: jspb.Message.getFieldWithDefault(msg, 1, 0), - rawMessage: jspb.Message.getFieldWithDefault(msg, 2, ""), - failCode: jspb.Message.getFieldWithDefault(msg, 3, 0), - failCodename: jspb.Message.getFieldWithDefault(msg, 4, ""), - erringIndex: jspb.Message.getFieldWithDefault(msg, 5, 0), - erringNode: jspb.Message.getFieldWithDefault(msg, 6, "") - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data; - return proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {number} */ (reader.readUint64()); - msg.setId(value); - break; - case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setRawMessage(value); - break; - case 3: - var value = /** @type {number} */ (reader.readUint64()); - msg.setFailCode(value); - break; - case 4: - var value = /** @type {string} */ (reader.readString()); - msg.setFailCodename(value); - break; - case 5: - var value = /** @type {number} */ (reader.readUint64()); - msg.setErringIndex(value); - break; - case 6: - var value = /** @type {string} */ (reader.readString()); - msg.setErringNode(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getId(); - if (f !== 0) { - writer.writeUint64( - 1, - f - ); - } - f = message.getRawMessage(); - if (f.length > 0) { - writer.writeString( - 2, - f - ); - } - f = message.getFailCode(); - if (f !== 0) { - writer.writeUint64( - 3, - f - ); - } - f = message.getFailCodename(); - if (f.length > 0) { - writer.writeString( - 4, - f - ); - } - f = message.getErringIndex(); - if (f !== 0) { - writer.writeUint64( - 5, - f - ); - } - f = message.getErringNode(); - if (f.length > 0) { - writer.writeString( - 6, - f - ); - } -}; - - -/** - * optional uint64 id = 1; - * @return {number} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.prototype.getId = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.prototype.setId = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); -}; - - -/** - * optional string raw_message = 2; - * @return {string} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.prototype.getRawMessage = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.prototype.setRawMessage = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); -}; - - -/** - * optional uint64 fail_code = 3; - * @return {number} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.prototype.getFailCode = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.prototype.setFailCode = function(value) { - return jspb.Message.setProto3IntField(this, 3, value); -}; - - -/** - * optional string fail_codename = 4; - * @return {string} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.prototype.getFailCodename = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.prototype.setFailCodename = function(value) { - return jspb.Message.setProto3StringField(this, 4, value); -}; - - -/** - * optional uint64 erring_index = 5; - * @return {number} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.prototype.getErringIndex = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.prototype.setErringIndex = function(value) { - return jspb.Message.setProto3IntField(this, 5, value); -}; - - -/** - * optional string erring_node = 6; - * @return {string} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.prototype.getErringNode = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data.prototype.setErringNode = function(value) { - return jspb.Message.setProto3StringField(this, 6, value); -}; - - -/** - * optional string message = 1; - * @return {string} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.prototype.getMessage = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.prototype.setMessage = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * optional uint64 code = 2; - * @return {number} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.prototype.getCode = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.prototype.setCode = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); -}; - - -/** - * optional Data data = 3; - * @return {?proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.prototype.getData = function() { - return /** @type{?proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data} */ ( - jspb.Message.getWrapperField(this, proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data, 3)); -}; - - -/** - * @param {?proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.Data|undefined} value - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure} returns this -*/ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.prototype.setData = function(value) { - return jspb.Message.setWrapperField(this, 3, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.Failure} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.prototype.clearData = function() { - return this.setData(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.Failure.prototype.hasData = function() { - return jspb.Message.getField(this, 3) != null; -}; - - -/** - * optional string strategy = 1; - * @return {string} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.getStrategy = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.setStrategy = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * optional uint64 start_time = 2; - * @return {number} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.getStartTime = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.setStartTime = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); -}; - - -/** - * optional uint64 age_in_seconds = 3; - * @return {number} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.getAgeInSeconds = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.setAgeInSeconds = function(value) { - return jspb.Message.setProto3IntField(this, 3, value); -}; - - -/** - * optional uint64 end_time = 4; - * @return {number} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.getEndTime = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.setEndTime = function(value) { - return jspb.Message.setField(this, 4, value); -}; - - -/** - * Clears the field making it undefined. - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.clearEndTime = function() { - return jspb.Message.setField(this, 4, undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.hasEndTime = function() { - return jspb.Message.getField(this, 4) != null; -}; - - -/** - * optional AttemptState state = 5; - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt.AttemptState} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.getState = function() { - return /** @type {!proto.hold.PayStatusResponse.PayStatus.Attempt.AttemptState} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); -}; - - -/** - * @param {!proto.hold.PayStatusResponse.PayStatus.Attempt.AttemptState} value - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.setState = function(value) { - return jspb.Message.setProto3EnumField(this, 5, value); -}; - - -/** - * optional Success success = 6; - * @return {?proto.hold.PayStatusResponse.PayStatus.Attempt.Success} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.getSuccess = function() { - return /** @type{?proto.hold.PayStatusResponse.PayStatus.Attempt.Success} */ ( - jspb.Message.getWrapperField(this, proto.hold.PayStatusResponse.PayStatus.Attempt.Success, 6)); -}; - - -/** - * @param {?proto.hold.PayStatusResponse.PayStatus.Attempt.Success|undefined} value - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt} returns this -*/ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.setSuccess = function(value) { - return jspb.Message.setWrapperField(this, 6, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.clearSuccess = function() { - return this.setSuccess(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.hasSuccess = function() { - return jspb.Message.getField(this, 6) != null; -}; - - -/** - * optional Failure failure = 7; - * @return {?proto.hold.PayStatusResponse.PayStatus.Attempt.Failure} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.getFailure = function() { - return /** @type{?proto.hold.PayStatusResponse.PayStatus.Attempt.Failure} */ ( - jspb.Message.getWrapperField(this, proto.hold.PayStatusResponse.PayStatus.Attempt.Failure, 7)); -}; - - -/** - * @param {?proto.hold.PayStatusResponse.PayStatus.Attempt.Failure|undefined} value - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt} returns this -*/ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.setFailure = function(value) { - return jspb.Message.setWrapperField(this, 7, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt} returns this - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.clearFailure = function() { - return this.setFailure(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.hold.PayStatusResponse.PayStatus.Attempt.prototype.hasFailure = function() { - return jspb.Message.getField(this, 7) != null; -}; - - -/** - * optional string bolt11 = 1; - * @return {string} - */ -proto.hold.PayStatusResponse.PayStatus.prototype.getBolt11 = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hold.PayStatusResponse.PayStatus} returns this - */ -proto.hold.PayStatusResponse.PayStatus.prototype.setBolt11 = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * optional uint64 amount_msat = 2; - * @return {number} - */ -proto.hold.PayStatusResponse.PayStatus.prototype.getAmountMsat = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); + f + ); + } }; /** - * @param {number} value - * @return {!proto.hold.PayStatusResponse.PayStatus} returns this + * optional bytes payment_hash = 1; + * @return {!(string|Uint8Array)} */ -proto.hold.PayStatusResponse.PayStatus.prototype.setAmountMsat = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); +proto.hold.CancelRequest.prototype.getPaymentHash = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional string destination = 3; + * optional bytes payment_hash = 1; + * This is a type-conversion wrapper around `getPaymentHash()` * @return {string} */ -proto.hold.PayStatusResponse.PayStatus.prototype.getDestination = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +proto.hold.CancelRequest.prototype.getPaymentHash_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getPaymentHash())); }; /** - * @param {string} value - * @return {!proto.hold.PayStatusResponse.PayStatus} returns this + * optional bytes payment_hash = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getPaymentHash()` + * @return {!Uint8Array} */ -proto.hold.PayStatusResponse.PayStatus.prototype.setDestination = function(value) { - return jspb.Message.setProto3StringField(this, 3, value); +proto.hold.CancelRequest.prototype.getPaymentHash_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getPaymentHash())); }; /** - * repeated Attempt attempts = 4; - * @return {!Array} + * @param {!(string|Uint8Array)} value + * @return {!proto.hold.CancelRequest} returns this */ -proto.hold.PayStatusResponse.PayStatus.prototype.getAttemptsList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.hold.PayStatusResponse.PayStatus.Attempt, 4)); +proto.hold.CancelRequest.prototype.setPaymentHash = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; -/** - * @param {!Array} value - * @return {!proto.hold.PayStatusResponse.PayStatus} returns this -*/ -proto.hold.PayStatusResponse.PayStatus.prototype.setAttemptsList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 4, value); -}; + +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * @param {!proto.hold.PayStatusResponse.PayStatus.Attempt=} opt_value - * @param {number=} opt_index - * @return {!proto.hold.PayStatusResponse.PayStatus.Attempt} + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.hold.PayStatusResponse.PayStatus.prototype.addAttempts = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 4, opt_value, proto.hold.PayStatusResponse.PayStatus.Attempt, opt_index); +proto.hold.CancelResponse.prototype.toObject = function(opt_includeInstance) { + return proto.hold.CancelResponse.toObject(opt_includeInstance, this); }; /** - * Clears the list making it empty but non-null. - * @return {!proto.hold.PayStatusResponse.PayStatus} returns this + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.hold.CancelResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.PayStatusResponse.PayStatus.prototype.clearAttemptsList = function() { - return this.setAttemptsList([]); +proto.hold.CancelResponse.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * repeated PayStatus status = 1; - * @return {!Array} + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.hold.CancelResponse} */ -proto.hold.PayStatusResponse.prototype.getStatusList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.hold.PayStatusResponse.PayStatus, 1)); +proto.hold.CancelResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.hold.CancelResponse; + return proto.hold.CancelResponse.deserializeBinaryFromReader(msg, reader); }; /** - * @param {!Array} value - * @return {!proto.hold.PayStatusResponse} returns this -*/ -proto.hold.PayStatusResponse.prototype.setStatusList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 1, value); + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.hold.CancelResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.hold.CancelResponse} + */ +proto.hold.CancelResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; }; /** - * @param {!proto.hold.PayStatusResponse.PayStatus=} opt_value - * @param {number=} opt_index - * @return {!proto.hold.PayStatusResponse.PayStatus} + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} */ -proto.hold.PayStatusResponse.prototype.addStatus = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.hold.PayStatusResponse.PayStatus, opt_index); +proto.hold.CancelResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.hold.CancelResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * Clears the list making it empty but non-null. - * @return {!proto.hold.PayStatusResponse} returns this + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.hold.CancelResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.PayStatusResponse.prototype.clearStatusList = function() { - return this.setStatusList([]); +proto.hold.CancelResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; }; @@ -5689,8 +3504,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.hold.GetRouteRequest.prototype.toObject = function(opt_includeInstance) { - return proto.hold.GetRouteRequest.toObject(opt_includeInstance, this); +proto.hold.TrackRequest.prototype.toObject = function(opt_includeInstance) { + return proto.hold.TrackRequest.toObject(opt_includeInstance, this); }; @@ -5699,18 +3514,13 @@ proto.hold.GetRouteRequest.prototype.toObject = function(opt_includeInstance) { * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.hold.GetRouteRequest} msg The msg instance to transform. + * @param {!proto.hold.TrackRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.GetRouteRequest.toObject = function(includeInstance, msg) { +proto.hold.TrackRequest.toObject = function(includeInstance, msg) { var f, obj = { - destination: jspb.Message.getFieldWithDefault(msg, 1, ""), - amountMsat: jspb.Message.getFieldWithDefault(msg, 2, 0), - maxRetries: jspb.Message.getFieldWithDefault(msg, 3, 0), - riskFactor: jspb.Message.getFieldWithDefault(msg, 4, 0), - maxCltv: jspb.Message.getFieldWithDefault(msg, 5, 0), - finalCltvDelta: jspb.Message.getFieldWithDefault(msg, 6, 0) + paymentHash: msg.getPaymentHash_asB64() }; if (includeInstance) { @@ -5724,23 +3534,23 @@ proto.hold.GetRouteRequest.toObject = function(includeInstance, msg) { /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.GetRouteRequest} + * @return {!proto.hold.TrackRequest} */ -proto.hold.GetRouteRequest.deserializeBinary = function(bytes) { +proto.hold.TrackRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.GetRouteRequest; - return proto.hold.GetRouteRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.hold.TrackRequest; + return proto.hold.TrackRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.hold.GetRouteRequest} msg The message object to deserialize into. + * @param {!proto.hold.TrackRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.GetRouteRequest} + * @return {!proto.hold.TrackRequest} */ -proto.hold.GetRouteRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.hold.TrackRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -5748,28 +3558,8 @@ proto.hold.GetRouteRequest.deserializeBinaryFromReader = function(msg, reader) { var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setDestination(value); - break; - case 2: - var value = /** @type {number} */ (reader.readUint64()); - msg.setAmountMsat(value); - break; - case 3: - var value = /** @type {number} */ (reader.readUint32()); - msg.setMaxRetries(value); - break; - case 4: - var value = /** @type {number} */ (reader.readUint32()); - msg.setRiskFactor(value); - break; - case 5: - var value = /** @type {number} */ (reader.readUint64()); - msg.setMaxCltv(value); - break; - case 6: - var value = /** @type {number} */ (reader.readUint64()); - msg.setFinalCltvDelta(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setPaymentHash(value); break; default: reader.skipField(); @@ -5784,9 +3574,9 @@ proto.hold.GetRouteRequest.deserializeBinaryFromReader = function(msg, reader) { * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.hold.GetRouteRequest.prototype.serializeBinary = function() { +proto.hold.TrackRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.hold.GetRouteRequest.serializeBinaryToWriter(this, writer); + proto.hold.TrackRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -5794,227 +3584,195 @@ proto.hold.GetRouteRequest.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.hold.GetRouteRequest} message + * @param {!proto.hold.TrackRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.GetRouteRequest.serializeBinaryToWriter = function(message, writer) { +proto.hold.TrackRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getDestination(); + f = message.getPaymentHash_asU8(); if (f.length > 0) { - writer.writeString( + writer.writeBytes( 1, f ); } - f = message.getAmountMsat(); - if (f !== 0) { - writer.writeUint64( - 2, - f - ); - } - f = message.getMaxRetries(); - if (f !== 0) { - writer.writeUint32( - 3, - f - ); - } - f = /** @type {number} */ (jspb.Message.getField(message, 4)); - if (f != null) { - writer.writeUint32( - 4, - f - ); - } - f = /** @type {number} */ (jspb.Message.getField(message, 5)); - if (f != null) { - writer.writeUint64( - 5, - f - ); - } - f = /** @type {number} */ (jspb.Message.getField(message, 6)); - if (f != null) { - writer.writeUint64( - 6, - f - ); - } -}; - - -/** - * optional string destination = 1; - * @return {string} - */ -proto.hold.GetRouteRequest.prototype.getDestination = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hold.GetRouteRequest} returns this - */ -proto.hold.GetRouteRequest.prototype.setDestination = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * optional uint64 amount_msat = 2; - * @return {number} - */ -proto.hold.GetRouteRequest.prototype.getAmountMsat = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); }; /** - * @param {number} value - * @return {!proto.hold.GetRouteRequest} returns this + * optional bytes payment_hash = 1; + * @return {!(string|Uint8Array)} */ -proto.hold.GetRouteRequest.prototype.setAmountMsat = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); +proto.hold.TrackRequest.prototype.getPaymentHash = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional uint32 max_retries = 3; - * @return {number} + * optional bytes payment_hash = 1; + * This is a type-conversion wrapper around `getPaymentHash()` + * @return {string} */ -proto.hold.GetRouteRequest.prototype.getMaxRetries = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +proto.hold.TrackRequest.prototype.getPaymentHash_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getPaymentHash())); }; /** - * @param {number} value - * @return {!proto.hold.GetRouteRequest} returns this + * optional bytes payment_hash = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getPaymentHash()` + * @return {!Uint8Array} */ -proto.hold.GetRouteRequest.prototype.setMaxRetries = function(value) { - return jspb.Message.setProto3IntField(this, 3, value); +proto.hold.TrackRequest.prototype.getPaymentHash_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getPaymentHash())); }; /** - * optional uint32 risk_factor = 4; - * @return {number} + * @param {!(string|Uint8Array)} value + * @return {!proto.hold.TrackRequest} returns this */ -proto.hold.GetRouteRequest.prototype.getRiskFactor = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +proto.hold.TrackRequest.prototype.setPaymentHash = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; -/** - * @param {number} value - * @return {!proto.hold.GetRouteRequest} returns this - */ -proto.hold.GetRouteRequest.prototype.setRiskFactor = function(value) { - return jspb.Message.setField(this, 4, value); -}; - -/** - * Clears the field making it undefined. - * @return {!proto.hold.GetRouteRequest} returns this - */ -proto.hold.GetRouteRequest.prototype.clearRiskFactor = function() { - return jspb.Message.setField(this, 4, undefined); -}; +if (jspb.Message.GENERATE_TO_OBJECT) { /** - * Returns whether this field is set. - * @return {boolean} + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} */ -proto.hold.GetRouteRequest.prototype.hasRiskFactor = function() { - return jspb.Message.getField(this, 4) != null; +proto.hold.TrackResponse.prototype.toObject = function(opt_includeInstance) { + return proto.hold.TrackResponse.toObject(opt_includeInstance, this); }; /** - * optional uint64 max_cltv = 5; - * @return {number} + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.hold.TrackResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.GetRouteRequest.prototype.getMaxCltv = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); -}; - +proto.hold.TrackResponse.toObject = function(includeInstance, msg) { + var f, obj = { + state: jspb.Message.getFieldWithDefault(msg, 1, 0) + }; -/** - * @param {number} value - * @return {!proto.hold.GetRouteRequest} returns this - */ -proto.hold.GetRouteRequest.prototype.setMaxCltv = function(value) { - return jspb.Message.setField(this, 5, value); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; }; +} /** - * Clears the field making it undefined. - * @return {!proto.hold.GetRouteRequest} returns this + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.hold.TrackResponse} */ -proto.hold.GetRouteRequest.prototype.clearMaxCltv = function() { - return jspb.Message.setField(this, 5, undefined); +proto.hold.TrackResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.hold.TrackResponse; + return proto.hold.TrackResponse.deserializeBinaryFromReader(msg, reader); }; /** - * Returns whether this field is set. - * @return {boolean} + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.hold.TrackResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.hold.TrackResponse} */ -proto.hold.GetRouteRequest.prototype.hasMaxCltv = function() { - return jspb.Message.getField(this, 5) != null; +proto.hold.TrackResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!proto.hold.InvoiceState} */ (reader.readEnum()); + msg.setState(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; }; /** - * optional uint64 final_cltv_delta = 6; - * @return {number} + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} */ -proto.hold.GetRouteRequest.prototype.getFinalCltvDelta = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 6, 0)); +proto.hold.TrackResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.hold.TrackResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); }; /** - * @param {number} value - * @return {!proto.hold.GetRouteRequest} returns this + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.hold.TrackResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.GetRouteRequest.prototype.setFinalCltvDelta = function(value) { - return jspb.Message.setField(this, 6, value); +proto.hold.TrackResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getState(); + if (f !== 0.0) { + writer.writeEnum( + 1, + f + ); + } }; /** - * Clears the field making it undefined. - * @return {!proto.hold.GetRouteRequest} returns this + * optional InvoiceState state = 1; + * @return {!proto.hold.InvoiceState} */ -proto.hold.GetRouteRequest.prototype.clearFinalCltvDelta = function() { - return jspb.Message.setField(this, 6, undefined); +proto.hold.TrackResponse.prototype.getState = function() { + return /** @type {!proto.hold.InvoiceState} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); }; /** - * Returns whether this field is set. - * @return {boolean} + * @param {!proto.hold.InvoiceState} value + * @return {!proto.hold.TrackResponse} returns this */ -proto.hold.GetRouteRequest.prototype.hasFinalCltvDelta = function() { - return jspb.Message.getField(this, 6) != null; +proto.hold.TrackResponse.prototype.setState = function(value) { + return jspb.Message.setProto3EnumField(this, 1, value); }; -/** - * List of repeated fields within this message type. - * @private {!Array} - * @const - */ -proto.hold.GetRouteResponse.repeatedFields_ = [1]; - if (jspb.Message.GENERATE_TO_OBJECT) { @@ -6030,8 +3788,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.hold.GetRouteResponse.prototype.toObject = function(opt_includeInstance) { - return proto.hold.GetRouteResponse.toObject(opt_includeInstance, this); +proto.hold.TrackAllRequest.prototype.toObject = function(opt_includeInstance) { + return proto.hold.TrackAllRequest.toObject(opt_includeInstance, this); }; @@ -6040,15 +3798,13 @@ proto.hold.GetRouteResponse.prototype.toObject = function(opt_includeInstance) { * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.hold.GetRouteResponse} msg The msg instance to transform. + * @param {!proto.hold.TrackAllRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.GetRouteResponse.toObject = function(includeInstance, msg) { +proto.hold.TrackAllRequest.toObject = function(includeInstance, msg) { var f, obj = { - hopsList: jspb.Message.toObjectList(msg.getHopsList(), - proto.hold.GetRouteResponse.Hop.toObject, includeInstance), - feesMsat: jspb.Message.getFieldWithDefault(msg, 2, 0) + }; if (includeInstance) { @@ -6062,38 +3818,29 @@ proto.hold.GetRouteResponse.toObject = function(includeInstance, msg) { /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.GetRouteResponse} + * @return {!proto.hold.TrackAllRequest} */ -proto.hold.GetRouteResponse.deserializeBinary = function(bytes) { +proto.hold.TrackAllRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.GetRouteResponse; - return proto.hold.GetRouteResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.hold.TrackAllRequest; + return proto.hold.TrackAllRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.hold.GetRouteResponse} msg The message object to deserialize into. + * @param {!proto.hold.TrackAllRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.GetRouteResponse} + * @return {!proto.hold.TrackAllRequest} */ -proto.hold.GetRouteResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.hold.TrackAllRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { - case 1: - var value = new proto.hold.GetRouteResponse.Hop; - reader.readMessage(value,proto.hold.GetRouteResponse.Hop.deserializeBinaryFromReader); - msg.addHops(value); - break; - case 2: - var value = /** @type {number} */ (reader.readUint64()); - msg.setFeesMsat(value); - break; default: reader.skipField(); break; @@ -6107,9 +3854,9 @@ proto.hold.GetRouteResponse.deserializeBinaryFromReader = function(msg, reader) * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.hold.GetRouteResponse.prototype.serializeBinary = function() { +proto.hold.TrackAllRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.hold.GetRouteResponse.serializeBinaryToWriter(this, writer); + proto.hold.TrackAllRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -6117,27 +3864,12 @@ proto.hold.GetRouteResponse.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.hold.GetRouteResponse} message + * @param {!proto.hold.TrackAllRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.GetRouteResponse.serializeBinaryToWriter = function(message, writer) { +proto.hold.TrackAllRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getHopsList(); - if (f.length > 0) { - writer.writeRepeatedMessage( - 1, - f, - proto.hold.GetRouteResponse.Hop.serializeBinaryToWriter - ); - } - f = message.getFeesMsat(); - if (f !== 0) { - writer.writeUint64( - 2, - f - ); - } }; @@ -6157,8 +3889,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.hold.GetRouteResponse.Hop.prototype.toObject = function(opt_includeInstance) { - return proto.hold.GetRouteResponse.Hop.toObject(opt_includeInstance, this); +proto.hold.TrackAllResponse.prototype.toObject = function(opt_includeInstance) { + return proto.hold.TrackAllResponse.toObject(opt_includeInstance, this); }; @@ -6167,18 +3899,15 @@ proto.hold.GetRouteResponse.Hop.prototype.toObject = function(opt_includeInstanc * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.hold.GetRouteResponse.Hop} msg The msg instance to transform. + * @param {!proto.hold.TrackAllResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.GetRouteResponse.Hop.toObject = function(includeInstance, msg) { +proto.hold.TrackAllResponse.toObject = function(includeInstance, msg) { var f, obj = { - id: jspb.Message.getFieldWithDefault(msg, 1, ""), - channel: jspb.Message.getFieldWithDefault(msg, 2, ""), - direction: jspb.Message.getFieldWithDefault(msg, 3, 0), - amountMsat: jspb.Message.getFieldWithDefault(msg, 4, 0), - delay: jspb.Message.getFieldWithDefault(msg, 5, 0), - style: jspb.Message.getFieldWithDefault(msg, 6, "") + paymentHash: msg.getPaymentHash_asB64(), + bolt11: jspb.Message.getFieldWithDefault(msg, 2, ""), + state: jspb.Message.getFieldWithDefault(msg, 3, 0) }; if (includeInstance) { @@ -6192,23 +3921,23 @@ proto.hold.GetRouteResponse.Hop.toObject = function(includeInstance, msg) { /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.hold.GetRouteResponse.Hop} + * @return {!proto.hold.TrackAllResponse} */ -proto.hold.GetRouteResponse.Hop.deserializeBinary = function(bytes) { +proto.hold.TrackAllResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.hold.GetRouteResponse.Hop; - return proto.hold.GetRouteResponse.Hop.deserializeBinaryFromReader(msg, reader); + var msg = new proto.hold.TrackAllResponse; + return proto.hold.TrackAllResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.hold.GetRouteResponse.Hop} msg The message object to deserialize into. + * @param {!proto.hold.TrackAllResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.hold.GetRouteResponse.Hop} + * @return {!proto.hold.TrackAllResponse} */ -proto.hold.GetRouteResponse.Hop.deserializeBinaryFromReader = function(msg, reader) { +proto.hold.TrackAllResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -6216,28 +3945,16 @@ proto.hold.GetRouteResponse.Hop.deserializeBinaryFromReader = function(msg, read var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setId(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setPaymentHash(value); break; case 2: var value = /** @type {string} */ (reader.readString()); - msg.setChannel(value); + msg.setBolt11(value); break; case 3: - var value = /** @type {number} */ (reader.readUint32()); - msg.setDirection(value); - break; - case 4: - var value = /** @type {number} */ (reader.readUint64()); - msg.setAmountMsat(value); - break; - case 5: - var value = /** @type {number} */ (reader.readUint64()); - msg.setDelay(value); - break; - case 6: - var value = /** @type {string} */ (reader.readString()); - msg.setStyle(value); + var value = /** @type {!proto.hold.InvoiceState} */ (reader.readEnum()); + msg.setState(value); break; default: reader.skipField(); @@ -6252,9 +3969,9 @@ proto.hold.GetRouteResponse.Hop.deserializeBinaryFromReader = function(msg, read * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.hold.GetRouteResponse.Hop.prototype.serializeBinary = function() { +proto.hold.TrackAllResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.hold.GetRouteResponse.Hop.serializeBinaryToWriter(this, writer); + proto.hold.TrackAllResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -6262,218 +3979,111 @@ proto.hold.GetRouteResponse.Hop.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.hold.GetRouteResponse.Hop} message + * @param {!proto.hold.TrackAllResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.hold.GetRouteResponse.Hop.serializeBinaryToWriter = function(message, writer) { +proto.hold.TrackAllResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getId(); + f = message.getPaymentHash_asU8(); if (f.length > 0) { - writer.writeString( + writer.writeBytes( 1, f ); } - f = message.getChannel(); + f = message.getBolt11(); if (f.length > 0) { writer.writeString( 2, f ); } - f = message.getDirection(); - if (f !== 0) { - writer.writeUint32( + f = message.getState(); + if (f !== 0.0) { + writer.writeEnum( 3, f ); } - f = message.getAmountMsat(); - if (f !== 0) { - writer.writeUint64( - 4, - f - ); - } - f = message.getDelay(); - if (f !== 0) { - writer.writeUint64( - 5, - f - ); - } - f = message.getStyle(); - if (f.length > 0) { - writer.writeString( - 6, - f - ); - } -}; - - -/** - * optional string id = 1; - * @return {string} - */ -proto.hold.GetRouteResponse.Hop.prototype.getId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * @param {string} value - * @return {!proto.hold.GetRouteResponse.Hop} returns this + * optional bytes payment_hash = 1; + * @return {!(string|Uint8Array)} */ -proto.hold.GetRouteResponse.Hop.prototype.setId = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); +proto.hold.TrackAllResponse.prototype.getPaymentHash = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; /** - * optional string channel = 2; + * optional bytes payment_hash = 1; + * This is a type-conversion wrapper around `getPaymentHash()` * @return {string} */ -proto.hold.GetRouteResponse.Hop.prototype.getChannel = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); -}; - - -/** - * @param {string} value - * @return {!proto.hold.GetRouteResponse.Hop} returns this - */ -proto.hold.GetRouteResponse.Hop.prototype.setChannel = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); -}; - - -/** - * optional uint32 direction = 3; - * @return {number} - */ -proto.hold.GetRouteResponse.Hop.prototype.getDirection = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.hold.GetRouteResponse.Hop} returns this - */ -proto.hold.GetRouteResponse.Hop.prototype.setDirection = function(value) { - return jspb.Message.setProto3IntField(this, 3, value); -}; - - -/** - * optional uint64 amount_msat = 4; - * @return {number} - */ -proto.hold.GetRouteResponse.Hop.prototype.getAmountMsat = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.hold.GetRouteResponse.Hop} returns this - */ -proto.hold.GetRouteResponse.Hop.prototype.setAmountMsat = function(value) { - return jspb.Message.setProto3IntField(this, 4, value); +proto.hold.TrackAllResponse.prototype.getPaymentHash_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getPaymentHash())); }; /** - * optional uint64 delay = 5; - * @return {number} + * optional bytes payment_hash = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getPaymentHash()` + * @return {!Uint8Array} */ -proto.hold.GetRouteResponse.Hop.prototype.getDelay = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); +proto.hold.TrackAllResponse.prototype.getPaymentHash_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getPaymentHash())); }; /** - * @param {number} value - * @return {!proto.hold.GetRouteResponse.Hop} returns this + * @param {!(string|Uint8Array)} value + * @return {!proto.hold.TrackAllResponse} returns this */ -proto.hold.GetRouteResponse.Hop.prototype.setDelay = function(value) { - return jspb.Message.setProto3IntField(this, 5, value); +proto.hold.TrackAllResponse.prototype.setPaymentHash = function(value) { + return jspb.Message.setProto3BytesField(this, 1, value); }; /** - * optional string style = 6; + * optional string bolt11 = 2; * @return {string} */ -proto.hold.GetRouteResponse.Hop.prototype.getStyle = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "")); +proto.hold.TrackAllResponse.prototype.getBolt11 = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); }; /** * @param {string} value - * @return {!proto.hold.GetRouteResponse.Hop} returns this - */ -proto.hold.GetRouteResponse.Hop.prototype.setStyle = function(value) { - return jspb.Message.setProto3StringField(this, 6, value); -}; - - -/** - * repeated Hop hops = 1; - * @return {!Array} - */ -proto.hold.GetRouteResponse.prototype.getHopsList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.hold.GetRouteResponse.Hop, 1)); -}; - - -/** - * @param {!Array} value - * @return {!proto.hold.GetRouteResponse} returns this -*/ -proto.hold.GetRouteResponse.prototype.setHopsList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 1, value); -}; - - -/** - * @param {!proto.hold.GetRouteResponse.Hop=} opt_value - * @param {number=} opt_index - * @return {!proto.hold.GetRouteResponse.Hop} - */ -proto.hold.GetRouteResponse.prototype.addHops = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.hold.GetRouteResponse.Hop, opt_index); -}; - - -/** - * Clears the list making it empty but non-null. - * @return {!proto.hold.GetRouteResponse} returns this + * @return {!proto.hold.TrackAllResponse} returns this */ -proto.hold.GetRouteResponse.prototype.clearHopsList = function() { - return this.setHopsList([]); +proto.hold.TrackAllResponse.prototype.setBolt11 = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); }; /** - * optional uint64 fees_msat = 2; - * @return {number} + * optional InvoiceState state = 3; + * @return {!proto.hold.InvoiceState} */ -proto.hold.GetRouteResponse.prototype.getFeesMsat = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +proto.hold.TrackAllResponse.prototype.getState = function() { + return /** @type {!proto.hold.InvoiceState} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); }; /** - * @param {number} value - * @return {!proto.hold.GetRouteResponse} returns this + * @param {!proto.hold.InvoiceState} value + * @return {!proto.hold.TrackAllResponse} returns this */ -proto.hold.GetRouteResponse.prototype.setFeesMsat = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); +proto.hold.TrackAllResponse.prototype.setState = function(value) { + return jspb.Message.setProto3EnumField(this, 3, value); }; @@ -6481,19 +4091,10 @@ proto.hold.GetRouteResponse.prototype.setFeesMsat = function(value) { * @enum {number} */ proto.hold.InvoiceState = { - INVOICE_UNPAID: 0, - INVOICE_ACCEPTED: 1, - INVOICE_PAID: 2, - INVOICE_CANCELLED: 3 -}; - -/** - * @enum {number} - */ -proto.hold.HtlcState = { - HTLC_ACCEPTED: 0, - HTLC_SETTLED: 1, - HTLC_CANCELLED: 2 + UNPAID: 0, + ACCEPTED: 1, + PAID: 2, + CANCELLED: 3 }; goog.object.extend(exports, proto.hold); diff --git a/proto/hold/hold.proto b/proto/hold/hold.proto new file mode 100644 index 00000000..4a80d071 --- /dev/null +++ b/proto/hold/hold.proto @@ -0,0 +1,119 @@ +syntax = "proto3"; + +package hold; + +service Hold { + rpc GetInfo (GetInfoRequest) returns (GetInfoResponse); + + rpc Invoice (InvoiceRequest) returns (InvoiceResponse) {} + + rpc List (ListRequest) returns (ListResponse) {} + + rpc Settle (SettleRequest) returns (SettleResponse) {} + rpc Cancel (CancelRequest) returns (CancelResponse) {} + + rpc Track (TrackRequest) returns (stream TrackResponse) {} + rpc TrackAll (TrackAllRequest) returns (stream TrackAllResponse) {} +} + +message GetInfoRequest {} +message GetInfoResponse { + string version = 1; +} + +message Hop { + bytes public_key = 1; + uint64 short_channel_id = 2; + uint64 base_fee = 3; + uint64 ppm_fee = 4; + uint64 cltv_expiry_delta = 5; +} + +message RoutingHint { + repeated Hop hops = 1; +} + +message InvoiceRequest { + bytes payment_hash = 1; + uint64 amount_msat = 2; + + oneof description { + string memo = 3; + bytes hash = 4; + } + + optional uint64 expiry = 5; + optional uint64 min_final_cltv_expiry = 6; + repeated RoutingHint routing_hints = 7; +} +message InvoiceResponse { + string bolt11 = 1; +} + +message ListRequest { + message Pagination { + // Inclusive + int64 index_start = 1; + uint64 limit = 2; + } + + oneof constraint { + bytes payment_hash = 1; + Pagination pagination = 2; + } +} + +enum InvoiceState { + UNPAID = 0; + ACCEPTED = 1; + PAID = 2; + CANCELLED = 3; +} + +message Htlc { + int64 id = 1; + InvoiceState state = 2; + string scid = 3; + uint64 channel_id = 4; + uint64 msat = 5; + uint64 created_at = 6; +} + +message Invoice { + int64 id = 1; + bytes payment_hash = 2; + optional bytes preimage = 3; + string bolt11 = 4; + InvoiceState state = 5; + uint64 created_at = 6; + repeated Htlc htlcs = 7; +} + +message ListResponse { + repeated Invoice invoices = 1; +} + +message SettleRequest { + bytes payment_preimage = 1; +} +message SettleResponse {} + +message CancelRequest { + bytes payment_hash = 1; +} +message CancelResponse {} + +message TrackRequest { + bytes payment_hash = 1; +} + +message TrackResponse { + InvoiceState state = 1; +} + +message TrackAllRequest {} +message TrackAllResponse { + bytes payment_hash = 1; + string bolt11 = 2; + InvoiceState state = 3; +} diff --git a/protos.js b/protos.js index b8717ee7..f81e0188 100644 --- a/protos.js +++ b/protos.js @@ -2,7 +2,6 @@ const path = require('path'); const childProcess = require('child_process'); const protoDir = path.join(__dirname, 'proto'); -const protoDirHold = path.join(__dirname, 'tools/plugins/hold/protos'); const protoDirMpay = path.join(__dirname, 'tools/plugins/mpay/protos'); const protoDirSidecar = path.join(__dirname, 'boltzr/protos'); @@ -16,10 +15,6 @@ const protocGenTsPath = path.join(__dirname, 'node_modules/.bin/protoc-gen-ts'); const protoPaths = [ [`--proto_path ${protoDir} ${protoDir}/*.proto`, libDir], [`--proto_path ${protoDir} ${protoDir}/**/*.proto`, libDir], - [ - `--proto_path ${protoDirHold} ${protoDirHold}/*.proto`, - path.join(libDir, 'hold'), - ], [ `--proto_path ${protoDirMpay} ${protoDirMpay}/*.proto`, path.join(libDir, 'mpay'), diff --git a/tools/plugins/hold/__init__.py b/tools/plugins/hold/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tools/plugins/hold/certs.py b/tools/plugins/hold/certs.py deleted file mode 100644 index d07b06ca..00000000 --- a/tools/plugins/hold/certs.py +++ /dev/null @@ -1,97 +0,0 @@ -import datetime -from dataclasses import dataclass -from pathlib import Path - -from cryptography import x509 -from cryptography.hazmat.primitives import hashes, serialization -from cryptography.hazmat.primitives.asymmetric import ec -from cryptography.hazmat.primitives.asymmetric.ec import ( - SECP256R1, -) -from cryptography.x509.oid import NameOID - -from plugins.hold.utils import time_now - - -@dataclass -class Certificate: - key: bytes - cert: bytes - - -def load_certs(name: str, base_path: str) -> tuple[Certificate, Certificate]: - Path(base_path).mkdir(exist_ok=True) - - ca_cert = get_cert(name, base_path, "ca") - server_cert = get_cert(name, base_path, "server", ca_cert.key) - get_cert(name, base_path, "client", ca_cert.key) - - return ca_cert, server_cert - - -def get_cert(subject: str, base_path: str, name: str, ca_key: bytes | None = None) -> Certificate: - def get_path(file_name: str) -> str: - return str(Path(base_path).joinpath(Path(file_name))) - - cert_path = f"{get_path(name)}.pem" - key_path = f"{get_path(name)}-key.pem" - - if all(Path.exists(Path(path)) for path in [cert_path, key_path]): - return Certificate( - key=Path.read_bytes(Path(key_path)), - cert=Path.read_bytes(Path(cert_path)), - ) - - key = ec.generate_private_key(curve=SECP256R1()) - - is_ca = ca_key is None - - subject_prefix = subject.upper() - issuer_name = create_cert_name(f"{subject_prefix} Root CA") - - cert = ( - x509.CertificateBuilder() - .subject_name(issuer_name if is_ca else create_cert_name(f"{subject_prefix} {name}")) - .issuer_name(issuer_name) - .public_key(key.public_key()) - .serial_number(x509.random_serial_number()) - .not_valid_before(time_now()) - .not_valid_after(time_now() + datetime.timedelta(weeks=52 * 10)) - .add_extension( - x509.SubjectAlternativeName([x509.DNSName(name) for name in [subject, "localhost"]]), - critical=False, - ) - ) - - if is_ca: - cert = cert.add_extension(x509.BasicConstraints(ca=True, path_length=None), critical=True) - - cert = cert.sign( - serialization.load_pem_private_key(ca_key, password=None) if not is_ca else key, - hashes.SHA256(), - ) - - key_bytes = key.private_bytes( - encoding=serialization.Encoding.PEM, - format=serialization.PrivateFormat.TraditionalOpenSSL, - encryption_algorithm=serialization.NoEncryption(), - ) - cert_bytes = cert.public_bytes(serialization.Encoding.PEM) - - for file_path, content in [(cert_path, cert_bytes), (key_path, key_bytes)]: - write_bytes(file_path, content) - - return Certificate(key=key_bytes, cert=cert_bytes) - - -def create_cert_name(common_name: str) -> x509.Name: - return x509.Name( - [ - x509.NameAttribute(NameOID.COMMON_NAME, common_name), - ] - ) - - -def write_bytes(name: str, content: bytes) -> None: - with Path.open(Path(name), "b+w") as f: - f.write(content) diff --git a/tools/plugins/hold/config.py b/tools/plugins/hold/config.py deleted file mode 100644 index aa98d8df..00000000 --- a/tools/plugins/hold/config.py +++ /dev/null @@ -1,34 +0,0 @@ -from typing import Any - -from pyln.client import Plugin -from strenum import StrEnum - -from plugins.hold.consts import GRPC_HOST_REGTEST, PLUGIN_NAME, Network - - -class OptionKeys(StrEnum): - GrpcHost = f"{PLUGIN_NAME}-grpc-host" - GrpcPort = f"{PLUGIN_NAME}-grpc-port" - - -class OptionDefaults(StrEnum): - GrpcHost = "127.0.0.1" - GrpcPort = "9292" - - -def register_options(pl: Plugin) -> None: - pl.add_option(OptionKeys.GrpcHost, OptionDefaults.GrpcHost, "hold gRPC host") - pl.add_option(OptionKeys.GrpcPort, OptionDefaults.GrpcPort, "hold gRPC port") - - -class Config: - grpc_host: str - grpc_port: int - - def __init__(self, pl: Plugin, configuration: dict[str, Any]) -> None: - self.grpc_host = ( - configuration[OptionKeys.GrpcHost] - if pl.rpc.getinfo()["network"] != Network.Regtest - else GRPC_HOST_REGTEST - ) - self.grpc_port = int(configuration[OptionKeys.GrpcPort]) diff --git a/tools/plugins/hold/consts.py b/tools/plugins/hold/consts.py deleted file mode 100644 index 80587970..00000000 --- a/tools/plugins/hold/consts.py +++ /dev/null @@ -1,21 +0,0 @@ -from strenum import StrEnum - - -class Network(StrEnum): - Mainnet = "bitcoin" - Testnet = "testnet" - Signet = "signet" - Regtest = "regtest" - - -PLUGIN_NAME = "hold" -VERSION = "0.0.5" - -TIMEOUT_CANCEL = 60 -TIMEOUT_CANCEL_REGTEST = 5 - -TIMEOUT_CHECK_INTERVAL = 10 - -GRPC_HOST_REGTEST = "0.0.0.0" # noqa: S104 - -OVERPAYMENT_FACTOR = 2 diff --git a/tools/plugins/hold/datastore.py b/tools/plugins/hold/datastore.py deleted file mode 100644 index e5f11689..00000000 --- a/tools/plugins/hold/datastore.py +++ /dev/null @@ -1,85 +0,0 @@ -from enum import Enum -from typing import Any - -from pyln.client import Plugin, RpcError - -from plugins.hold.consts import PLUGIN_NAME -from plugins.hold.invoice import HoldInvoice -from plugins.hold.settler import Settler - - -class DataErrorCodes(int, Enum): - KeyDoesNotExist = 1200 - KeyExists = 1202 - - -class DataStore: - _plugin: Plugin - _settler: Settler - _invoices_key = "invoices" - - def __init__(self, plugin: Plugin, settler: Settler) -> None: - self._plugin = plugin - self._settler = settler - - def save_invoice(self, invoice: HoldInvoice, mode: str = "must-create") -> None: - self._plugin.rpc.datastore( - key=[PLUGIN_NAME, DataStore._invoices_key, invoice.payment_hash], - string=invoice.to_json(), - mode=mode, - ) - - def list_invoices(self, payment_hash: str | None) -> list[HoldInvoice]: - key = [PLUGIN_NAME, DataStore._invoices_key] - if payment_hash is not None: - key.append(payment_hash) - - return self._parse_invoices( - self._plugin.rpc.listdatastore( - key=key, - ) - ) - - def get_invoice(self, payment_hash: str) -> HoldInvoice | None: - invoices = self.list_invoices(payment_hash) - if len(invoices) == 0: - return None - - return invoices[0] - - def delete_invoice(self, payment_hash: str) -> bool: - try: - self._plugin.rpc.deldatastore( - [PLUGIN_NAME, DataStore._invoices_key, payment_hash], - ) - except RpcError as e: - # noinspection PyTypeChecker - if e.error["code"] == DataErrorCodes.KeyDoesNotExist: - return False - - raise - - return True - - def settle_invoice(self, invoice: HoldInvoice, preimage: str) -> None: - # TODO: save in the normal invoice table of CLN - invoice.payment_preimage = preimage - self._settler.settle(invoice) - self.save_invoice(invoice, mode="must-replace") - - def cancel_invoice(self, invoice: HoldInvoice) -> None: - self._settler.cancel(invoice) - self.save_invoice(invoice, mode="must-replace") - - def delete_invoices(self) -> int: - key = [PLUGIN_NAME, DataStore._invoices_key] - invoices = self._plugin.rpc.listdatastore(key=key)["datastore"] - for invoice in invoices: - # TODO: also cancel? - self._plugin.rpc.deldatastore(invoice["key"]) - - return len(invoices) - - @staticmethod - def _parse_invoices(data: dict[str, Any]) -> list[HoldInvoice]: - return [HoldInvoice.from_json(i["string"]) for i in data["datastore"]] diff --git a/tools/plugins/hold/encoder.py b/tools/plugins/hold/encoder.py deleted file mode 100644 index 61726c9c..00000000 --- a/tools/plugins/hold/encoder.py +++ /dev/null @@ -1,108 +0,0 @@ -import random -from enum import Enum - -from bolt11 import Bolt11, Feature, Features, FeatureState, encode -from bolt11.models.tags import Tag -from bolt11.types import MilliSatoshi, RouteHint, TagChar, Tags -from pyln.client import Plugin -from secp256k1 import PrivateKey - -from plugins.hold.consts import Network -from plugins.hold.utils import time_now - -NETWORK_PREFIXES = { - Network.Mainnet: "bc", - Network.Testnet: "tb", - Network.Signet: "tbs", - Network.Regtest: "bcrt", -} - - -class Defaults(int, Enum): - Expiry = 3600 - MinFinalCltvExpiry = 80 - - -def get_network_prefix(network: str) -> str: - # noinspection PyTypeChecker - return ( - NETWORK_PREFIXES[network] - if network in NETWORK_PREFIXES - else NETWORK_PREFIXES[Network.Mainnet] - ) - - -def get_payment_secret(val: str | None) -> str: - return val if val is not None else random.randbytes(32).hex() - - -class Encoder: - _pl: Plugin - _prefix: str - _features: Features - - # Random key to make the bolt11 library work; - # the node signs the invoice again with its key - _key = PrivateKey().serialize() - - def __init__(self, pl: Plugin) -> None: - self._pl = pl - - def init(self) -> None: - info = self._pl.rpc.getinfo() - self._prefix = get_network_prefix(info["network"]) - - # TODO: parse from CLN - self._features = Features.from_feature_list( - { - Feature.var_onion_optin: FeatureState.required, - Feature.payment_secret: FeatureState.required, - Feature.basic_mpp: FeatureState.supported, - Feature.option_route_blinding: FeatureState.supported, - } - ) - - def encode( - self, - payment_hash: str, - amount_msat: int, - description: str | None = None, - description_hash: str | None = None, - expiry: int = Defaults.Expiry, - min_final_cltv_expiry: int = Defaults.MinFinalCltvExpiry, - payment_secret: str | None = None, - route_hints: list[RouteHint] | None = None, - ) -> str: - tags = Tags( - [ - Tag(TagChar.payment_hash, payment_hash), - Tag(TagChar.expire_time, expiry), - Tag(TagChar.min_final_cltv_expiry, min_final_cltv_expiry), - Tag(TagChar.payment_secret, get_payment_secret(payment_secret)), - Tag(TagChar.features, self._features), - ] - ) - - if route_hints is not None: - tags.tags.extend([Tag(TagChar.route_hint, route) for route in route_hints]) - - if description_hash is not None and description_hash != "": - if len(description_hash) != 64: - msg = "description_hash must be 64 bytes" - raise ValueError(msg) - - tags.tags.extend([Tag(TagChar.description_hash, description_hash)]) - else: - tags.tags.extend( - [Tag(TagChar.description, description if description is not None else "")] - ) - - return encode( - Bolt11( - self._prefix, - int(time_now().timestamp()), - tags, - MilliSatoshi(amount_msat), - ), - self._key, - ) diff --git a/tools/plugins/hold/enums.py b/tools/plugins/hold/enums.py deleted file mode 100644 index 966b5025..00000000 --- a/tools/plugins/hold/enums.py +++ /dev/null @@ -1,35 +0,0 @@ -from strenum import StrEnum - - -class HtlcFailureMessage(StrEnum): - MppTimeout = "0017" - IncorrectPaymentDetails = "400F" - - -class HtlcState(StrEnum): - Paid = "paid" - Accepted = "accepted" - Cancelled = "cancelled" - - -class InvoiceState(StrEnum): - Paid = "paid" - Unpaid = "unpaid" - Accepted = "accepted" - Cancelled = "cancelled" - - -POSSIBLE_STATE_TRANSITIONS = { - InvoiceState.Paid: [], - InvoiceState.Cancelled: [], - InvoiceState.Accepted: [ - InvoiceState.Cancelled, - InvoiceState.Paid, - InvoiceState.Accepted, - ], - InvoiceState.Unpaid: [InvoiceState.Accepted, InvoiceState.Cancelled], -} - - -def invoice_state_final(state: InvoiceState) -> bool: - return len(POSSIBLE_STATE_TRANSITIONS[state]) == 0 diff --git a/tools/plugins/hold/errors.py b/tools/plugins/hold/errors.py deleted file mode 100644 index e34a2f74..00000000 --- a/tools/plugins/hold/errors.py +++ /dev/null @@ -1,20 +0,0 @@ -from typing import Any, ClassVar - - -class Errors: - invoice_exists: ClassVar[dict[str, Any]] = { - "code": 2101, - "message": "hold invoice with that payment hash exists already", - } - invoice_not_exists: ClassVar[dict[str, Any]] = { - "code": 2102, - "message": "hold invoice with that payment hash does not exist", - } - not_route: ClassVar[dict[str, Any]] = { - "code": 2103, - "message": "no route found", - } - invalid_payment_hash_length: ClassVar[dict[str, Any]] = { - "code": 2104, - "message": "invalid payment hash length", - } diff --git a/tools/plugins/hold/grpc_server.py b/tools/plugins/hold/grpc_server.py deleted file mode 100644 index 7d18e12c..00000000 --- a/tools/plugins/hold/grpc_server.py +++ /dev/null @@ -1,110 +0,0 @@ -import threading -from abc import ABC, abstractmethod -from concurrent.futures import ThreadPoolExecutor -from typing import Callable - -import grpc -from grpc_interceptor import ServerInterceptor -from pyln.client import Plugin - -from plugins.hold.certs import load_certs - - -def handle_grpc_error( - plugin: Plugin, - method_name: str, - context: grpc.ServicerContext, - e: Exception, -) -> None: - estr = str(e) if str(e) != "" else repr(e) - - plugin.log(f"gRPC call {method_name} failed: {estr}", level="warn") - context.abort(grpc.StatusCode.INTERNAL, estr) - - -class ServerError(Exception): - def __init__(self, message: str) -> None: - super().__init__(message) - - -class LogInterceptor(ServerInterceptor): - _plugin: Plugin - - def __init__(self, plugin: Plugin) -> None: - self._plugin = plugin - - def intercept( - self, - method: Callable, - request: object, - context: grpc.ServicerContext, - method_name: str, - ) -> object: - try: - self._plugin.log(f"gRPC call {method_name}", level="debug") - return method(request, context) - except Exception as e: - handle_grpc_error(self._plugin, method_name, context, e) - - -class GrpcServer(ABC): - _name: str - _use_ssl: bool - - _plugin: Plugin - _server: grpc.Server | None - - _server_thread: threading.Thread | None - - def __init__(self, name: str, pl: Plugin, use_ssl: bool = True) -> None: - self._name = name - self._use_ssl = use_ssl - - self._plugin = pl - self._server = None - self._server_thread = None - - def start(self, host: str, port: int, lightning_dir: str | None) -> None: - self._server = grpc.server( - ThreadPoolExecutor(), - interceptors=[LogInterceptor(self._plugin)], - ) - self._register_service() - - address = f"{host}:{port}" - - if self._use_ssl and lightning_dir is not None: - ca_cert, server_cert = load_certs(self._name, f"{lightning_dir}/{self._name}") - self._server.add_secure_port( - address, - grpc.ssl_server_credentials( - [(server_cert.key, server_cert.cert)], ca_cert.cert, True - ), - ) - else: - self._server.add_insecure_port(address) - - def start_server() -> None: - self._server.start() - - self._plugin.log(f"Started {self._name} gRPC server on {address}") - self._server.wait_for_termination() - - self._server_thread = threading.Thread(target=start_server) - self._server_thread.start() - - def is_running(self) -> bool: - return self._server is not None - - def stop(self) -> None: - if self.is_running(): - self._server.stop(False) - self._server_thread.join() - self._plugin.log("Stopped gRPC server") - else: - msg = "server not running" - raise ServerError(msg) - - @abstractmethod - def _register_service(self) -> None: - pass diff --git a/tools/plugins/hold/hold.py b/tools/plugins/hold/hold.py deleted file mode 100644 index 2ed46b2d..00000000 --- a/tools/plugins/hold/hold.py +++ /dev/null @@ -1,131 +0,0 @@ -import hashlib - -from bolt11.types import RouteHint -from pyln.client import Plugin, RpcError - -from plugins.hold.datastore import DataErrorCodes, DataStore -from plugins.hold.encoder import Encoder -from plugins.hold.htlc_handler import HtlcHandler -from plugins.hold.invoice import HoldInvoice, Htlcs, InvoiceState -from plugins.hold.route_hints import RouteHints -from plugins.hold.router import Router -from plugins.hold.settler import Settler -from plugins.hold.tracker import Tracker -from plugins.hold.utils import time_now - - -class InvoiceExistsError(Exception): - pass - - -class NoSuchInvoiceError(Exception): - pass - - -class InvalidPaymentHashLengthError(Exception): - pass - - -class Hold: - def __init__(self, plugin: Plugin) -> None: - self._plugin = plugin - self.tracker = Tracker() - self._settler = Settler(self.tracker) - self._encoder = Encoder(plugin) - self._route_hints = RouteHints(plugin) - - self.router = Router(plugin) - self.ds = DataStore(plugin, self._settler) - self.handler = HtlcHandler(plugin, self.ds, self._settler, self.tracker) - - def init(self) -> None: - self.handler.init() - self._encoder.init() - - def invoice( - self, - payment_hash: str, - amount_msat: int, - description: str | None, - description_hash: str | None, - expiry: int | None, - min_final_cltv_expiry: int | None, - route_hints: list[RouteHint] | None = None, - ) -> str: - if len(payment_hash) != 64: - raise InvalidPaymentHashLengthError - - if len(self._plugin.rpc.listinvoices(payment_hash=payment_hash)["invoices"]) > 0: - raise InvoiceExistsError - - bolt11 = self._encoder.encode( - payment_hash, - amount_msat, - description, - description_hash, - expiry, - min_final_cltv_expiry, - route_hints=route_hints, - ) - signed = self._plugin.rpc.call( - "signinvoice", - { - "invstring": bolt11, - }, - )["bolt11"] - - try: - hi = HoldInvoice( - state=InvoiceState.Unpaid, - bolt11=signed, - amount_msat=amount_msat, - payment_hash=payment_hash, - payment_preimage=None, - htlcs=Htlcs(), - created_at=time_now(), - ) - self.ds.save_invoice(hi) - self.tracker.send_update(hi.payment_hash, hi.bolt11, hi.state) - self._plugin.log(f"Added hold invoice {payment_hash} for {amount_msat}") - except RpcError as e: - # noinspection PyTypeChecker - if e.error["code"] == DataErrorCodes.KeyExists: - raise InvoiceExistsError from None - - raise - - return signed - - def settle(self, payment_preimage: str) -> None: - payment_hash = hashlib.sha256(bytes.fromhex(payment_preimage)).hexdigest() - invoice = self.ds.get_invoice(payment_hash) - if invoice is None: - raise NoSuchInvoiceError - - self.ds.settle_invoice(invoice, payment_preimage) - self._plugin.log(f"Settled hold invoice {payment_hash}") - - def cancel(self, payment_hash: str) -> None: - invoice = self.ds.get_invoice(payment_hash) - if invoice is None: - raise NoSuchInvoiceError - - self.ds.cancel_invoice(invoice) - self._plugin.log(f"Cancelled hold invoice {payment_hash}") - - def list_invoices(self, payment_hash: str | None) -> list[HoldInvoice]: - return self.ds.list_invoices(None if payment_hash == "" else payment_hash) - - def wipe(self, payment_hash: str | None) -> int: - if payment_hash is None or payment_hash == "": - self._plugin.log("Deleting all hold invoices", level="warn") - return self.ds.delete_invoices() - - if self.ds.delete_invoice(payment_hash): - self._plugin.log(f"Deleted hold invoice {payment_hash}", level="warn") - return 1 - - raise NoSuchInvoiceError - - def get_private_channels(self, node: str) -> list[RouteHint]: - return self._route_hints.get_private_channels(node) diff --git a/tools/plugins/hold/htlc_handler.py b/tools/plugins/hold/htlc_handler.py deleted file mode 100644 index 3f3b2521..00000000 --- a/tools/plugins/hold/htlc_handler.py +++ /dev/null @@ -1,181 +0,0 @@ -import threading -from typing import Any, Callable -from urllib.request import Request - -from pyln.client import Plugin - -from plugins.hold.consts import ( - OVERPAYMENT_FACTOR, - TIMEOUT_CANCEL, - TIMEOUT_CANCEL_REGTEST, - TIMEOUT_CHECK_INTERVAL, - Network, -) -from plugins.hold.datastore import DataStore -from plugins.hold.enums import HtlcState -from plugins.hold.invoice import HoldInvoice, Htlc, InvoiceState -from plugins.hold.settler import HtlcFailureMessage, Settler -from plugins.hold.tracker import Tracker - - -class HtlcHandler: - lock = threading.Lock() - - _interval_thread: threading.Thread - _stop_timeout_interval: threading.Event - - _plugin: Plugin - _ds: DataStore - _settler: Settler - - def __init__(self, plugin: Plugin, ds: DataStore, settler: Settler, tracker: Tracker) -> None: - self._plugin = plugin - self._ds = ds - self._settler = settler - self._tracker = tracker - self._timeout = TIMEOUT_CANCEL - - self._start_timeout_interval() - - def init(self) -> None: - if self._plugin.rpc.getinfo()["network"] == Network.Regtest: - self._timeout = TIMEOUT_CANCEL_REGTEST - self._plugin.log( - f"Using regtest MPP timeout of {self._timeout} seconds", - level="warn", - ) - - def stop(self) -> None: - self._stop_timeout_interval.set() - self._interval_thread.join() - - def handle_htlc( - self, - invoice: HoldInvoice, - htlc_dict: dict[str, str | int], - onion: dict[str, Any], - request: Request, - ) -> None: - # TODO: test restart handling accept/settle already accepted/settled invoices - - dec = self._plugin.rpc.decodepay(invoice.bolt11) - - htlc = Htlc.from_dict(htlc_dict) - - if invoice.htlcs.is_known(htlc): - self.handle_known_htlc( - invoice, - invoice.htlcs.find_htlc(htlc.short_channel_id, htlc.channel_id), - request, - ) - return - - invoice.htlcs.add_htlc(htlc) - - if htlc_dict["cltv_expiry_relative"] < dec["min_final_cltv_expiry"]: - self._log_htlc_rejected( - invoice, - htlc, - f"CLTV too little ({htlc_dict['cltv_expiry_relative']} < " - f"{dec['min_final_cltv_expiry']})", - ) - # TODO: use incorrect_cltv_expiry or expiry_too_soon error? - self._fail_and_save_htlc(request, invoice, htlc) - return - - if "payment_secret" not in onion or onion["payment_secret"] != dec["payment_secret"]: - self._log_htlc_rejected( - invoice, - htlc, - "incorrect payment secret", - ) - self._fail_and_save_htlc(request, invoice, htlc) - return - - if invoice.state != InvoiceState.Unpaid: - self._log_htlc_rejected(invoice, htlc, f"invoice is in state {invoice.state}") - self._fail_and_save_htlc(request, invoice, htlc) - return - - if invoice.amount_msat * OVERPAYMENT_FACTOR < invoice.sum_paid(): - self._log_htlc_rejected( - invoice, - htlc, - f"overpayment protection; " - f"{invoice.sum_paid()} > {invoice.amount_msat * OVERPAYMENT_FACTOR}", - ) - self._fail_and_save_htlc(request, invoice, htlc) - return - - self._settler.add_htlc(invoice.payment_hash, request, htlc) - - if not invoice.is_fully_paid(): - self._ds.save_invoice(invoice, mode="must-replace") - return - - invoice.set_state(self._tracker, InvoiceState.Accepted) - self._ds.save_invoice(invoice, mode="must-replace") - self._plugin.log( - f"Accepted hold invoice {invoice.payment_hash} " f"with {len(invoice.htlcs)} HTLCs", - ) - - def handle_known_htlc(self, invoice: HoldInvoice, htlc: Htlc, request: Request) -> None: - if htlc.state == HtlcState.Accepted: - # Pass the request to the settler to handle in the future - self._settler.add_htlc(invoice.payment_hash, request, htlc) - - elif htlc.state == HtlcState.Paid: - Settler.settle_callback(request, invoice.payment_preimage) - - elif htlc.state == HtlcState.Cancelled: - Settler.fail_callback(request, HtlcFailureMessage.IncorrectPaymentDetails) - - def _start_timeout_interval(self) -> None: - self._stop_timeout_interval = threading.Event() - - def loop() -> None: - while not self._stop_timeout_interval.wait(TIMEOUT_CHECK_INTERVAL): - self._timeout_handler() - - self._interval_thread = threading.Thread(target=loop) - self._interval_thread.start() - - def _timeout_handler(self) -> None: - with self.lock: - for payment_hash in self._settler.pending_payment_hashes(): - invoice = self._ds.get_invoice(payment_hash) - - if invoice is not None and not invoice.is_fully_paid(): - invoice.htlcs.cancel_expired( - self._timeout, self._fail_expired_callback(invoice) - ) - self._ds.save_invoice(invoice, mode="must-replace") - - def _fail_expired_callback( - self, invoice: HoldInvoice - ) -> Callable[[Htlc, HtlcFailureMessage], None]: - def callback(htlc: Htlc, message: HtlcFailureMessage) -> None: - request = self._settler.find_htlc_request(invoice.payment_hash, htlc) - if request is not None: - Settler.fail_callback(request, message) - self._settler.remove_htlc(invoice.payment_hash, htlc) - - return callback - - def _fail_and_save_htlc( - self, - request: Request, - invoice: HoldInvoice, - htlc: Htlc, - message: HtlcFailureMessage = HtlcFailureMessage.IncorrectPaymentDetails, - ) -> None: - Settler.fail_callback(request, message) - - htlc.state = HtlcState.Cancelled - self._ds.save_invoice(invoice, mode="must-replace") - - def _log_htlc_rejected(self, invoice: HoldInvoice, htlc: Htlc, msg: str) -> None: - self._plugin.log( - f"Rejected HTLC {htlc.identifier} for hold invoice {invoice.payment_hash}: {msg}", - level="warn", - ) diff --git a/tools/plugins/hold/invoice.py b/tools/plugins/hold/invoice.py deleted file mode 100644 index 70b3a8e4..00000000 --- a/tools/plugins/hold/invoice.py +++ /dev/null @@ -1,194 +0,0 @@ -import json -from dataclasses import dataclass -from datetime import date, datetime, timezone -from enum import Enum -from json import JSONEncoder -from typing import Any, Callable, TypeVar - -import bolt11 - -from plugins.hold.enums import ( - POSSIBLE_STATE_TRANSITIONS, - HtlcFailureMessage, - HtlcState, - InvoiceState, -) -from plugins.hold.tracker import Tracker -from plugins.hold.utils import time_now - -HtlcType = TypeVar("HtlcType", bound="Htlc") - - -@dataclass -class Htlc: - state: HtlcState - short_channel_id: str - channel_id: int - msat: int - created_at: datetime - - @property - def identifier(self) -> str: - return f"{self.short_channel_id}/{self.channel_id}" - - def to_dict(self) -> dict[str, Any]: - return { - k: int(v.timestamp()) if isinstance(v, datetime) else v - for k, v in self.__dict__.items() - } - - @classmethod - def from_dict(cls: type[HtlcType], htlc_dict: dict[str, Any]) -> HtlcType: - return Htlc( - state=HtlcState.Accepted, - short_channel_id=htlc_dict["short_channel_id"], - channel_id=htlc_dict["id"], - msat=htlc_dict["amount_msat"], - created_at=time_now(), - ) - - @classmethod - def from_json_dict(cls: type[HtlcType], json_dict: dict[str, Any]) -> HtlcType: - json_dict["created_at"] = datetime.fromtimestamp(json_dict["created_at"], tz=timezone.utc) - - return cls(**json_dict) - - -HtlcsType = TypeVar("HtlcsType", bound="Htlcs") - - -class Htlcs: - htlcs: list[Htlc] - - def __init__(self) -> None: - self.htlcs = [] - - def __len__(self) -> int: - """Return the number of accepted HTLCs.""" - return len([h.msat for h in self.htlcs if h.state in HtlcState.Accepted]) - - def add_htlc(self, htlc: Htlc) -> None: - self.htlcs.append(htlc) - - def is_known(self, htlc: Htlc) -> bool: - return self.find_htlc(htlc.short_channel_id, htlc.channel_id) is not None - - def find_htlc(self, short_channel_id: str, channel_id: int) -> Htlc | None: - return next( - ( - htlc - for htlc in self.htlcs - if htlc.short_channel_id == short_channel_id and htlc.channel_id == channel_id - ), - None, - ) - - def cancel_expired( - self, - expiry: int, - fail_callback: Callable[[Htlc, HtlcFailureMessage], None], - ) -> None: - for htlc in self.htlcs: - if not (time_now() - htlc.created_at).total_seconds() > expiry: - continue - - htlc.state = HtlcState.Cancelled - fail_callback(htlc, HtlcFailureMessage.MppTimeout) - - @classmethod - def from_json_arr(cls: type[HtlcsType], json_arr: list[Any]) -> HtlcsType: - htlcs = cls() - htlcs.htlcs = [Htlc.from_json_dict(entry) for entry in json_arr] - - return htlcs - - -class HoldInvoiceStateError(ValueError): - def __init__(self, old_state: InvoiceState, new_state: InvoiceState) -> None: - msg = f"illegal hold invoice state transition ({old_state} -> {new_state})" - super(ValueError, self).__init__(msg) - - self.error = { - "code": 2103, - "message": msg, - } - - -class HoldInvoiceEncoder(JSONEncoder): - def default(self, obj: object) -> str | int | list | None: - if isinstance(obj, (date, datetime)): - return int(obj.timestamp()) - - if isinstance(obj, Enum): - return obj.value - - if isinstance(obj, Htlcs): - return [htlc.to_dict() for htlc in obj.htlcs] - - return None - - -HoldInvoiceType = TypeVar("HoldInvoiceType", bound="HoldInvoice") - - -@dataclass -class HoldInvoice: - state: InvoiceState - bolt11: str - amount_msat: int - payment_hash: str - payment_preimage: str | None - created_at: datetime - htlcs: Htlcs - - def set_state(self, tracker: Tracker, new_state: InvoiceState) -> None: - if self.state == new_state: - return - - if new_state not in POSSIBLE_STATE_TRANSITIONS[self.state]: - raise HoldInvoiceStateError(self.state, new_state) - - self.state = new_state - tracker.send_update(self.payment_hash, self.bolt11, self.state) - - def is_fully_paid(self) -> bool: - return self.amount_msat <= self.sum_paid() - - def sum_paid(self) -> int: - return sum( - h.msat for h in self.htlcs.htlcs if h.state in [HtlcState.Paid, HtlcState.Accepted] - ) - - def to_json(self) -> str: - return json.dumps( - self.__dict__, - cls=HoldInvoiceEncoder, - ) - - def to_dict(self) -> dict[str, Any]: - self_with_htlcs = { - k: v if not isinstance(v, Htlcs) else [htlc.to_dict() for htlc in v.htlcs] - for k, v in self.__dict__.items() - } - - return { - k: int(v.timestamp()) if isinstance(v, datetime) else v - for k, v in self_with_htlcs.items() - } - - @classmethod - def from_json(cls: type[HoldInvoiceType], json_str: str) -> HoldInvoiceType: - json_str = json_str.removeprefix("\\") - - if json_str.endswith("\\}"): - json_str = json_str.removesuffix("\\}") + "}" - - json_dict = json.loads(json_str) - json_dict["created_at"] = datetime.fromtimestamp(json_dict["created_at"], tz=timezone.utc) - - if "amount_msat" not in json_dict: - json_dict["amount_msat"] = bolt11.decode(json_dict["bolt11"]).amount_msat - - json_dict["htlcs"] = Htlcs.from_json_arr(json_dict["htlcs"]) if "htlcs" in json_dict else [] - - return cls(**json_dict) diff --git a/tools/plugins/hold/plugin.py b/tools/plugins/hold/plugin.py deleted file mode 100755 index a3004d95..00000000 --- a/tools/plugins/hold/plugin.py +++ /dev/null @@ -1,240 +0,0 @@ -#!/usr/bin/env python3 -import contextlib -import sys -from typing import Any - -import bolt11 -from bolt11.exceptions import Bolt11Bech32InvalidException -from consts import ( - PLUGIN_NAME, - VERSION, -) -from pyln.client import Plugin -from pyln.client.plugin import Request - -from plugins.hold.config import Config, register_options -from plugins.hold.encoder import Defaults -from plugins.hold.errors import Errors -from plugins.hold.hold import ( - Hold, - InvalidPaymentHashLengthError, - InvoiceExistsError, - NoSuchInvoiceError, -) -from plugins.hold.invoice import HoldInvoiceStateError -from plugins.hold.router import NoRouteError -from plugins.hold.server import Server -from plugins.hold.settler import Settler -from plugins.hold.transformers import Transformers - -empty_value = ["", "none", "null", None] - -pl = Plugin() -hold = Hold(pl) -server = Server(pl, hold) - -register_options(pl) - - -@pl.init() -def init( - options: dict[str, Any], - configuration: dict[str, Any], - plugin: Plugin, - **kwargs: dict[str, Any], -) -> None: - cfg = Config(plugin, options) - hold.init() - - if cfg.grpc_port != -1: - server.start(cfg.grpc_host, cfg.grpc_port, configuration["lightning-dir"]) - else: - plugin.log("Not starting gRPC server") - - pl.log(f"Plugin {PLUGIN_NAME} v{VERSION} initialized") - - -@pl.method( - method_name="holdinvoice", - category=PLUGIN_NAME, -) -def hold_invoice( - plugin: Plugin, - payment_hash: str, - amount_msat: int, - description: str = "", - description_hash: str = "", - expiry: int = Defaults.Expiry, - min_final_cltv_expiry: int = Defaults.MinFinalCltvExpiry, - routing_hints: list[Any] | None = None, -) -> dict[str, Any]: - """Create a new hold invoice.""" - try: - return { - "bolt11": hold.invoice( - payment_hash, - amount_msat, - description, - description_hash, - expiry, - min_final_cltv_expiry, - Transformers.routing_hints_from_json(routing_hints) - if routing_hints is not None - else None, - ), - } - except InvoiceExistsError: - return Errors.invoice_exists - except InvalidPaymentHashLengthError: - return Errors.invalid_payment_hash_length - - -@pl.method( - method_name="listholdinvoices", - category=PLUGIN_NAME, -) -def list_hold_invoices(plugin: Plugin, payment_hash: str = "", invoice: str = "") -> dict[str, Any]: - """List one or more hold invoices.""" - if payment_hash in empty_value and invoice not in empty_value: - payment_hash = bolt11.decode(invoice).payment_hash - elif ( - payment_hash is not None - and len(payment_hash) > 64 - and payment_hash.lower().startswith("ln") - ): - # To allow the first parameter to be the invoice - with contextlib.suppress(Bolt11Bech32InvalidException): - payment_hash = bolt11.decode(payment_hash).payment_hash - - return { - "holdinvoices": [invoice.to_dict() for invoice in hold.list_invoices(payment_hash)], - } - - -@pl.method( - method_name="settleholdinvoice", - category=PLUGIN_NAME, -) -def settle_hold_invoice(plugin: Plugin, payment_preimage: str) -> dict[str, Any]: - """Settle a hold invoice.""" - try: - hold.settle(payment_preimage) - except NoSuchInvoiceError: - return Errors.invoice_not_exists - except HoldInvoiceStateError as e: - return e.error - - return {} - - -@pl.method( - method_name="cancelholdinvoice", - category=PLUGIN_NAME, -) -def cancel_hold_invoice(plugin: Plugin, payment_hash: str) -> dict[str, Any]: - """Cancel a hold invoice.""" - try: - hold.cancel(payment_hash) - except NoSuchInvoiceError: - return Errors.invoice_not_exists - except HoldInvoiceStateError as e: - return e.error - - return {} - - -@pl.method( - method_name="hold-getroute", - category=PLUGIN_NAME, -) -def get_route( - plugin: Plugin, - destination: str, - amount_msat: int, - risk: int = 0, - max_ctlv: int | None = None, - final_cltv_delta: int | None = None, - max_retries: int | None = None, -) -> dict[str, Any]: - """Get a route with less than a specified CLTV.""" - try: - return { - "routes": [ - hop.to_dict() - for hop in hold.router.get_route( - destination, - amount_msat, - risk, - max_ctlv, - final_cltv_delta, - max_retries, - ) - ] - } - except NoRouteError: - return Errors.not_route - - -@pl.method( - method_name="routinghints", - category=PLUGIN_NAME, -) -def get_routing_hints(plugin: Plugin, node: str) -> dict[str, Any]: - """Get routing hints for the unannounced channels of a node.""" - return { - "hints": Transformers.named_tuples_to_dict(hold.get_private_channels(node)), - } - - -@pl.method( - method_name="dev-wipeholdinvoices", - category=PLUGIN_NAME, -) -def wipe_hold_invoices(plugin: Plugin, payment_hash: str = "") -> dict[str, Any]: - """Delete one or more hold invoices from the datastore.""" - try: - return { - "deleted_count": hold.wipe(payment_hash), - } - except NoSuchInvoiceError: - return Errors.invoice_not_exists - - -@pl.async_hook("htlc_accepted") -def on_htlc_accepted( - onion: dict[str, Any], - htlc: dict[str, Any], - request: Request, - plugin: Plugin, - **kwargs: dict[str, Any], -) -> None: - # Ignore forwards - if "forward_to" in kwargs: - Settler.continue_callback(request) - return - - with hold.handler.lock: - invoice = hold.ds.get_invoice(htlc["payment_hash"]) - - # Ignore invoices that aren't hold invoices - if invoice is None: - Settler.continue_callback(request) - return - - hold.handler.handle_htlc(invoice, htlc, onion, request) - - -@pl.subscribe("shutdown") -def shutdown(**kwargs: dict[str, Any]) -> None: - pl.log(f"Plugin {PLUGIN_NAME} stopping") - - if server.is_running(): - server.stop() - - hold.handler.stop() - - pl.log(f"Plugin {PLUGIN_NAME} stopped") - sys.exit(0) - - -pl.run() diff --git a/tools/plugins/hold/protos/__init__.py b/tools/plugins/hold/protos/__init__.py deleted file mode 100644 index 1da1dcf0..00000000 --- a/tools/plugins/hold/protos/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -import sys -from pathlib import Path - -sys.path.insert(0, str(Path(__file__).parent)) diff --git a/tools/plugins/hold/protos/hold.proto b/tools/plugins/hold/protos/hold.proto deleted file mode 100644 index 350e854b..00000000 --- a/tools/plugins/hold/protos/hold.proto +++ /dev/null @@ -1,198 +0,0 @@ -syntax = "proto3"; - -package hold; - -service Hold { - rpc GetInfo (GetInfoRequest) returns (GetInfoResponse) {} - - rpc Invoice (InvoiceRequest) returns (InvoiceResponse) {} - rpc RoutingHints (RoutingHintsRequest) returns (RoutingHintsResponse) {} - rpc List (ListRequest) returns (ListResponse) {} - - rpc Settle (SettleRequest) returns (SettleResponse) {} - rpc Cancel (CancelRequest) returns (CancelResponse) {} - - rpc Track (TrackRequest) returns (stream TrackResponse) {} - rpc TrackAll (TrackAllRequest) returns (stream TrackAllResponse) {} - - // Workaround to expose the paystatus command via gRPC, since CLN doesn't - rpc PayStatus (PayStatusRequest) returns (PayStatusResponse) {} - - // Custom algorithm that allows specifying a max delay - rpc GetRoute (GetRouteRequest) returns (GetRouteResponse); -} - -message GetInfoRequest {} -message GetInfoResponse { - string version = 1; -} - -message InvoiceRequest { - string payment_hash = 1; - uint64 amount_msat = 2; - optional string description = 3; - // Takes precedence over description in case both are set - optional string description_hash = 7; - optional uint64 expiry = 4; - optional uint64 min_final_cltv_expiry = 5; - repeated RoutingHint routing_hints = 6; -} -message InvoiceResponse { - string bolt11 = 1; -} - -message RoutingHintsRequest { - string node = 1; -} - -message Hop { - string public_key = 1; - string short_channel_id = 2; - uint64 base_fee = 3; - uint64 ppm_fee = 4; - uint64 cltv_expiry_delta = 5; -} - -message RoutingHint { - repeated Hop hops = 1; -} - -message RoutingHintsResponse { - repeated RoutingHint hints = 1; -} - -message ListRequest { - optional string payment_hash = 1; -} - -enum InvoiceState { - INVOICE_UNPAID = 0; - INVOICE_ACCEPTED = 1; - INVOICE_PAID = 2; - INVOICE_CANCELLED = 3; -} - -enum HtlcState { - HTLC_ACCEPTED = 0; - HTLC_SETTLED = 1; - HTLC_CANCELLED = 2; -} - -message Htlc { - HtlcState state = 1; - uint64 msat = 2; - uint64 created_at = 3; - string short_channel_id = 4; - uint64 id = 5; -} - -message Invoice { - string payment_hash = 1; - optional string payment_preimage = 2; - InvoiceState state = 3; - string bolt11 = 4; - uint64 created_at = 5; - repeated Htlc htlcs = 6; - uint64 amount_msat = 7; -} - -message ListResponse { - repeated Invoice invoices = 1; -} - -message SettleRequest { - string payment_preimage = 1; -} -message SettleResponse {} - -message CancelRequest { - string payment_hash = 1; -} -message CancelResponse {} - -message TrackRequest { - string payment_hash = 1; -} -message TrackResponse { - InvoiceState state = 1; -} - -message TrackAllRequest {} -message TrackAllResponse { - string payment_hash = 1; - string bolt11 = 2; - InvoiceState state = 3; -} - -message PayStatusRequest { - optional string bolt11 = 1; -} - -message PayStatusResponse { - message PayStatus { - message Attempt { - enum AttemptState { - ATTEMPT_PENDING = 0; - ATTEMPT_COMPLETED = 1; - } - - message Success { - uint64 id = 1; - string payment_preimage = 2; - } - - message Failure { - message Data { - uint64 id = 1; - string raw_message = 2; - uint64 fail_code = 3; - string fail_codename = 4; - uint64 erring_index = 5; - string erring_node = 6; - } - - string message = 1; - uint64 code = 2; - optional Data data = 3; - } - - string strategy = 1; - uint64 start_time = 2; - uint64 age_in_seconds = 3; - optional uint64 end_time = 4; - AttemptState state = 5; - optional Success success = 6; - optional Failure failure = 7; - } - - string bolt11 = 1; - uint64 amount_msat = 2; - string destination = 3; - repeated Attempt attempts = 4; - } - - repeated PayStatus status = 1; -} - -message GetRouteRequest { - string destination = 1; - uint64 amount_msat = 2; - uint32 max_retries = 3; - optional uint32 risk_factor = 4; - optional uint64 max_cltv = 5; - optional uint64 final_cltv_delta = 6; -} - -message GetRouteResponse { - message Hop { - string id = 1; - string channel = 2; - uint32 direction = 3; - uint64 amount_msat = 4; - uint64 delay = 5; - string style = 6; - } - - repeated Hop hops = 1; - uint64 fees_msat = 2; -} diff --git a/tools/plugins/hold/protos/hold_pb2.py b/tools/plugins/hold/protos/hold_pb2.py deleted file mode 100644 index 2760f93a..00000000 --- a/tools/plugins/hold/protos/hold_pb2.py +++ /dev/null @@ -1,92 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: hold.proto -# Protobuf Python Version: 5.26.1 -"""Generated protocol buffer code.""" -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -from google.protobuf.internal import builder as _builder -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nhold.proto\x12\x04hold\"\x10\n\x0eGetInfoRequest\"\"\n\x0fGetInfoResponse\x12\x0f\n\x07version\x18\x01 \x01(\t\"\xa1\x02\n\x0eInvoiceRequest\x12\x14\n\x0cpayment_hash\x18\x01 \x01(\t\x12\x13\n\x0b\x61mount_msat\x18\x02 \x01(\x04\x12\x18\n\x0b\x64\x65scription\x18\x03 \x01(\tH\x00\x88\x01\x01\x12\x1d\n\x10\x64\x65scription_hash\x18\x07 \x01(\tH\x01\x88\x01\x01\x12\x13\n\x06\x65xpiry\x18\x04 \x01(\x04H\x02\x88\x01\x01\x12\"\n\x15min_final_cltv_expiry\x18\x05 \x01(\x04H\x03\x88\x01\x01\x12(\n\rrouting_hints\x18\x06 \x03(\x0b\x32\x11.hold.RoutingHintB\x0e\n\x0c_descriptionB\x13\n\x11_description_hashB\t\n\x07_expiryB\x18\n\x16_min_final_cltv_expiry\"!\n\x0fInvoiceResponse\x12\x0e\n\x06\x62olt11\x18\x01 \x01(\t\"#\n\x13RoutingHintsRequest\x12\x0c\n\x04node\x18\x01 \x01(\t\"q\n\x03Hop\x12\x12\n\npublic_key\x18\x01 \x01(\t\x12\x18\n\x10short_channel_id\x18\x02 \x01(\t\x12\x10\n\x08\x62\x61se_fee\x18\x03 \x01(\x04\x12\x0f\n\x07ppm_fee\x18\x04 \x01(\x04\x12\x19\n\x11\x63ltv_expiry_delta\x18\x05 \x01(\x04\"&\n\x0bRoutingHint\x12\x17\n\x04hops\x18\x01 \x03(\x0b\x32\t.hold.Hop\"8\n\x14RoutingHintsResponse\x12 \n\x05hints\x18\x01 \x03(\x0b\x32\x11.hold.RoutingHint\"9\n\x0bListRequest\x12\x19\n\x0cpayment_hash\x18\x01 \x01(\tH\x00\x88\x01\x01\x42\x0f\n\r_payment_hash\"n\n\x04Htlc\x12\x1e\n\x05state\x18\x01 \x01(\x0e\x32\x0f.hold.HtlcState\x12\x0c\n\x04msat\x18\x02 \x01(\x04\x12\x12\n\ncreated_at\x18\x03 \x01(\x04\x12\x18\n\x10short_channel_id\x18\x04 \x01(\t\x12\n\n\x02id\x18\x05 \x01(\x04\"\xca\x01\n\x07Invoice\x12\x14\n\x0cpayment_hash\x18\x01 \x01(\t\x12\x1d\n\x10payment_preimage\x18\x02 \x01(\tH\x00\x88\x01\x01\x12!\n\x05state\x18\x03 \x01(\x0e\x32\x12.hold.InvoiceState\x12\x0e\n\x06\x62olt11\x18\x04 \x01(\t\x12\x12\n\ncreated_at\x18\x05 \x01(\x04\x12\x19\n\x05htlcs\x18\x06 \x03(\x0b\x32\n.hold.Htlc\x12\x13\n\x0b\x61mount_msat\x18\x07 \x01(\x04\x42\x13\n\x11_payment_preimage\"/\n\x0cListResponse\x12\x1f\n\x08invoices\x18\x01 \x03(\x0b\x32\r.hold.Invoice\")\n\rSettleRequest\x12\x18\n\x10payment_preimage\x18\x01 \x01(\t\"\x10\n\x0eSettleResponse\"%\n\rCancelRequest\x12\x14\n\x0cpayment_hash\x18\x01 \x01(\t\"\x10\n\x0e\x43\x61ncelResponse\"$\n\x0cTrackRequest\x12\x14\n\x0cpayment_hash\x18\x01 \x01(\t\"2\n\rTrackResponse\x12!\n\x05state\x18\x01 \x01(\x0e\x32\x12.hold.InvoiceState\"\x11\n\x0fTrackAllRequest\"[\n\x10TrackAllResponse\x12\x14\n\x0cpayment_hash\x18\x01 \x01(\t\x12\x0e\n\x06\x62olt11\x18\x02 \x01(\t\x12!\n\x05state\x18\x03 \x01(\x0e\x32\x12.hold.InvoiceState\"2\n\x10PayStatusRequest\x12\x13\n\x06\x62olt11\x18\x01 \x01(\tH\x00\x88\x01\x01\x42\t\n\x07_bolt11\"\x94\x07\n\x11PayStatusResponse\x12\x31\n\x06status\x18\x01 \x03(\x0b\x32!.hold.PayStatusResponse.PayStatus\x1a\xcb\x06\n\tPayStatus\x12\x0e\n\x06\x62olt11\x18\x01 \x01(\t\x12\x13\n\x0b\x61mount_msat\x18\x02 \x01(\x04\x12\x13\n\x0b\x64\x65stination\x18\x03 \x01(\t\x12;\n\x08\x61ttempts\x18\x04 \x03(\x0b\x32).hold.PayStatusResponse.PayStatus.Attempt\x1a\xc6\x05\n\x07\x41ttempt\x12\x10\n\x08strategy\x18\x01 \x01(\t\x12\x12\n\nstart_time\x18\x02 \x01(\x04\x12\x16\n\x0e\x61ge_in_seconds\x18\x03 \x01(\x04\x12\x15\n\x08\x65nd_time\x18\x04 \x01(\x04H\x00\x88\x01\x01\x12\x45\n\x05state\x18\x05 \x01(\x0e\x32\x36.hold.PayStatusResponse.PayStatus.Attempt.AttemptState\x12G\n\x07success\x18\x06 \x01(\x0b\x32\x31.hold.PayStatusResponse.PayStatus.Attempt.SuccessH\x01\x88\x01\x01\x12G\n\x07\x66\x61ilure\x18\x07 \x01(\x0b\x32\x31.hold.PayStatusResponse.PayStatus.Attempt.FailureH\x02\x88\x01\x01\x1a/\n\x07Success\x12\n\n\x02id\x18\x01 \x01(\x04\x12\x18\n\x10payment_preimage\x18\x02 \x01(\t\x1a\xfa\x01\n\x07\x46\x61ilure\x12\x0f\n\x07message\x18\x01 \x01(\t\x12\x0c\n\x04\x63ode\x18\x02 \x01(\x04\x12I\n\x04\x64\x61ta\x18\x03 \x01(\x0b\x32\x36.hold.PayStatusResponse.PayStatus.Attempt.Failure.DataH\x00\x88\x01\x01\x1a|\n\x04\x44\x61ta\x12\n\n\x02id\x18\x01 \x01(\x04\x12\x13\n\x0braw_message\x18\x02 \x01(\t\x12\x11\n\tfail_code\x18\x03 \x01(\x04\x12\x15\n\rfail_codename\x18\x04 \x01(\t\x12\x14\n\x0c\x65rring_index\x18\x05 \x01(\x04\x12\x13\n\x0b\x65rring_node\x18\x06 \x01(\tB\x07\n\x05_data\":\n\x0c\x41ttemptState\x12\x13\n\x0f\x41TTEMPT_PENDING\x10\x00\x12\x15\n\x11\x41TTEMPT_COMPLETED\x10\x01\x42\x0b\n\t_end_timeB\n\n\x08_successB\n\n\x08_failure\"\xd2\x01\n\x0fGetRouteRequest\x12\x13\n\x0b\x64\x65stination\x18\x01 \x01(\t\x12\x13\n\x0b\x61mount_msat\x18\x02 \x01(\x04\x12\x13\n\x0bmax_retries\x18\x03 \x01(\r\x12\x18\n\x0brisk_factor\x18\x04 \x01(\rH\x00\x88\x01\x01\x12\x15\n\x08max_cltv\x18\x05 \x01(\x04H\x01\x88\x01\x01\x12\x1d\n\x10\x66inal_cltv_delta\x18\x06 \x01(\x04H\x02\x88\x01\x01\x42\x0e\n\x0c_risk_factorB\x0b\n\t_max_cltvB\x13\n\x11_final_cltv_delta\"\xb9\x01\n\x10GetRouteResponse\x12(\n\x04hops\x18\x01 \x03(\x0b\x32\x1a.hold.GetRouteResponse.Hop\x12\x11\n\tfees_msat\x18\x02 \x01(\x04\x1ah\n\x03Hop\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0f\n\x07\x63hannel\x18\x02 \x01(\t\x12\x11\n\tdirection\x18\x03 \x01(\r\x12\x13\n\x0b\x61mount_msat\x18\x04 \x01(\x04\x12\r\n\x05\x64\x65lay\x18\x05 \x01(\x04\x12\r\n\x05style\x18\x06 \x01(\t*a\n\x0cInvoiceState\x12\x12\n\x0eINVOICE_UNPAID\x10\x00\x12\x14\n\x10INVOICE_ACCEPTED\x10\x01\x12\x10\n\x0cINVOICE_PAID\x10\x02\x12\x15\n\x11INVOICE_CANCELLED\x10\x03*D\n\tHtlcState\x12\x11\n\rHTLC_ACCEPTED\x10\x00\x12\x10\n\x0cHTLC_SETTLED\x10\x01\x12\x12\n\x0eHTLC_CANCELLED\x10\x02\x32\xd2\x04\n\x04Hold\x12\x38\n\x07GetInfo\x12\x14.hold.GetInfoRequest\x1a\x15.hold.GetInfoResponse\"\x00\x12\x38\n\x07Invoice\x12\x14.hold.InvoiceRequest\x1a\x15.hold.InvoiceResponse\"\x00\x12G\n\x0cRoutingHints\x12\x19.hold.RoutingHintsRequest\x1a\x1a.hold.RoutingHintsResponse\"\x00\x12/\n\x04List\x12\x11.hold.ListRequest\x1a\x12.hold.ListResponse\"\x00\x12\x35\n\x06Settle\x12\x13.hold.SettleRequest\x1a\x14.hold.SettleResponse\"\x00\x12\x35\n\x06\x43\x61ncel\x12\x13.hold.CancelRequest\x1a\x14.hold.CancelResponse\"\x00\x12\x34\n\x05Track\x12\x12.hold.TrackRequest\x1a\x13.hold.TrackResponse\"\x00\x30\x01\x12=\n\x08TrackAll\x12\x15.hold.TrackAllRequest\x1a\x16.hold.TrackAllResponse\"\x00\x30\x01\x12>\n\tPayStatus\x12\x16.hold.PayStatusRequest\x1a\x17.hold.PayStatusResponse\"\x00\x12\x39\n\x08GetRoute\x12\x15.hold.GetRouteRequest\x1a\x16.hold.GetRouteResponseb\x06proto3') - -_globals = globals() -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'hold_pb2', _globals) -if not _descriptor._USE_C_DESCRIPTORS: - DESCRIPTOR._loaded_options = None - _globals['_INVOICESTATE']._serialized_start=2768 - _globals['_INVOICESTATE']._serialized_end=2865 - _globals['_HTLCSTATE']._serialized_start=2867 - _globals['_HTLCSTATE']._serialized_end=2935 - _globals['_GETINFOREQUEST']._serialized_start=20 - _globals['_GETINFOREQUEST']._serialized_end=36 - _globals['_GETINFORESPONSE']._serialized_start=38 - _globals['_GETINFORESPONSE']._serialized_end=72 - _globals['_INVOICEREQUEST']._serialized_start=75 - _globals['_INVOICEREQUEST']._serialized_end=364 - _globals['_INVOICERESPONSE']._serialized_start=366 - _globals['_INVOICERESPONSE']._serialized_end=399 - _globals['_ROUTINGHINTSREQUEST']._serialized_start=401 - _globals['_ROUTINGHINTSREQUEST']._serialized_end=436 - _globals['_HOP']._serialized_start=438 - _globals['_HOP']._serialized_end=551 - _globals['_ROUTINGHINT']._serialized_start=553 - _globals['_ROUTINGHINT']._serialized_end=591 - _globals['_ROUTINGHINTSRESPONSE']._serialized_start=593 - _globals['_ROUTINGHINTSRESPONSE']._serialized_end=649 - _globals['_LISTREQUEST']._serialized_start=651 - _globals['_LISTREQUEST']._serialized_end=708 - _globals['_HTLC']._serialized_start=710 - _globals['_HTLC']._serialized_end=820 - _globals['_INVOICE']._serialized_start=823 - _globals['_INVOICE']._serialized_end=1025 - _globals['_LISTRESPONSE']._serialized_start=1027 - _globals['_LISTRESPONSE']._serialized_end=1074 - _globals['_SETTLEREQUEST']._serialized_start=1076 - _globals['_SETTLEREQUEST']._serialized_end=1117 - _globals['_SETTLERESPONSE']._serialized_start=1119 - _globals['_SETTLERESPONSE']._serialized_end=1135 - _globals['_CANCELREQUEST']._serialized_start=1137 - _globals['_CANCELREQUEST']._serialized_end=1174 - _globals['_CANCELRESPONSE']._serialized_start=1176 - _globals['_CANCELRESPONSE']._serialized_end=1192 - _globals['_TRACKREQUEST']._serialized_start=1194 - _globals['_TRACKREQUEST']._serialized_end=1230 - _globals['_TRACKRESPONSE']._serialized_start=1232 - _globals['_TRACKRESPONSE']._serialized_end=1282 - _globals['_TRACKALLREQUEST']._serialized_start=1284 - _globals['_TRACKALLREQUEST']._serialized_end=1301 - _globals['_TRACKALLRESPONSE']._serialized_start=1303 - _globals['_TRACKALLRESPONSE']._serialized_end=1394 - _globals['_PAYSTATUSREQUEST']._serialized_start=1396 - _globals['_PAYSTATUSREQUEST']._serialized_end=1446 - _globals['_PAYSTATUSRESPONSE']._serialized_start=1449 - _globals['_PAYSTATUSRESPONSE']._serialized_end=2365 - _globals['_PAYSTATUSRESPONSE_PAYSTATUS']._serialized_start=1522 - _globals['_PAYSTATUSRESPONSE_PAYSTATUS']._serialized_end=2365 - _globals['_PAYSTATUSRESPONSE_PAYSTATUS_ATTEMPT']._serialized_start=1655 - _globals['_PAYSTATUSRESPONSE_PAYSTATUS_ATTEMPT']._serialized_end=2365 - _globals['_PAYSTATUSRESPONSE_PAYSTATUS_ATTEMPT_SUCCESS']._serialized_start=1968 - _globals['_PAYSTATUSRESPONSE_PAYSTATUS_ATTEMPT_SUCCESS']._serialized_end=2015 - _globals['_PAYSTATUSRESPONSE_PAYSTATUS_ATTEMPT_FAILURE']._serialized_start=2018 - _globals['_PAYSTATUSRESPONSE_PAYSTATUS_ATTEMPT_FAILURE']._serialized_end=2268 - _globals['_PAYSTATUSRESPONSE_PAYSTATUS_ATTEMPT_FAILURE_DATA']._serialized_start=2135 - _globals['_PAYSTATUSRESPONSE_PAYSTATUS_ATTEMPT_FAILURE_DATA']._serialized_end=2259 - _globals['_PAYSTATUSRESPONSE_PAYSTATUS_ATTEMPT_ATTEMPTSTATE']._serialized_start=2270 - _globals['_PAYSTATUSRESPONSE_PAYSTATUS_ATTEMPT_ATTEMPTSTATE']._serialized_end=2328 - _globals['_GETROUTEREQUEST']._serialized_start=2368 - _globals['_GETROUTEREQUEST']._serialized_end=2578 - _globals['_GETROUTERESPONSE']._serialized_start=2581 - _globals['_GETROUTERESPONSE']._serialized_end=2766 - _globals['_GETROUTERESPONSE_HOP']._serialized_start=2662 - _globals['_GETROUTERESPONSE_HOP']._serialized_end=2766 - _globals['_HOLD']._serialized_start=2938 - _globals['_HOLD']._serialized_end=3532 -# @@protoc_insertion_point(module_scope) diff --git a/tools/plugins/hold/protos/hold_pb2.pyi b/tools/plugins/hold/protos/hold_pb2.pyi deleted file mode 100644 index 4d963628..00000000 --- a/tools/plugins/hold/protos/hold_pb2.pyi +++ /dev/null @@ -1,299 +0,0 @@ -from google.protobuf.internal import containers as _containers -from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union - -DESCRIPTOR: _descriptor.FileDescriptor - -class InvoiceState(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): - __slots__ = () - INVOICE_UNPAID: _ClassVar[InvoiceState] - INVOICE_ACCEPTED: _ClassVar[InvoiceState] - INVOICE_PAID: _ClassVar[InvoiceState] - INVOICE_CANCELLED: _ClassVar[InvoiceState] - -class HtlcState(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): - __slots__ = () - HTLC_ACCEPTED: _ClassVar[HtlcState] - HTLC_SETTLED: _ClassVar[HtlcState] - HTLC_CANCELLED: _ClassVar[HtlcState] -INVOICE_UNPAID: InvoiceState -INVOICE_ACCEPTED: InvoiceState -INVOICE_PAID: InvoiceState -INVOICE_CANCELLED: InvoiceState -HTLC_ACCEPTED: HtlcState -HTLC_SETTLED: HtlcState -HTLC_CANCELLED: HtlcState - -class GetInfoRequest(_message.Message): - __slots__ = () - def __init__(self) -> None: ... - -class GetInfoResponse(_message.Message): - __slots__ = ("version",) - VERSION_FIELD_NUMBER: _ClassVar[int] - version: str - def __init__(self, version: _Optional[str] = ...) -> None: ... - -class InvoiceRequest(_message.Message): - __slots__ = ("payment_hash", "amount_msat", "description", "description_hash", "expiry", "min_final_cltv_expiry", "routing_hints") - PAYMENT_HASH_FIELD_NUMBER: _ClassVar[int] - AMOUNT_MSAT_FIELD_NUMBER: _ClassVar[int] - DESCRIPTION_FIELD_NUMBER: _ClassVar[int] - DESCRIPTION_HASH_FIELD_NUMBER: _ClassVar[int] - EXPIRY_FIELD_NUMBER: _ClassVar[int] - MIN_FINAL_CLTV_EXPIRY_FIELD_NUMBER: _ClassVar[int] - ROUTING_HINTS_FIELD_NUMBER: _ClassVar[int] - payment_hash: str - amount_msat: int - description: str - description_hash: str - expiry: int - min_final_cltv_expiry: int - routing_hints: _containers.RepeatedCompositeFieldContainer[RoutingHint] - def __init__(self, payment_hash: _Optional[str] = ..., amount_msat: _Optional[int] = ..., description: _Optional[str] = ..., description_hash: _Optional[str] = ..., expiry: _Optional[int] = ..., min_final_cltv_expiry: _Optional[int] = ..., routing_hints: _Optional[_Iterable[_Union[RoutingHint, _Mapping]]] = ...) -> None: ... - -class InvoiceResponse(_message.Message): - __slots__ = ("bolt11",) - BOLT11_FIELD_NUMBER: _ClassVar[int] - bolt11: str - def __init__(self, bolt11: _Optional[str] = ...) -> None: ... - -class RoutingHintsRequest(_message.Message): - __slots__ = ("node",) - NODE_FIELD_NUMBER: _ClassVar[int] - node: str - def __init__(self, node: _Optional[str] = ...) -> None: ... - -class Hop(_message.Message): - __slots__ = ("public_key", "short_channel_id", "base_fee", "ppm_fee", "cltv_expiry_delta") - PUBLIC_KEY_FIELD_NUMBER: _ClassVar[int] - SHORT_CHANNEL_ID_FIELD_NUMBER: _ClassVar[int] - BASE_FEE_FIELD_NUMBER: _ClassVar[int] - PPM_FEE_FIELD_NUMBER: _ClassVar[int] - CLTV_EXPIRY_DELTA_FIELD_NUMBER: _ClassVar[int] - public_key: str - short_channel_id: str - base_fee: int - ppm_fee: int - cltv_expiry_delta: int - def __init__(self, public_key: _Optional[str] = ..., short_channel_id: _Optional[str] = ..., base_fee: _Optional[int] = ..., ppm_fee: _Optional[int] = ..., cltv_expiry_delta: _Optional[int] = ...) -> None: ... - -class RoutingHint(_message.Message): - __slots__ = ("hops",) - HOPS_FIELD_NUMBER: _ClassVar[int] - hops: _containers.RepeatedCompositeFieldContainer[Hop] - def __init__(self, hops: _Optional[_Iterable[_Union[Hop, _Mapping]]] = ...) -> None: ... - -class RoutingHintsResponse(_message.Message): - __slots__ = ("hints",) - HINTS_FIELD_NUMBER: _ClassVar[int] - hints: _containers.RepeatedCompositeFieldContainer[RoutingHint] - def __init__(self, hints: _Optional[_Iterable[_Union[RoutingHint, _Mapping]]] = ...) -> None: ... - -class ListRequest(_message.Message): - __slots__ = ("payment_hash",) - PAYMENT_HASH_FIELD_NUMBER: _ClassVar[int] - payment_hash: str - def __init__(self, payment_hash: _Optional[str] = ...) -> None: ... - -class Htlc(_message.Message): - __slots__ = ("state", "msat", "created_at", "short_channel_id", "id") - STATE_FIELD_NUMBER: _ClassVar[int] - MSAT_FIELD_NUMBER: _ClassVar[int] - CREATED_AT_FIELD_NUMBER: _ClassVar[int] - SHORT_CHANNEL_ID_FIELD_NUMBER: _ClassVar[int] - ID_FIELD_NUMBER: _ClassVar[int] - state: HtlcState - msat: int - created_at: int - short_channel_id: str - id: int - def __init__(self, state: _Optional[_Union[HtlcState, str]] = ..., msat: _Optional[int] = ..., created_at: _Optional[int] = ..., short_channel_id: _Optional[str] = ..., id: _Optional[int] = ...) -> None: ... - -class Invoice(_message.Message): - __slots__ = ("payment_hash", "payment_preimage", "state", "bolt11", "created_at", "htlcs", "amount_msat") - PAYMENT_HASH_FIELD_NUMBER: _ClassVar[int] - PAYMENT_PREIMAGE_FIELD_NUMBER: _ClassVar[int] - STATE_FIELD_NUMBER: _ClassVar[int] - BOLT11_FIELD_NUMBER: _ClassVar[int] - CREATED_AT_FIELD_NUMBER: _ClassVar[int] - HTLCS_FIELD_NUMBER: _ClassVar[int] - AMOUNT_MSAT_FIELD_NUMBER: _ClassVar[int] - payment_hash: str - payment_preimage: str - state: InvoiceState - bolt11: str - created_at: int - htlcs: _containers.RepeatedCompositeFieldContainer[Htlc] - amount_msat: int - def __init__(self, payment_hash: _Optional[str] = ..., payment_preimage: _Optional[str] = ..., state: _Optional[_Union[InvoiceState, str]] = ..., bolt11: _Optional[str] = ..., created_at: _Optional[int] = ..., htlcs: _Optional[_Iterable[_Union[Htlc, _Mapping]]] = ..., amount_msat: _Optional[int] = ...) -> None: ... - -class ListResponse(_message.Message): - __slots__ = ("invoices",) - INVOICES_FIELD_NUMBER: _ClassVar[int] - invoices: _containers.RepeatedCompositeFieldContainer[Invoice] - def __init__(self, invoices: _Optional[_Iterable[_Union[Invoice, _Mapping]]] = ...) -> None: ... - -class SettleRequest(_message.Message): - __slots__ = ("payment_preimage",) - PAYMENT_PREIMAGE_FIELD_NUMBER: _ClassVar[int] - payment_preimage: str - def __init__(self, payment_preimage: _Optional[str] = ...) -> None: ... - -class SettleResponse(_message.Message): - __slots__ = () - def __init__(self) -> None: ... - -class CancelRequest(_message.Message): - __slots__ = ("payment_hash",) - PAYMENT_HASH_FIELD_NUMBER: _ClassVar[int] - payment_hash: str - def __init__(self, payment_hash: _Optional[str] = ...) -> None: ... - -class CancelResponse(_message.Message): - __slots__ = () - def __init__(self) -> None: ... - -class TrackRequest(_message.Message): - __slots__ = ("payment_hash",) - PAYMENT_HASH_FIELD_NUMBER: _ClassVar[int] - payment_hash: str - def __init__(self, payment_hash: _Optional[str] = ...) -> None: ... - -class TrackResponse(_message.Message): - __slots__ = ("state",) - STATE_FIELD_NUMBER: _ClassVar[int] - state: InvoiceState - def __init__(self, state: _Optional[_Union[InvoiceState, str]] = ...) -> None: ... - -class TrackAllRequest(_message.Message): - __slots__ = () - def __init__(self) -> None: ... - -class TrackAllResponse(_message.Message): - __slots__ = ("payment_hash", "bolt11", "state") - PAYMENT_HASH_FIELD_NUMBER: _ClassVar[int] - BOLT11_FIELD_NUMBER: _ClassVar[int] - STATE_FIELD_NUMBER: _ClassVar[int] - payment_hash: str - bolt11: str - state: InvoiceState - def __init__(self, payment_hash: _Optional[str] = ..., bolt11: _Optional[str] = ..., state: _Optional[_Union[InvoiceState, str]] = ...) -> None: ... - -class PayStatusRequest(_message.Message): - __slots__ = ("bolt11",) - BOLT11_FIELD_NUMBER: _ClassVar[int] - bolt11: str - def __init__(self, bolt11: _Optional[str] = ...) -> None: ... - -class PayStatusResponse(_message.Message): - __slots__ = ("status",) - class PayStatus(_message.Message): - __slots__ = ("bolt11", "amount_msat", "destination", "attempts") - class Attempt(_message.Message): - __slots__ = ("strategy", "start_time", "age_in_seconds", "end_time", "state", "success", "failure") - class AttemptState(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): - __slots__ = () - ATTEMPT_PENDING: _ClassVar[PayStatusResponse.PayStatus.Attempt.AttemptState] - ATTEMPT_COMPLETED: _ClassVar[PayStatusResponse.PayStatus.Attempt.AttemptState] - ATTEMPT_PENDING: PayStatusResponse.PayStatus.Attempt.AttemptState - ATTEMPT_COMPLETED: PayStatusResponse.PayStatus.Attempt.AttemptState - class Success(_message.Message): - __slots__ = ("id", "payment_preimage") - ID_FIELD_NUMBER: _ClassVar[int] - PAYMENT_PREIMAGE_FIELD_NUMBER: _ClassVar[int] - id: int - payment_preimage: str - def __init__(self, id: _Optional[int] = ..., payment_preimage: _Optional[str] = ...) -> None: ... - class Failure(_message.Message): - __slots__ = ("message", "code", "data") - class Data(_message.Message): - __slots__ = ("id", "raw_message", "fail_code", "fail_codename", "erring_index", "erring_node") - ID_FIELD_NUMBER: _ClassVar[int] - RAW_MESSAGE_FIELD_NUMBER: _ClassVar[int] - FAIL_CODE_FIELD_NUMBER: _ClassVar[int] - FAIL_CODENAME_FIELD_NUMBER: _ClassVar[int] - ERRING_INDEX_FIELD_NUMBER: _ClassVar[int] - ERRING_NODE_FIELD_NUMBER: _ClassVar[int] - id: int - raw_message: str - fail_code: int - fail_codename: str - erring_index: int - erring_node: str - def __init__(self, id: _Optional[int] = ..., raw_message: _Optional[str] = ..., fail_code: _Optional[int] = ..., fail_codename: _Optional[str] = ..., erring_index: _Optional[int] = ..., erring_node: _Optional[str] = ...) -> None: ... - MESSAGE_FIELD_NUMBER: _ClassVar[int] - CODE_FIELD_NUMBER: _ClassVar[int] - DATA_FIELD_NUMBER: _ClassVar[int] - message: str - code: int - data: PayStatusResponse.PayStatus.Attempt.Failure.Data - def __init__(self, message: _Optional[str] = ..., code: _Optional[int] = ..., data: _Optional[_Union[PayStatusResponse.PayStatus.Attempt.Failure.Data, _Mapping]] = ...) -> None: ... - STRATEGY_FIELD_NUMBER: _ClassVar[int] - START_TIME_FIELD_NUMBER: _ClassVar[int] - AGE_IN_SECONDS_FIELD_NUMBER: _ClassVar[int] - END_TIME_FIELD_NUMBER: _ClassVar[int] - STATE_FIELD_NUMBER: _ClassVar[int] - SUCCESS_FIELD_NUMBER: _ClassVar[int] - FAILURE_FIELD_NUMBER: _ClassVar[int] - strategy: str - start_time: int - age_in_seconds: int - end_time: int - state: PayStatusResponse.PayStatus.Attempt.AttemptState - success: PayStatusResponse.PayStatus.Attempt.Success - failure: PayStatusResponse.PayStatus.Attempt.Failure - def __init__(self, strategy: _Optional[str] = ..., start_time: _Optional[int] = ..., age_in_seconds: _Optional[int] = ..., end_time: _Optional[int] = ..., state: _Optional[_Union[PayStatusResponse.PayStatus.Attempt.AttemptState, str]] = ..., success: _Optional[_Union[PayStatusResponse.PayStatus.Attempt.Success, _Mapping]] = ..., failure: _Optional[_Union[PayStatusResponse.PayStatus.Attempt.Failure, _Mapping]] = ...) -> None: ... - BOLT11_FIELD_NUMBER: _ClassVar[int] - AMOUNT_MSAT_FIELD_NUMBER: _ClassVar[int] - DESTINATION_FIELD_NUMBER: _ClassVar[int] - ATTEMPTS_FIELD_NUMBER: _ClassVar[int] - bolt11: str - amount_msat: int - destination: str - attempts: _containers.RepeatedCompositeFieldContainer[PayStatusResponse.PayStatus.Attempt] - def __init__(self, bolt11: _Optional[str] = ..., amount_msat: _Optional[int] = ..., destination: _Optional[str] = ..., attempts: _Optional[_Iterable[_Union[PayStatusResponse.PayStatus.Attempt, _Mapping]]] = ...) -> None: ... - STATUS_FIELD_NUMBER: _ClassVar[int] - status: _containers.RepeatedCompositeFieldContainer[PayStatusResponse.PayStatus] - def __init__(self, status: _Optional[_Iterable[_Union[PayStatusResponse.PayStatus, _Mapping]]] = ...) -> None: ... - -class GetRouteRequest(_message.Message): - __slots__ = ("destination", "amount_msat", "max_retries", "risk_factor", "max_cltv", "final_cltv_delta") - DESTINATION_FIELD_NUMBER: _ClassVar[int] - AMOUNT_MSAT_FIELD_NUMBER: _ClassVar[int] - MAX_RETRIES_FIELD_NUMBER: _ClassVar[int] - RISK_FACTOR_FIELD_NUMBER: _ClassVar[int] - MAX_CLTV_FIELD_NUMBER: _ClassVar[int] - FINAL_CLTV_DELTA_FIELD_NUMBER: _ClassVar[int] - destination: str - amount_msat: int - max_retries: int - risk_factor: int - max_cltv: int - final_cltv_delta: int - def __init__(self, destination: _Optional[str] = ..., amount_msat: _Optional[int] = ..., max_retries: _Optional[int] = ..., risk_factor: _Optional[int] = ..., max_cltv: _Optional[int] = ..., final_cltv_delta: _Optional[int] = ...) -> None: ... - -class GetRouteResponse(_message.Message): - __slots__ = ("hops", "fees_msat") - class Hop(_message.Message): - __slots__ = ("id", "channel", "direction", "amount_msat", "delay", "style") - ID_FIELD_NUMBER: _ClassVar[int] - CHANNEL_FIELD_NUMBER: _ClassVar[int] - DIRECTION_FIELD_NUMBER: _ClassVar[int] - AMOUNT_MSAT_FIELD_NUMBER: _ClassVar[int] - DELAY_FIELD_NUMBER: _ClassVar[int] - STYLE_FIELD_NUMBER: _ClassVar[int] - id: str - channel: str - direction: int - amount_msat: int - delay: int - style: str - def __init__(self, id: _Optional[str] = ..., channel: _Optional[str] = ..., direction: _Optional[int] = ..., amount_msat: _Optional[int] = ..., delay: _Optional[int] = ..., style: _Optional[str] = ...) -> None: ... - HOPS_FIELD_NUMBER: _ClassVar[int] - FEES_MSAT_FIELD_NUMBER: _ClassVar[int] - hops: _containers.RepeatedCompositeFieldContainer[GetRouteResponse.Hop] - fees_msat: int - def __init__(self, hops: _Optional[_Iterable[_Union[GetRouteResponse.Hop, _Mapping]]] = ..., fees_msat: _Optional[int] = ...) -> None: ... diff --git a/tools/plugins/hold/protos/hold_pb2_grpc.py b/tools/plugins/hold/protos/hold_pb2_grpc.py deleted file mode 100644 index be70f382..00000000 --- a/tools/plugins/hold/protos/hold_pb2_grpc.py +++ /dev/null @@ -1,491 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc -import warnings - -import hold_pb2 as hold__pb2 - -GRPC_GENERATED_VERSION = '1.65.4' -GRPC_VERSION = grpc.__version__ -EXPECTED_ERROR_RELEASE = '1.66.0' -SCHEDULED_RELEASE_DATE = 'August 6, 2024' -_version_not_supported = False - -try: - from grpc._utilities import first_version_is_lower - _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION) -except ImportError: - _version_not_supported = True - -if _version_not_supported: - warnings.warn( - f'The grpc package installed is at version {GRPC_VERSION},' - + f' but the generated code in hold_pb2_grpc.py depends on' - + f' grpcio>={GRPC_GENERATED_VERSION}.' - + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}' - + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.' - + f' This warning will become an error in {EXPECTED_ERROR_RELEASE},' - + f' scheduled for release on {SCHEDULED_RELEASE_DATE}.', - RuntimeWarning - ) - - -class HoldStub(object): - """Missing associated documentation comment in .proto file.""" - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.GetInfo = channel.unary_unary( - '/hold.Hold/GetInfo', - request_serializer=hold__pb2.GetInfoRequest.SerializeToString, - response_deserializer=hold__pb2.GetInfoResponse.FromString, - _registered_method=True) - self.Invoice = channel.unary_unary( - '/hold.Hold/Invoice', - request_serializer=hold__pb2.InvoiceRequest.SerializeToString, - response_deserializer=hold__pb2.InvoiceResponse.FromString, - _registered_method=True) - self.RoutingHints = channel.unary_unary( - '/hold.Hold/RoutingHints', - request_serializer=hold__pb2.RoutingHintsRequest.SerializeToString, - response_deserializer=hold__pb2.RoutingHintsResponse.FromString, - _registered_method=True) - self.List = channel.unary_unary( - '/hold.Hold/List', - request_serializer=hold__pb2.ListRequest.SerializeToString, - response_deserializer=hold__pb2.ListResponse.FromString, - _registered_method=True) - self.Settle = channel.unary_unary( - '/hold.Hold/Settle', - request_serializer=hold__pb2.SettleRequest.SerializeToString, - response_deserializer=hold__pb2.SettleResponse.FromString, - _registered_method=True) - self.Cancel = channel.unary_unary( - '/hold.Hold/Cancel', - request_serializer=hold__pb2.CancelRequest.SerializeToString, - response_deserializer=hold__pb2.CancelResponse.FromString, - _registered_method=True) - self.Track = channel.unary_stream( - '/hold.Hold/Track', - request_serializer=hold__pb2.TrackRequest.SerializeToString, - response_deserializer=hold__pb2.TrackResponse.FromString, - _registered_method=True) - self.TrackAll = channel.unary_stream( - '/hold.Hold/TrackAll', - request_serializer=hold__pb2.TrackAllRequest.SerializeToString, - response_deserializer=hold__pb2.TrackAllResponse.FromString, - _registered_method=True) - self.PayStatus = channel.unary_unary( - '/hold.Hold/PayStatus', - request_serializer=hold__pb2.PayStatusRequest.SerializeToString, - response_deserializer=hold__pb2.PayStatusResponse.FromString, - _registered_method=True) - self.GetRoute = channel.unary_unary( - '/hold.Hold/GetRoute', - request_serializer=hold__pb2.GetRouteRequest.SerializeToString, - response_deserializer=hold__pb2.GetRouteResponse.FromString, - _registered_method=True) - - -class HoldServicer(object): - """Missing associated documentation comment in .proto file.""" - - def GetInfo(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def Invoice(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def RoutingHints(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def List(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def Settle(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def Cancel(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def Track(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def TrackAll(self, request, context): - """Missing associated documentation comment in .proto file.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def PayStatus(self, request, context): - """Workaround to expose the paystatus command via gRPC, since CLN doesn't - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetRoute(self, request, context): - """Custom algorithm that allows specifying a max delay - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - -def add_HoldServicer_to_server(servicer, server): - rpc_method_handlers = { - 'GetInfo': grpc.unary_unary_rpc_method_handler( - servicer.GetInfo, - request_deserializer=hold__pb2.GetInfoRequest.FromString, - response_serializer=hold__pb2.GetInfoResponse.SerializeToString, - ), - 'Invoice': grpc.unary_unary_rpc_method_handler( - servicer.Invoice, - request_deserializer=hold__pb2.InvoiceRequest.FromString, - response_serializer=hold__pb2.InvoiceResponse.SerializeToString, - ), - 'RoutingHints': grpc.unary_unary_rpc_method_handler( - servicer.RoutingHints, - request_deserializer=hold__pb2.RoutingHintsRequest.FromString, - response_serializer=hold__pb2.RoutingHintsResponse.SerializeToString, - ), - 'List': grpc.unary_unary_rpc_method_handler( - servicer.List, - request_deserializer=hold__pb2.ListRequest.FromString, - response_serializer=hold__pb2.ListResponse.SerializeToString, - ), - 'Settle': grpc.unary_unary_rpc_method_handler( - servicer.Settle, - request_deserializer=hold__pb2.SettleRequest.FromString, - response_serializer=hold__pb2.SettleResponse.SerializeToString, - ), - 'Cancel': grpc.unary_unary_rpc_method_handler( - servicer.Cancel, - request_deserializer=hold__pb2.CancelRequest.FromString, - response_serializer=hold__pb2.CancelResponse.SerializeToString, - ), - 'Track': grpc.unary_stream_rpc_method_handler( - servicer.Track, - request_deserializer=hold__pb2.TrackRequest.FromString, - response_serializer=hold__pb2.TrackResponse.SerializeToString, - ), - 'TrackAll': grpc.unary_stream_rpc_method_handler( - servicer.TrackAll, - request_deserializer=hold__pb2.TrackAllRequest.FromString, - response_serializer=hold__pb2.TrackAllResponse.SerializeToString, - ), - 'PayStatus': grpc.unary_unary_rpc_method_handler( - servicer.PayStatus, - request_deserializer=hold__pb2.PayStatusRequest.FromString, - response_serializer=hold__pb2.PayStatusResponse.SerializeToString, - ), - 'GetRoute': grpc.unary_unary_rpc_method_handler( - servicer.GetRoute, - request_deserializer=hold__pb2.GetRouteRequest.FromString, - response_serializer=hold__pb2.GetRouteResponse.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'hold.Hold', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - server.add_registered_method_handlers('hold.Hold', rpc_method_handlers) - - - # This class is part of an EXPERIMENTAL API. -class Hold(object): - """Missing associated documentation comment in .proto file.""" - - @staticmethod - def GetInfo(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary( - request, - target, - '/hold.Hold/GetInfo', - hold__pb2.GetInfoRequest.SerializeToString, - hold__pb2.GetInfoResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def Invoice(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary( - request, - target, - '/hold.Hold/Invoice', - hold__pb2.InvoiceRequest.SerializeToString, - hold__pb2.InvoiceResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def RoutingHints(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary( - request, - target, - '/hold.Hold/RoutingHints', - hold__pb2.RoutingHintsRequest.SerializeToString, - hold__pb2.RoutingHintsResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def List(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary( - request, - target, - '/hold.Hold/List', - hold__pb2.ListRequest.SerializeToString, - hold__pb2.ListResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def Settle(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary( - request, - target, - '/hold.Hold/Settle', - hold__pb2.SettleRequest.SerializeToString, - hold__pb2.SettleResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def Cancel(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary( - request, - target, - '/hold.Hold/Cancel', - hold__pb2.CancelRequest.SerializeToString, - hold__pb2.CancelResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def Track(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_stream( - request, - target, - '/hold.Hold/Track', - hold__pb2.TrackRequest.SerializeToString, - hold__pb2.TrackResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def TrackAll(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_stream( - request, - target, - '/hold.Hold/TrackAll', - hold__pb2.TrackAllRequest.SerializeToString, - hold__pb2.TrackAllResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def PayStatus(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary( - request, - target, - '/hold.Hold/PayStatus', - hold__pb2.PayStatusRequest.SerializeToString, - hold__pb2.PayStatusResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) - - @staticmethod - def GetRoute(request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary( - request, - target, - '/hold.Hold/GetRoute', - hold__pb2.GetRouteRequest.SerializeToString, - hold__pb2.GetRouteResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - _registered_method=True) diff --git a/tools/plugins/hold/route_hints.py b/tools/plugins/hold/route_hints.py deleted file mode 100644 index 8a778fef..00000000 --- a/tools/plugins/hold/route_hints.py +++ /dev/null @@ -1,31 +0,0 @@ -from bolt11.models.routehint import Route, RouteHint -from pyln.client import Plugin, RpcError - - -class RouteHints: - _id: str - - def __init__(self, plugin: Plugin) -> None: - self._plugin = plugin - - def get_private_channels(self, node: str) -> list[RouteHint]: - try: - chans = self._plugin.rpc.listpeerchannels(peer_id=node)["channels"] - except RpcError: - return [] - - return [ - RouteHint( - [ - Route( - public_key=node, - short_channel_id=chan["short_channel_id"], - base_fee=int(chan["updates"]["remote"]["fee_base_msat"]), - ppm_fee=chan["updates"]["remote"]["fee_proportional_millionths"], - cltv_expiry_delta=chan["updates"]["remote"]["cltv_expiry_delta"], - ) - ] - ) - for chan in chans - if chan["private"] - ] diff --git a/tools/plugins/hold/router.py b/tools/plugins/hold/router.py deleted file mode 100644 index 88dc740c..00000000 --- a/tools/plugins/hold/router.py +++ /dev/null @@ -1,115 +0,0 @@ -from dataclasses import dataclass -from typing import Any - -from pyln.client import Plugin, RpcError - - -class NoRouteError(Exception): - pass - - -@dataclass -class Hop: - node_id: str - channel: str - direction: int - amount_msat: int - delay: int - style: str - - def to_dict(self) -> dict[str, Any]: - return dict(self.__dict__.items()) - - -# TODO: exclude our channels where we don't have enough balance -class Router: - plugin: Plugin - - def __init__(self, plugin: Plugin) -> None: - self.plugin = plugin - - def get_route( - self, - destination: str, - amount_msat: int, - risk_factor: int, - max_cltv: int | None, - final_cltv_delta: int | None, - max_retries: int | None, - ) -> list[Hop]: - exclude: list[str] = [] - - for _ in range(max_retries if max_retries is not None else 10): - route = self._get_route( - destination, amount_msat, risk_factor, final_cltv_delta, exclude - ) - if len(route) == 0: - raise NoRouteError - - cltv_too_high = max_cltv is not None and route[0].delay > max_cltv - if not cltv_too_high: - return route - - most_expensive = Router._most_expensive_channel(route) - exclude.append(f"{most_expensive.channel}/{most_expensive.direction}") - - raise NoRouteError - - def _get_route( - self, - destination: str, - amount_msat: int, - risk_factor: int, - final_cltv_delta: int, - exclude: list[str], - ) -> list[Hop]: - try: - return Router._transform_route_res( - self.plugin.rpc.getroute( - node_id=destination, - amount_msat=amount_msat, - riskfactor=risk_factor, - cltv=final_cltv_delta if final_cltv_delta is not None else 9, - exclude=exclude, - ) - ) - except RpcError: - raise NoRouteError from None - - @staticmethod - def _most_expensive_channel(route: list[Hop]) -> Hop: - if len(route) < 2: - return route[0] - - max_hops = [] - max_delta = route[0].delay - route[1].delay - max_hops.append(route[0]) - - for i in range(1, len(route) - 1): - delta = route[i].delay - route[i + 1].delay - - if delta == max_delta: - max_hops.append(route[i]) - elif delta > max_delta: - max_hops = [route[i]] - max_delta = delta - - return max_hops[-1] - - @staticmethod - def _transform_route_res(res: dict[str, any]) -> list[Hop]: - return ( - [ - Hop( - node_id=hop["id"], - channel=hop["channel"], - direction=hop["direction"], - amount_msat=int(hop["amount_msat"]), - delay=hop["delay"], - style=hop["style"], - ) - for hop in res["route"] - ] - if "route" in res - else [] - ) diff --git a/tools/plugins/hold/server.py b/tools/plugins/hold/server.py deleted file mode 100644 index 37c58d53..00000000 --- a/tools/plugins/hold/server.py +++ /dev/null @@ -1,196 +0,0 @@ -from collections.abc import Iterable -from queue import Empty -from typing import TypeVar - -import grpc -from pyln.client import Plugin - -from plugins.hold.consts import PLUGIN_NAME, VERSION -from plugins.hold.encoder import Defaults -from plugins.hold.enums import invoice_state_final -from plugins.hold.grpc_server import GrpcServer, handle_grpc_error -from plugins.hold.hold import Hold, NoSuchInvoiceError -from plugins.hold.protos.hold_pb2 import ( - CancelRequest, - CancelResponse, - GetInfoRequest, - GetInfoResponse, - GetRouteRequest, - GetRouteResponse, - InvoiceRequest, - InvoiceResponse, - ListRequest, - ListResponse, - PayStatusRequest, - PayStatusResponse, - RoutingHintsRequest, - RoutingHintsResponse, - SettleRequest, - SettleResponse, - TrackAllRequest, - TrackAllResponse, - TrackRequest, - TrackResponse, -) -from plugins.hold.protos.hold_pb2_grpc import HoldServicer, add_HoldServicer_to_server -from plugins.hold.transformers import INVOICE_STATE_TO_GRPC, Transformers - -T = TypeVar("T") - - -def optional_default(value: T | None, default: T, fallback: T) -> T: - return value if value is not None and value != default else fallback - - -class HoldService(HoldServicer): - def __init__(self, plugin: Plugin, hold: Hold) -> None: - self._plugin = plugin - self._hold = hold - - def GetInfo( # noqa: N802 - self, - request: GetInfoRequest, # noqa: ARG002 - context: grpc.ServicerContext, # noqa: ARG002 - ) -> GetInfoResponse: - return GetInfoResponse(version=VERSION) - - def Invoice( # noqa: N802 - self, - request: InvoiceRequest, - context: grpc.ServicerContext, # noqa: ARG002 - ) -> InvoiceResponse: - return InvoiceResponse( - bolt11=self._hold.invoice( - request.payment_hash, - request.amount_msat, - request.description, - request.description_hash, - optional_default(request.expiry, 0, Defaults.Expiry), - optional_default( - request.min_final_cltv_expiry, - 0, - Defaults.MinFinalCltvExpiry, - ), - Transformers.routing_hints_from_grpc(list(request.routing_hints)), - ) - ) - - def RoutingHints( # noqa: N802 - self, - request: RoutingHintsRequest, - context: grpc.ServicerContext, # noqa: ARG002 - ) -> RoutingHintsResponse: - return Transformers.routing_hints_to_grpc(self._hold.get_private_channels(request.node)) - - def List( # noqa: N802 - self, - request: ListRequest, - context: grpc.ServicerContext, # noqa: ARG002 - ) -> ListResponse: - return ListResponse( - invoices=[ - Transformers.invoice_to_grpc(inv) - for inv in self._hold.list_invoices(request.payment_hash) - ] - ) - - def Settle( # noqa: N802 - self, - request: SettleRequest, - context: grpc.ServicerContext, # noqa: ARG002 - ) -> SettleResponse: - self._hold.settle(request.payment_preimage) - return SettleResponse() - - def Cancel( # noqa: N802 - self, - request: CancelRequest, - context: grpc.ServicerContext, # noqa: ARG002 - ) -> CancelResponse: - self._hold.cancel(request.payment_hash) - return CancelResponse() - - def Track( # noqa: N802 - self, request: TrackRequest, context: grpc.ServicerContext - ) -> Iterable[TrackResponse]: - try: - queue = self._hold.tracker.track(request.payment_hash) - invoices = self._hold.list_invoices(request.payment_hash) - - if len(invoices) == 0: - self._hold.tracker.stop_tracking(request.payment_hash, queue) - raise NoSuchInvoiceError # noqa: TRY301 - - yield TrackResponse(state=INVOICE_STATE_TO_GRPC[invoices[0].state]) - - while context.is_active(): - state = queue.get() - yield TrackResponse(state=INVOICE_STATE_TO_GRPC[state]) - - if invoice_state_final(state): - break - - self._hold.tracker.stop_tracking(request.payment_hash, queue) - except Exception as e: - handle_grpc_error(self._plugin, self.Track.__name__, context, e) - - def TrackAll( # noqa: N802 - self, - request: TrackAllRequest, # noqa: ARG002 - context: grpc.ServicerContext, - ) -> Iterable[TrackAllResponse]: - try: - queue = self._hold.tracker.track_all() - - while context.is_active(): - # Trick to stop the stream when the client cancels - try: - ev = queue.get(block=True, timeout=1) - yield TrackAllResponse( - payment_hash=ev.payment_hash, - bolt11=ev.bolt11, - state=INVOICE_STATE_TO_GRPC[ev.update], - ) - except Empty: # noqa: PERF203 - pass - - except Exception as e: - handle_grpc_error(self._plugin, self.TrackAll.__name__, context, e) - - def PayStatus( # noqa: N802 - self, - request: PayStatusRequest, - context: grpc.ServicerContext, # noqa: ARG002 - ) -> PayStatusResponse: - return Transformers.pay_status_response_to_grpc( - self._plugin.rpc.paystatus(request.bolt11 if request.bolt11 != "" else None) - ) - - def GetRoute( # noqa: N802 - self, - request: GetRouteRequest, - context: grpc.ServicerContext, # noqa: ARG002 - ) -> GetRouteResponse: - route = self._hold.router.get_route( - request.destination, - request.amount_msat, - request.risk_factor, - request.max_cltv if request.max_cltv != 0 else None, - request.final_cltv_delta if request.final_cltv_delta != 0 else None, - request.max_retries if request.max_retries != 0 else None, - ) - return GetRouteResponse( - hops=Transformers.route_to_grpc(route), - fees_msat=route[0].amount_msat - request.amount_msat, - ) - - -class Server(GrpcServer): - _hold: Hold - - def __init__(self, plugin: Plugin, hold: Hold) -> None: - super().__init__(PLUGIN_NAME, plugin) - self._hold = hold - - def _register_service(self) -> None: - add_HoldServicer_to_server(HoldService(self._plugin, self._hold), self._server) diff --git a/tools/plugins/hold/settler.py b/tools/plugins/hold/settler.py deleted file mode 100644 index 558ec68f..00000000 --- a/tools/plugins/hold/settler.py +++ /dev/null @@ -1,110 +0,0 @@ -from dataclasses import dataclass - -from pyln.client.plugin import Request - -from plugins.hold.enums import HtlcFailureMessage, HtlcState -from plugins.hold.invoice import HoldInvoice, Htlc, InvoiceState -from plugins.hold.tracker import Tracker - - -@dataclass -class HtlcRequest: - short_channel_id: str - channel_id: int - request: Request - - -class Settler: - _tracker: Tracker - _htlcs: dict[str, list[HtlcRequest]] - - def __init__(self, tracker: Tracker) -> None: - self._htlcs = {} - self._tracker = tracker - - def add_htlc(self, payment_hash: str, request: Request, htlc: Htlc) -> None: - if payment_hash not in self._htlcs: - self._htlcs[payment_hash] = [] - - self._htlcs[payment_hash].append( - HtlcRequest( - short_channel_id=htlc.short_channel_id, - channel_id=htlc.channel_id, - request=request, - ) - ) - - def settle(self, invoice: HoldInvoice) -> None: - for htlc in self._pop_requests(invoice.payment_hash): - self.settle_callback(htlc.request, invoice.payment_preimage) - Settler._update_htlc_state(invoice, htlc, HtlcState.Paid) - - invoice.set_state(self._tracker, InvoiceState.Paid) - - def cancel(self, invoice: HoldInvoice) -> None: - for htlc in self._pop_requests(invoice.payment_hash): - self.fail_callback(htlc.request, HtlcFailureMessage.IncorrectPaymentDetails) - Settler._update_htlc_state(invoice, htlc, HtlcState.Cancelled) - - invoice.set_state(self._tracker, InvoiceState.Cancelled) - - def pending_payment_hashes(self) -> list[str]: - return list(self._htlcs.keys()) - - def find_htlc_request(self, payment_hash: str, htlc: Htlc) -> Request | None: - if payment_hash not in self._htlcs: - return None - - return next( - ( - htlc_req.request - for htlc_req in self._htlcs[payment_hash] - if htlc_req.short_channel_id == htlc.short_channel_id - and htlc_req.channel_id == htlc.channel_id - ), - None, - ) - - def remove_htlc(self, payment_hash: str, to_remove: Htlc) -> None: - if payment_hash not in self._htlcs: - return - - self._htlcs[payment_hash] = [ - htlc - for htlc in self._htlcs[payment_hash] - if htlc.short_channel_id != to_remove.short_channel_id - or htlc.channel_id != to_remove.channel_id - ] - - def _pop_requests(self, payment_hash: str) -> list[HtlcRequest]: - return self._htlcs.pop(payment_hash, []) - - @staticmethod - def _update_htlc_state(invoice: HoldInvoice, htlc: HtlcRequest, new_state: HtlcState) -> None: - invoice.htlcs.find_htlc(htlc.short_channel_id, htlc.channel_id).state = new_state - - @staticmethod - def fail_callback(req: Request, message: HtlcFailureMessage) -> None: - req.set_result( - { - "result": "fail", - "failure_message": message, - } - ) - - @staticmethod - def continue_callback(req: Request) -> None: - req.set_result( - { - "result": "continue", - } - ) - - @staticmethod - def settle_callback(req: Request, preimage: str) -> None: - req.set_result( - { - "result": "resolve", - "payment_key": preimage, - } - ) diff --git a/tools/plugins/hold/tests/__init__.py b/tools/plugins/hold/tests/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tools/plugins/hold/tests/test_certs.py b/tools/plugins/hold/tests/test_certs.py deleted file mode 100644 index 6e9a04f7..00000000 --- a/tools/plugins/hold/tests/test_certs.py +++ /dev/null @@ -1,42 +0,0 @@ -import os -from pathlib import Path - -from cryptography import x509 - -from plugins.hold.certs import get_cert -from plugins.hold.utils import time_now - -SUBJECT = "test" -CA_NAME = "ca" -CLIENT_NAME = "client" - - -class TestCerts: - def test_create_cert(self) -> None: - cert = get_cert(SUBJECT, "", CA_NAME) - parsed = x509.load_pem_x509_certificate(cert.cert) - assert parsed.not_valid_after.year >= time_now().year + 9 - - for path in [Path(f"{CA_NAME}.pem"), Path(f"{CA_NAME}-key.pem")]: - assert Path.exists(path) - - def test_open_cert(self) -> None: - ca_cert = get_cert(SUBJECT, "", CA_NAME) - - assert ca_cert.cert == Path.read_bytes(Path(f"{CA_NAME}.pem")) - assert ca_cert.key == Path.read_bytes(Path(f"{CA_NAME}-key.pem")) - - def test_create_from_ca(self) -> None: - cert = get_cert(SUBJECT, "", CA_NAME) - get_cert(SUBJECT, "", CLIENT_NAME, cert.key) - - cert_verification = os.popen( - f"openssl verify -verbose -CAfile {CA_NAME}.pem {CLIENT_NAME}.pem" - ).read() - assert cert_verification.strip() == f"{CLIENT_NAME}.pem: OK" - - def test_clean(self) -> None: - for path in [ - f"{name}{suffix}" for name in [CA_NAME, CLIENT_NAME] for suffix in [".pem", "-key.pem"] - ]: - Path(path).unlink() diff --git a/tools/plugins/hold/tests/test_encoder.py b/tools/plugins/hold/tests/test_encoder.py deleted file mode 100644 index 3238cf1e..00000000 --- a/tools/plugins/hold/tests/test_encoder.py +++ /dev/null @@ -1,171 +0,0 @@ -import random - -import pytest -from bolt11.models.routehint import Route, RouteHint - -from plugins.hold.encoder import Defaults, Encoder, get_network_prefix, get_payment_secret -from plugins.hold.tests.utils import RpcPlugin, cln_con -from plugins.hold.utils import time_now - -route_hint = RouteHint( - routes=[ - Route( - public_key="02e425026d928083eb432886c4c209abff4aea1e6bafca208671fdb0e42be4b63d", - short_channel_id="117x1x0", - base_fee=1000, - ppm_fee=1, - cltv_expiry_delta=80, - ) - ] -) - - -class TestEncoder: - # noinspection PyTypeChecker - en = Encoder(RpcPlugin()) - - @pytest.mark.parametrize( - ("network", "prefix"), - [ - ("bitcoin", "bc"), - ("testnet", "tb"), - ("signet", "tbs"), - ("regtest", "bcrt"), - ("unknown", "bc"), - ("not found", "bc"), - ], - ) - def test_get_network_prefix(self, network: str, prefix: str) -> None: - assert get_network_prefix(network) == prefix - - def test_get_payment_secret(self) -> None: - assert get_payment_secret("val") == "val" - assert len(get_payment_secret(None)) == 64 - - def test_init(self) -> None: - self.en.init() - assert self.en._prefix == "bcrt" # noqa: SLF001 - - features = self.en._features # noqa: SLF001 - assert features is not None - - def test_encode(self) -> None: - payment_hash = random.randbytes(32).hex() - amount = 10_000 - description = "memo" - - invoice = self.en.encode(payment_hash, amount, description) - dec = cln_con("decode", invoice) - - assert dec["valid"] - assert dec["payment_secret"] != "" - assert dec["amount_msat"] == amount - assert dec["expiry"] == Defaults.Expiry - assert dec["description"] == description - assert dec["payment_hash"] == payment_hash - assert dec["created_at"] - int(time_now().timestamp()) < 2 - assert dec["min_final_cltv_expiry"] == Defaults.MinFinalCltvExpiry - - def test_encode_empty_description(self) -> None: - invoice = self.en.encode( - random.randbytes(32).hex(), - 10_000, - ) - - dec = cln_con("decode", invoice) - assert dec["valid"] - assert dec["description"] == "" - - def test_encode_description_hash(self) -> None: - description_hash = "c84cfc6d31834f01b1c36af114883dd9eb700a4dfef4adbcff7b9af401d54ce7" - invoice = self.en.encode( - random.randbytes(32).hex(), - 10_000, - description_hash=description_hash, - ) - - dec = cln_con("decode", invoice) - assert dec["valid"] - assert dec["description_hash"] == description_hash - - def test_encode_description_hash_invalid(self) -> None: - description_hash = "c84cfc6d31834f01b1c36af114883dd9eb700a4dfef4adbcff7b9af401d54ce" - - with pytest.raises(ValueError, match="description_hash must be 64 bytes"): - self.en.encode( - random.randbytes(32).hex(), - 10_000, - description_hash=description_hash, - ) - - @pytest.mark.parametrize("expiry", [1, 60, 1200, 3600, 3601, 7200, 86400]) - def test_encode_expiry(self, expiry: int) -> None: - invoice = self.en.encode(random.randbytes(32).hex(), 10_000, expiry=expiry) - dec = cln_con("decode", invoice) - - assert dec["expiry"] == expiry - - @pytest.mark.parametrize("cltv", [1, 2, 3, 80, 90, 144, 150]) - def test_encode_min_final_cltv_expiry(self, cltv: int) -> None: - invoice = self.en.encode( - random.randbytes(32).hex(), - 10_000, - min_final_cltv_expiry=cltv, - ) - dec = cln_con("decode", invoice) - - assert dec["valid"] - assert dec["min_final_cltv_expiry"] == cltv - - def test_encode_payment_secret(self) -> None: - payment_secret = random.randbytes(32).hex() - - invoice = self.en.encode( - random.randbytes(32).hex(), - 10_000, - "memo", - payment_secret=payment_secret, - ) - - dec = cln_con("decode", invoice) - - assert dec["valid"] - assert dec["payment_secret"] == payment_secret - - def test_encode_route_hints(self) -> None: - invoice = self.en.encode( - random.randbytes(32).hex(), - 10_000, - "memo", - route_hints=[route_hint], - ) - - dec = cln_con("decode", invoice) - assert dec["valid"] - - routes = dec["routes"] - assert len(routes) == 1 - - route = routes[0] - assert len(route) == 1 - - hop = route[0] - assert hop["pubkey"] == route_hint.routes[0].public_key - assert hop["fee_base_msat"] == route_hint.routes[0].base_fee - assert hop["short_channel_id"] == route_hint.routes[0].short_channel_id - assert hop["fee_proportional_millionths"] == route_hint.routes[0].ppm_fee - - def test_encode_route_hints_multiple(self) -> None: - invoice = self.en.encode( - random.randbytes(32).hex(), - 10_000, - "memo", - route_hints=[route_hint, route_hint], - ) - - dec = cln_con("decode", invoice) - assert dec["valid"] - - routes = dec["routes"] - assert len(routes) == 2 - assert routes[0] == routes[1] diff --git a/tools/plugins/hold/tests/test_grpc.py b/tools/plugins/hold/tests/test_grpc.py deleted file mode 100644 index 67a3cf2a..00000000 --- a/tools/plugins/hold/tests/test_grpc.py +++ /dev/null @@ -1,593 +0,0 @@ -import concurrent.futures -import random -import time -from hashlib import sha256 -from pathlib import Path - -import grpc -import pytest - -# noinspection PyProtectedMember -from grpc._channel import _InactiveRpcError, _MultiThreadedRendezvous - -from plugins.hold.config import OptionDefaults -from plugins.hold.consts import VERSION -from plugins.hold.encoder import Defaults -from plugins.hold.protos.hold_pb2 import ( - INVOICE_ACCEPTED, - INVOICE_CANCELLED, - INVOICE_PAID, - INVOICE_UNPAID, - CancelRequest, - GetInfoRequest, - GetInfoResponse, - HtlcState, - InvoiceRequest, - InvoiceState, - ListRequest, - ListResponse, - PayStatusRequest, - PayStatusResponse, - RoutingHintsRequest, - RoutingHintsResponse, - SettleRequest, - TrackAllRequest, - TrackRequest, -) -from plugins.hold.protos.hold_pb2_grpc import HoldStub -from plugins.hold.tests.utils import ( - LndNode, - LndPay, - cln_con, - connect_peers, - lnd, - start_plugin, - stop_plugin, -) -from plugins.hold.utils import time_now - - -def add_hold_invoice(cl: HoldStub) -> tuple[str, str, str]: - payment_preimage = random.randbytes(32) - payment_hash = sha256(payment_preimage).hexdigest() - - invoice = cl.Invoice( - InvoiceRequest(payment_hash=payment_hash, amount_msat=100000), - ).bolt11 - - return payment_preimage.hex(), payment_hash, invoice - - -class TestGrpc: - @pytest.fixture(scope="class", autouse=True) - def cl(self) -> HoldStub: - stop_plugin(cln_con) - start_plugin(cln_con) - cln_con("dev-wipeholdinvoices") - - connect_peers(cln_con) - - cert_path = Path("../docker/regtest/data/cln/hold") - creds = grpc.ssl_channel_credentials( - root_certificates=cert_path.joinpath("ca.pem").read_bytes(), - private_key=cert_path.joinpath("client-key.pem").read_bytes(), - certificate_chain=cert_path.joinpath("client.pem").read_bytes(), - ) - channel = grpc.secure_channel( - f"127.0.0.1:{OptionDefaults.GrpcPort}", - creds, - options=(("grpc.ssl_target_name_override", "hold"),), - ) - client = HoldStub(channel) - - yield client - - channel.close() - - cln_con("dev-wipeholdinvoices") - stop_plugin(cln_con) - - def test_get_info(self, cl: HoldStub) -> None: - res: GetInfoResponse = cl.GetInfo(GetInfoRequest()) - assert res.version == VERSION - - def test_invoice(self, cl: HoldStub) -> None: - amount = 10_000 - payment_hash = random.randbytes(32).hex() - - res = cl.Invoice(InvoiceRequest(payment_hash=payment_hash, amount_msat=amount)) - assert res.bolt11 != "" - - dec = cln_con("decode", res.bolt11) - assert dec["valid"] - assert dec["amount_msat"] == amount - assert dec["payment_hash"] == payment_hash - - def test_invoice_defaults(self, cl: HoldStub) -> None: - amount = 10_000 - payment_hash = random.randbytes(32).hex() - - res = cl.Invoice(InvoiceRequest(payment_hash=payment_hash, amount_msat=amount)) - assert res.bolt11 != "" - - dec = cln_con("decode", res.bolt11) - assert dec["valid"] - assert dec["description"] == "" - assert dec["amount_msat"] == amount - assert dec["expiry"] == Defaults.Expiry - assert dec["payment_hash"] == payment_hash - assert dec["min_final_cltv_expiry"] == Defaults.MinFinalCltvExpiry - - @pytest.mark.parametrize("description", ["some", "text", "Send to BTC address"]) - def test_invoice_description(self, cl: HoldStub, description: str) -> None: - invoice = cl.Invoice( - InvoiceRequest( - payment_hash=random.randbytes(32).hex(), - amount_msat=10_000, - description=description, - ) - ).bolt11 - - dec = cln_con("decode", invoice) - assert dec["valid"] - assert dec["description"] == description - - def test_invoice_description_hash(self, cl: HoldStub) -> None: - description_hash = "e9a88bde48ab1318da7e914405c144a8a4f898d4e24da23e10bcdbfd7978e9e7" - invoice = cl.Invoice( - InvoiceRequest( - payment_hash=random.randbytes(32).hex(), - amount_msat=10_000, - description_hash=description_hash, - ) - ).bolt11 - - dec = cln_con("decode", invoice) - assert dec["valid"] - assert dec["description_hash"] == description_hash - - @pytest.mark.parametrize("expiry", [1, 2, 3, 3600, 24000, 86400]) - def test_invoice_expiry(self, cl: HoldStub, expiry: int) -> None: - invoice = cl.Invoice( - InvoiceRequest( - payment_hash=random.randbytes(32).hex(), - amount_msat=10_000, - expiry=expiry, - ) - ).bolt11 - - dec = cln_con("decode", invoice) - assert dec["valid"] - assert dec["expiry"] == expiry - - @pytest.mark.parametrize("min_final_cltv_expiry", [1, 2, 3, 80, 144, 150, 200]) - def test_invoice_min_final_cltv_expiry( - self, - cl: HoldStub, - min_final_cltv_expiry: int, - ) -> None: - invoice = cl.Invoice( - InvoiceRequest( - payment_hash=random.randbytes(32).hex(), - amount_msat=10_000, - min_final_cltv_expiry=min_final_cltv_expiry, - ) - ).bolt11 - - dec = cln_con("decode", invoice) - assert dec["valid"] - assert dec["min_final_cltv_expiry"] == min_final_cltv_expiry - - def test_invoice_routing_hints(self, cl: HoldStub) -> None: - lnd_pubkey = lnd(LndNode.One, "getinfo")["identity_pubkey"] - routing_hints: RoutingHintsResponse = cl.RoutingHints(RoutingHintsRequest(node=lnd_pubkey)) - - invoice = cl.Invoice( - InvoiceRequest( - payment_hash=random.randbytes(32).hex(), - amount_msat=10_000, - routing_hints=routing_hints.hints, - ) - ).bolt11 - - dec = cln_con("decode", invoice) - assert dec["valid"] - assert len(dec["routes"]) == 1 - assert len(dec["routes"][0]) == 1 - - hop = dec["routes"][0][0] - hint = routing_hints.hints[0].hops[0] - - assert hop["pubkey"] == hint.public_key - assert hop["fee_base_msat"] == hint.base_fee - assert hop["short_channel_id"] == hint.short_channel_id - assert hop["fee_proportional_millionths"] == hint.ppm_fee - - def test_invoice_routing_hints_multiple(self, cl: HoldStub) -> None: - lnd_pubkey = lnd(LndNode.One, "getinfo")["identity_pubkey"] - routing_hints: RoutingHintsResponse = cl.RoutingHints(RoutingHintsRequest(node=lnd_pubkey)) - - routing_hints.hints.append(routing_hints.hints[0]) - - invoice = cl.Invoice( - InvoiceRequest( - payment_hash=random.randbytes(32).hex(), - amount_msat=10_000, - routing_hints=routing_hints.hints, - ) - ).bolt11 - - dec = cln_con("decode", invoice) - assert dec["valid"] - assert len(dec["routes"]) == 2 - assert len(dec["routes"][0]) == 1 - assert len(dec["routes"][1]) == 1 - - assert dec["routes"][0] == dec["routes"][1] - - def test_routing_hints(self, cl: HoldStub) -> None: - lnd_pubkey = lnd(LndNode.One, "getinfo")["identity_pubkey"] - - res: RoutingHintsResponse = cl.RoutingHints(RoutingHintsRequest(node=lnd_pubkey)) - assert len(res.hints) == 1 - - hops = res.hints[0].hops - assert len(hops) == 1 - - hop = hops[0] - - channel_info = next( - chan - for chan in cln_con(f"listpeerchannels {lnd_pubkey}")["channels"] - if chan["short_channel_id"] == hop.short_channel_id - ) - - updates = channel_info["updates"]["remote"] - - assert hop.base_fee == updates["fee_base_msat"] - assert hop.cltv_expiry_delta == updates["cltv_expiry_delta"] - assert hop.ppm_fee == updates["fee_proportional_millionths"] - assert hop.short_channel_id == channel_info["short_channel_id"] - - def test_routing_hints_none_found(self, cl: HoldStub) -> None: - res: RoutingHintsResponse = cl.RoutingHints(RoutingHintsRequest(node="not found")) - assert len(res.hints) == 0 - - def test_list(self, cl: HoldStub) -> None: - invoices = cl.List(ListRequest()).invoices - assert len(invoices) > 1 - - def test_list_single(self, cl: HoldStub) -> None: - amount_msat = 10_000 - payment_hash = random.randbytes(32).hex() - - cl.Invoice(InvoiceRequest(payment_hash=payment_hash, amount_msat=amount_msat)) - - invoice = cl.List(ListRequest(payment_hash=payment_hash)).invoices - - assert len(invoice) == 1 - assert invoice[0].amount_msat == amount_msat - assert invoice[0].payment_hash == payment_hash - - def test_list_created_at(self, cl: HoldStub) -> None: - payment_hash = random.randbytes(32).hex() - cl.Invoice(InvoiceRequest(payment_hash=payment_hash, amount_msat=10_000)) - res: ListResponse = cl.List(ListRequest(payment_hash=payment_hash)) - - now = int(time_now().timestamp()) - assert now - res.invoices[0].created_at < 2 - - def test_list_not_found(self, cl: HoldStub) -> None: - payment_hash = random.randbytes(32).hex() - invoices = cl.List(ListRequest(payment_hash=payment_hash)).invoices - - assert len(invoices) == 0 - - def test_settle_accepted(self, cl: HoldStub) -> None: - payment_preimage, payment_hash, invoice = add_hold_invoice(cl) - - pay = LndPay(LndNode.One, invoice) - pay.start() - - time.sleep(1) - - assert cl.List(ListRequest(payment_hash=payment_hash)).invoices[0].state == INVOICE_ACCEPTED - - cl.Settle(SettleRequest(payment_preimage=payment_preimage)) - pay.join() - - assert pay.res["status"] == "SUCCEEDED" - - assert cl.List(ListRequest(payment_hash=payment_hash)).invoices[0].state == INVOICE_PAID - - def test_settle_unpaid(self, cl: HoldStub) -> None: - payment_preimage, _, _ = add_hold_invoice(cl) - - with pytest.raises(_InactiveRpcError) as err: - cl.Settle(SettleRequest(payment_preimage=payment_preimage)) - - assert err.value.code() == grpc.StatusCode.INTERNAL - assert err.value.details() == "illegal hold invoice state transition (unpaid -> paid)" - - def test_settle_non_existent(self, cl: HoldStub) -> None: - payment_preimage = random.randbytes(32).hex() - - with pytest.raises(_InactiveRpcError) as err: - cl.Settle(SettleRequest(payment_preimage=payment_preimage)) - - assert err.value.code() == grpc.StatusCode.INTERNAL - assert err.value.details() == "NoSuchInvoiceError()" - - def test_cancel_unpaid(self, cl: HoldStub) -> None: - payment_preimage, payment_hash, invoice = add_hold_invoice(cl) - cl.Cancel(CancelRequest(payment_hash=payment_hash)) - - assert ( - cl.List(ListRequest(payment_hash=payment_hash)).invoices[0].state == INVOICE_CANCELLED - ) - - def test_cancel_non_existent(self, cl: HoldStub) -> None: - payment_hash = random.randbytes(32).hex() - - with pytest.raises(_InactiveRpcError) as err: - cl.Cancel(CancelRequest(payment_hash=payment_hash)) - - assert err.value.code() == grpc.StatusCode.INTERNAL - assert err.value.details() == "NoSuchInvoiceError()" - - def test_track_non_existent(self, cl: HoldStub) -> None: - payment_hash = random.randbytes(32).hex() - - with pytest.raises(_MultiThreadedRendezvous) as err: - cl.Track(TrackRequest(payment_hash=payment_hash)).__next__() - - assert err.value.code() == grpc.StatusCode.INTERNAL - assert err.value.details() == "NoSuchInvoiceError()" - - def test_track_settle(self, cl: HoldStub) -> None: - payment_preimage, payment_hash, invoice = add_hold_invoice(cl) - - def track_states() -> list[InvoiceState]: - return [update.state for update in cl.Track(TrackRequest(payment_hash=payment_hash))] - - with concurrent.futures.ThreadPoolExecutor() as pool: - fut = pool.submit(track_states) - - pay = LndPay(LndNode.One, invoice) - pay.start() - time.sleep(1) - - invoice_state = cl.List(ListRequest(payment_hash=payment_hash)).invoices[0] - assert len(invoice_state.htlcs) == 1 - assert invoice_state.htlcs[0].state == HtlcState.HTLC_ACCEPTED - assert invoice_state.htlcs[0].short_channel_id != "" - - cl.Settle(SettleRequest(payment_preimage=payment_preimage)) - pay.join() - - assert fut.result() == [ - INVOICE_UNPAID, - INVOICE_ACCEPTED, - INVOICE_PAID, - ] - - invoice_state = cl.List(ListRequest(payment_hash=payment_hash)).invoices[0] - assert len(invoice_state.htlcs) == 1 - assert invoice_state.htlcs[0].state == HtlcState.HTLC_SETTLED - - def test_track_cancel(self, cl: HoldStub) -> None: - _, payment_hash, invoice = add_hold_invoice(cl) - - def track_states() -> list[InvoiceState]: - return [update.state for update in cl.Track(TrackRequest(payment_hash=payment_hash))] - - with concurrent.futures.ThreadPoolExecutor() as pool: - fut = pool.submit(track_states) - - pay = LndPay(LndNode.One, invoice) - pay.start() - time.sleep(1) - - cl.Cancel(CancelRequest(payment_hash=payment_hash)) - pay.join() - - assert fut.result() == [ - INVOICE_UNPAID, - INVOICE_ACCEPTED, - INVOICE_CANCELLED, - ] - - invoice_state = cl.List(ListRequest(payment_hash=payment_hash)).invoices[0] - assert len(invoice_state.htlcs) == 1 - assert invoice_state.htlcs[0].state == HtlcState.HTLC_CANCELLED - - def test_track_multiple(self, cl: HoldStub) -> None: - _, payment_hash, invoice = add_hold_invoice(cl) - - def track_states() -> list[InvoiceState]: - return [update.state for update in cl.Track(TrackRequest(payment_hash=payment_hash))] - - with concurrent.futures.ThreadPoolExecutor() as pool: - futs = [pool.submit(track_states), pool.submit(track_states)] - - pay = LndPay(LndNode.One, invoice) - pay.start() - time.sleep(1) - - cl.Cancel(CancelRequest(payment_hash=payment_hash)) - pay.join() - - for res in [fut.result() for fut in futs]: - assert res == [ - INVOICE_UNPAID, - INVOICE_ACCEPTED, - INVOICE_CANCELLED, - ] - - def test_track_cancelled_sub(self, cl: HoldStub) -> None: - _, payment_hash, invoice = add_hold_invoice(cl) - - sub = cl.Track(TrackRequest(payment_hash=payment_hash)) - - for update in sub: - assert update.state == INVOICE_UNPAID - break - - assert sub.cancel() - - pay = LndPay(LndNode.One, invoice) - pay.start() - time.sleep(1) - - cl.Cancel(CancelRequest(payment_hash=payment_hash)) - pay.join() - - # Make sure the plugin is still alive - invoice_res = cl.List(ListRequest(payment_hash=payment_hash)).invoices[0] - assert invoice_res.bolt11 == invoice - assert invoice_res.state == INVOICE_CANCELLED - - def test_track_multiple_cancelled_sub(self, cl: HoldStub) -> None: - _, payment_hash, invoice = add_hold_invoice(cl) - - def track_states(cancel: bool) -> list[InvoiceState]: - if cancel: - sub = cl.Track(TrackRequest(payment_hash=payment_hash)) - - updates = [] - for update in sub: - updates = [update.state] - sub.cancel() - break - - return updates - - return [update.state for update in cl.Track(TrackRequest(payment_hash=payment_hash))] - - with concurrent.futures.ThreadPoolExecutor(2) as pool: - futs = [ - pool.submit(track_states, True), - pool.submit(track_states, False), - ] - - pay = LndPay(LndNode.One, invoice) - pay.start() - time.sleep(1) - - cl.Cancel(CancelRequest(payment_hash=payment_hash)) - pay.join() - - res = [fut.result() for fut in futs] - assert res[0] == [INVOICE_UNPAID] - assert res[1] == [ - INVOICE_UNPAID, - INVOICE_ACCEPTED, - INVOICE_CANCELLED, - ] - - def test_track_all(self, cl: HoldStub) -> None: - expected_events = 6 - - def track_states() -> list[tuple[str, str, str]]: - evs = [] - - sub = cl.TrackAll(TrackAllRequest()) - for ev in sub: - evs.append((ev.payment_hash, ev.bolt11, ev.state)) - if len(evs) == expected_events: - sub.cancel() - break - - return evs - - with concurrent.futures.ThreadPoolExecutor() as pool: - fut = pool.submit(track_states) - - _, payment_hash_created, invoice_created = add_hold_invoice(cl) - _, payment_hash_cancelled, invoice_cancelled = add_hold_invoice(cl) - ( - payment_preimage_settled, - payment_hash_settled, - invoice_settled, - ) = add_hold_invoice(cl) - - cl.Cancel(CancelRequest(payment_hash=payment_hash_cancelled)) - - pay = LndPay(LndNode.One, invoice_settled) - pay.start() - time.sleep(1) - - cl.Settle(SettleRequest(payment_preimage=payment_preimage_settled)) - pay.join() - - res = fut.result() - assert len(res) == expected_events - assert res == [ - (payment_hash_created, invoice_created, INVOICE_UNPAID), - (payment_hash_cancelled, invoice_cancelled, INVOICE_UNPAID), - (payment_hash_settled, invoice_settled, INVOICE_UNPAID), - (payment_hash_cancelled, invoice_cancelled, INVOICE_CANCELLED), - (payment_hash_settled, invoice_settled, INVOICE_ACCEPTED), - (payment_hash_settled, invoice_settled, INVOICE_PAID), - ] - - def test_pay_status_empty(self, cl: HoldStub) -> None: - _, _, invoice = add_hold_invoice(cl) - res: PayStatusResponse = cl.PayStatus(PayStatusRequest(bolt11=invoice)) - assert res.status == [] - - def test_pay_status_success(self, cl: HoldStub) -> None: - amount = 100 - inv_res = lnd(LndNode.One, "addinvoice", str(amount)) - cln_con("pay", inv_res["payment_request"]) - - res: PayStatusResponse = cl.PayStatus(PayStatusRequest(bolt11=inv_res["payment_request"])) - assert len(res.status) == 1 - - status = res.status[0] - - assert status.bolt11 == inv_res["payment_request"] - assert status.amount_msat == amount * 1000 - assert status.destination == lnd(LndNode.One, "getinfo")["identity_pubkey"] - - assert len(status.attempts) >= 1 - attempt = status.attempts[len(status.attempts) - 1] - - assert attempt.strategy == "Initial attempt" - assert attempt.start_time > 0 - assert attempt.age_in_seconds in [0, 1] - assert attempt.end_time > 0 - assert attempt.state == PayStatusResponse.PayStatus.Attempt.ATTEMPT_COMPLETED - assert attempt.success.id > 0 - assert ( - attempt.success.payment_preimage - == lnd(LndNode.One, "lookupinvoice", inv_res["r_hash"])["r_preimage"] - ) - - def test_pay_status_failure(self, cl: HoldStub) -> None: - amount = 100 - inv_res = lnd(LndNode.One, "addinvoice", str(amount)) - lnd(LndNode.One, "cancelinvoice", inv_res["r_hash"]) - cln_con("pay", inv_res["payment_request"]) - - res: PayStatusResponse = cl.PayStatus(PayStatusRequest(bolt11=inv_res["payment_request"])) - assert len(res.status) == 1 - - status = res.status[0] - assert len(status.attempts) == 1 - failure: PayStatusResponse.PayStatus.Attempt.Failure = status.attempts[0].failure - - assert failure.code == 203 - assert ( - failure.message - == "failed: WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS (reply from remote)" - ) - assert failure.data.id > 0 - assert failure.data.fail_codename == "WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS" - assert failure.data.fail_code == 16399 - assert failure.data.erring_index == 1 - assert failure.data.erring_node == lnd(LndNode.One, "getinfo")["identity_pubkey"] - - def test_pay_status_all(self, cl: HoldStub) -> None: - res: PayStatusResponse = cl.PayStatus(PayStatusRequest()) - assert len(res.status) > 1 diff --git a/tools/plugins/hold/tests/test_plugin.py b/tools/plugins/hold/tests/test_plugin.py deleted file mode 100644 index 41a02163..00000000 --- a/tools/plugins/hold/tests/test_plugin.py +++ /dev/null @@ -1,724 +0,0 @@ -import json -import random -import time -import uuid -from hashlib import sha256 - -import bolt11 -import pytest -from bolt11.types import MilliSatoshi - -from plugins.hold.consts import OVERPAYMENT_FACTOR, PLUGIN_NAME -from plugins.hold.encoder import Defaults -from plugins.hold.tests.utils import ( - PLUGIN_PATH, - CliCaller, - LndNode, - LndPay, - cln_con, - connect_peers, - format_json, - lnd, - start_plugin, - stop_plugin, -) - - -def add_hold_invoice(cln: CliCaller, amount_msat: int = 100_000) -> tuple[str, str, str]: - payment_preimage = random.randbytes(32) - payment_hash = sha256(payment_preimage).hexdigest() - - invoice = cln( - "holdinvoice", - payment_hash, - f"{amount_msat}", - )["bolt11"] - - return payment_preimage.hex(), payment_hash, invoice - - -class TestHold: - @pytest.fixture(scope="class", autouse=True) - def cln(self) -> CliCaller: - stop_plugin(cln_con) - start_plugin(cln_con) - cln_con("dev-wipeholdinvoices") - - connect_peers(cln_con) - - yield cln_con - - cln_con("dev-wipeholdinvoices") - stop_plugin(cln_con) - - def test_add(self, cln: CliCaller) -> None: - payment_hash = random.randbytes(32).hex() - - cln_res = cln("holdinvoice", payment_hash, "10000") - assert "bolt11" in cln_res - - hold_invoices = cln("listholdinvoices")["holdinvoices"] - assert len(hold_invoices) == 1 - assert hold_invoices[0]["state"] == "unpaid" - assert hold_invoices[0]["payment_preimage"] is None - assert hold_invoices[0]["bolt11"] == cln_res["bolt11"] - assert hold_invoices[0]["payment_hash"] == payment_hash - - def test_add_defaults(self, cln: CliCaller) -> None: - amount = 10_000 - payment_hash = random.randbytes(32).hex() - - invoice = cln("holdinvoice", payment_hash, str(amount))["bolt11"] - - dec = cln("decode", invoice) - assert dec["valid"] - assert dec["description"] == "" - assert dec["amount_msat"] == amount - assert dec["expiry"] == Defaults.Expiry - assert dec["payment_hash"] == payment_hash - assert dec["min_final_cltv_expiry"] == Defaults.MinFinalCltvExpiry - - @pytest.mark.parametrize("length", [30, 31, 33, 34, 64]) - def test_add_invalid_payment_hash_length(self, cln: CliCaller, length: int) -> None: - amount = 10_000 - payment_hash = random.randbytes(length).hex() - - res = cln("holdinvoice", payment_hash, str(amount)) - assert res["code"] == 2104 - assert res["message"] == "invalid payment hash length" - - @pytest.mark.parametrize("description", ["some", "text", "Send to BTC address"]) - def test_add_description(self, cln: CliCaller, description: str) -> None: - invoice = cln( - "holdinvoice", - random.randbytes(32).hex(), - "10000", - f'"{description}"', - )["bolt11"] - - dec = cln("decode", invoice) - assert dec["valid"] - assert dec["description"] == description - - @pytest.mark.parametrize("expiry", [1, 2, 3, 3600, 24000, 86400]) - def test_add_expiry(self, cln: CliCaller, expiry: int) -> None: - invoice = cln( - "-k", - "holdinvoice", - f"payment_hash={random.randbytes(32).hex()}", - "amount_msat=10000", - f"expiry={expiry}", - )["bolt11"] - - dec = cln("decode", invoice) - assert dec["valid"] - assert dec["expiry"] == expiry - - @pytest.mark.parametrize("min_final_cltv_expiry", [1, 2, 3, 80, 144, 150, 200]) - def test_add_min_final_cltv_expiry( - self, - cln: CliCaller, - min_final_cltv_expiry: int, - ) -> None: - invoice = cln( - "-k", - "holdinvoice", - f"payment_hash={random.randbytes(32).hex()}", - "amount_msat=10000", - f"min_final_cltv_expiry={min_final_cltv_expiry}", - )["bolt11"] - - dec = cln("decode", invoice) - assert dec["valid"] - assert dec["min_final_cltv_expiry"] == min_final_cltv_expiry - - def test_invoice_routing_hints(self, cln: CliCaller) -> None: - lnd_pubkey = lnd(LndNode.One, "getinfo")["identity_pubkey"] - hints = cln("routinghints", lnd_pubkey)["hints"] - - invoice = cln( - "-k", - "holdinvoice", - f"payment_hash={random.randbytes(32).hex()}", - "amount_msat=10000", - f"routing_hints={format_json(hints)}", - )["bolt11"] - - dec = cln_con("decode", invoice) - assert dec["valid"] - assert len(dec["routes"]) == 1 - assert len(dec["routes"][0]) == 1 - - hop = dec["routes"][0][0] - hint = hints[0]["routes"][0] - - assert hop["pubkey"] == hint["public_key"] - assert hop["fee_base_msat"] == hint["base_fee"] - assert hop["short_channel_id"] == hint["short_channel_id"] - assert hop["fee_proportional_millionths"] == hint["ppm_fee"] - - def test_invoice_routing_hints_multiple(self, cln: CliCaller) -> None: - lnd_pubkey = lnd(LndNode.One, "getinfo")["identity_pubkey"] - hints = cln("routinghints", lnd_pubkey)["hints"] - hints.append(hints[0]) - - invoice = cln( - "-k", - "holdinvoice", - f"payment_hash={random.randbytes(32).hex()}", - "amount_msat=10000", - f"routing_hints={format_json(hints)}", - )["bolt11"] - - dec = cln_con("decode", invoice) - assert dec["valid"] - assert len(dec["routes"]) == 2 - assert len(dec["routes"][0]) == 1 - assert len(dec["routes"][1]) == 1 - - assert dec["routes"][0] == dec["routes"][1] - - def test_add_duplicate_fail(self, cln: CliCaller) -> None: - amount = 10000 - payment_hash = random.randbytes(32).hex() - - assert "bolt11" in cln("holdinvoice", payment_hash, str(amount)) - - cln_res = cln("holdinvoice", payment_hash, str(amount)) - assert cln_res["code"] == 2101 - assert cln_res["message"] == "hold invoice with that payment hash exists already" - - def test_add_invoice_duplicate_fail(self, cln: CliCaller) -> None: - payment_hash = cln("invoice", "1000", str(uuid.uuid4()), '""')["payment_hash"] - - cln_res = cln("holdinvoice", payment_hash, "10000") - assert cln_res["code"] == 2101 - assert cln_res["message"] == "hold invoice with that payment hash exists already" - - def test_list(self, cln: CliCaller) -> None: - invoices = cln("listholdinvoices")["holdinvoices"] - assert len(invoices) > 1 - - def test_list_single(self, cln: CliCaller) -> None: - amount = 123_000 - _, payment_hash, invoice = add_hold_invoice(cln, amount) - - invoice = cln("listholdinvoices", payment_hash)["holdinvoices"] - assert len(invoice) == 1 - - assert invoice[0]["payment_hash"] == payment_hash - assert invoice[0]["amount_msat"] == amount - - def test_list_legacy_format(self, cln: CliCaller) -> None: - data = { - "state": "unpaid", - "payment_preimage": None, - "created_at": 1697995743, - "payment_hash": "e3e9513787fae9478704447fc954cbd1de61299f4656f2b5afb7d1a02628d3be", - "bolt11": "lnbcrt12323230p1pjn2k7lsp57u9d0zghvyenzmxtk4xzq2yjkgj3hspcg82jzp0szvyyqnl0cekspp5u054zdu8lt550pcyg3luj4xt680xz2vlget09dd0klg6qf3g6wlqdqqcqzzs9qxpqysgqlnxpq3fd0g9wsfvpmd0anlc6n6umef9v48wjgw8myp4c9fgsf68nt4hchp9v62s8ppqxa858gk4yyats6unr2nhv2r9jntu5sj79xxcpugvr9l", # noqa: E501 - } - - data_dump = json.dumps(data).replace('"', '\\"').replace("{", "\\{").replace("}", "\\}") - cln( - "datastore", - format_json([PLUGIN_NAME, "invoices", data["payment_hash"]]), - f'"{data_dump}"', - ) - cln( - "listdatastore", - format_json([PLUGIN_NAME, "invoices", data["payment_hash"]]), - ) - - invoices = cln("listholdinvoices", data["payment_hash"])["holdinvoices"] - assert len(invoices) == 1 - assert invoices[0]["amount_msat"] == 1232323 - - @pytest.mark.parametrize("payment_hash_param", ["", "none", "null"]) - def test_list_by_invoice(self, cln: CliCaller, payment_hash_param: str) -> None: - _, payment_hash, invoice = add_hold_invoice(cln) - - invoice_res = cln("listholdinvoices", payment_hash_param, invoice)["holdinvoices"] - assert len(invoice_res) == 1 - assert invoice_res[0]["bolt11"] == invoice - assert invoice_res[0]["payment_hash"] == payment_hash - - def test_list_by_invoice_first_param(self, cln: CliCaller) -> None: - _, payment_hash, invoice = add_hold_invoice(cln) - - invoice_res = cln("listholdinvoices", invoice)["holdinvoices"] - assert len(invoice_res) == 1 - assert invoice_res[0]["bolt11"] == invoice - assert invoice_res[0]["payment_hash"] == payment_hash - - def test_list_not_found(self, cln: CliCaller) -> None: - payment_hash = random.randbytes(32).hex() - invoices = cln("listholdinvoices", payment_hash) - - assert len(invoices["holdinvoices"]) == 0 - - def test_settle_accepted(self, cln: CliCaller) -> None: - payment_preimage, payment_hash, invoice = add_hold_invoice(cln) - - pay = LndPay(LndNode.One, invoice) - pay.start() - - time.sleep(1) - - list_invoice = cln( - "listholdinvoices", - payment_hash, - )["holdinvoices"][0] - assert list_invoice["state"] == "accepted" - for htlc in list_invoice["htlcs"]: - assert htlc["state"] == "accepted" - assert htlc["channel_id"] != 0 - assert htlc["short_channel_id"] != "" - - cln("settleholdinvoice", payment_preimage) - pay.join() - - assert pay.res["status"] == "SUCCEEDED" - - list_invoice = cln( - "listholdinvoices", - payment_hash, - )["holdinvoices"][0] - - assert list_invoice["state"] == "paid" - for htlc in list_invoice["htlcs"]: - assert htlc["state"] == "paid" - assert htlc["channel_id"] != 0 - assert htlc["short_channel_id"] != "" - - @pytest.mark.parametrize("parts", [2, 4]) - def test_settle_accepted_mpp(self, cln: CliCaller, parts: int) -> None: - payment_preimage, payment_hash, invoice = add_hold_invoice(cln) - amount = int(lnd(LndNode.One, "decodepayreq", invoice)["num_satoshis"]) - - pay = LndPay(LndNode.One, invoice, max_shard_size=int(amount / parts)) - pay.start() - - time.sleep(1) - - list_invoice = cln( - "listholdinvoices", - payment_hash, - )["holdinvoices"][0] - - assert list_invoice["state"] == "accepted" - assert len(list_invoice["htlcs"]) == parts - for htlc in list_invoice["htlcs"]: - assert htlc["state"] == "accepted" - - cln("settleholdinvoice", payment_preimage) - pay.join() - - assert pay.res["status"] == "SUCCEEDED" - assert len(pay.res["htlcs"]) == parts - - list_invoice = cln( - "listholdinvoices", - payment_hash, - )["holdinvoices"][0] - - assert list_invoice["state"] == "paid" - assert len(list_invoice["htlcs"]) == parts - for htlc in list_invoice["htlcs"]: - assert htlc["state"] == "paid" - - def test_reject_pay_settled(self, cln: CliCaller) -> None: - payment_preimage, payment_hash, invoice = add_hold_invoice(cln) - - pay = LndPay(LndNode.One, invoice) - pay.start() - - time.sleep(1) - - cln("settleholdinvoice", payment_preimage) - pay.join() - - assert pay.res["status"] == "SUCCEEDED" - - list_invoice = cln( - "listholdinvoices", - payment_hash, - )["holdinvoices"][0] - assert list_invoice["state"] == "paid" - assert len(list_invoice["htlcs"]) == 1 - assert list_invoice["htlcs"][0]["state"] == "paid" - - pay = LndPay(LndNode.Two, invoice) - pay.start() - pay.join() - - assert pay.res["status"] == "FAILED" - assert pay.res["failure_reason"] == "FAILURE_REASON_INCORRECT_PAYMENT_DETAILS" - - list_invoice = cln( - "listholdinvoices", - payment_hash, - )["holdinvoices"][0] - assert list_invoice["state"] == "paid" - assert len(list_invoice["htlcs"]) == 2 - assert list_invoice["htlcs"][0]["state"] == "paid" - assert list_invoice["htlcs"][1]["state"] == "cancelled" - - def test_reject_pay_accepted(self, cln: CliCaller) -> None: - payment_preimage, payment_hash, invoice = add_hold_invoice(cln) - - pay = LndPay(LndNode.One, invoice) - pay.start() - - time.sleep(1) - - pay_two = LndPay(LndNode.Two, invoice) - pay_two.start() - pay_two.join() - - assert pay_two.res["status"] == "FAILED" - assert pay_two.res["failure_reason"] == "FAILURE_REASON_INCORRECT_PAYMENT_DETAILS" - - list_invoice = cln( - "listholdinvoices", - payment_hash, - )["holdinvoices"][0] - assert list_invoice["state"] == "accepted" - assert len(list_invoice["htlcs"]) == 2 - assert list_invoice["htlcs"][0]["state"] == "accepted" - assert list_invoice["htlcs"][1]["state"] == "cancelled" - - cln("settleholdinvoice", payment_preimage) - pay.join() - - assert pay.res["status"] == "SUCCEEDED" - - list_invoice = cln( - "listholdinvoices", - payment_hash, - )["holdinvoices"][0] - assert list_invoice["state"] == "paid" - assert len(list_invoice["htlcs"]) == 2 - assert list_invoice["htlcs"][0]["state"] == "paid" - assert list_invoice["htlcs"][1]["state"] == "cancelled" - - def test_settle_unpaid(self, cln: CliCaller) -> None: - payment_preimage, _, _ = add_hold_invoice(cln) - - err_res = cln("settleholdinvoice", payment_preimage) - assert err_res["code"] == 2103 - assert err_res["message"] == "illegal hold invoice state transition (unpaid -> paid)" - - def test_settle_cancelled(self, cln: CliCaller) -> None: - payment_preimage, payment_hash, _ = add_hold_invoice(cln) - - cln("cancelholdinvoice", payment_hash) - err_res = cln("settleholdinvoice", payment_preimage) - assert err_res["code"] == 2103 - assert err_res["message"] == "illegal hold invoice state transition (cancelled -> paid)" - - def test_settle_non_existent(self, cln: CliCaller) -> None: - payment_preimage = random.randbytes(32).hex() - res = cln("settleholdinvoice", payment_preimage) - - assert res["code"] == 2102 - assert res["message"] == "hold invoice with that payment hash does not exist" - - def test_cancel_unpaid(self, cln: CliCaller) -> None: - payment_hash = random.randbytes(32).hex() - cln("holdinvoice", payment_hash, "100000") - - assert len(cln("cancelholdinvoice", payment_hash)) == 0 - assert ( - cln( - "listholdinvoices", - payment_hash, - )["holdinvoices"][0]["state"] - == "cancelled" - ) - - def test_cancel_accepted(self, cln: CliCaller) -> None: - _, payment_hash, invoice = add_hold_invoice(cln) - - pay = LndPay(LndNode.One, invoice) - pay.start() - - time.sleep(0.5) - - list_invoice = cln( - "listholdinvoices", - payment_hash, - )["holdinvoices"][0] - assert list_invoice["state"] == "accepted" - assert len(list_invoice["htlcs"]) == 1 - assert list_invoice["htlcs"][0]["state"] == "accepted" - - cln("cancelholdinvoice", payment_hash) - pay.join() - - assert pay.res["status"] == "FAILED" - assert pay.res["failure_reason"] == "FAILURE_REASON_INCORRECT_PAYMENT_DETAILS" - - list_invoice = cln( - "listholdinvoices", - payment_hash, - )["holdinvoices"][0] - assert list_invoice["state"] == "cancelled" - assert len(list_invoice["htlcs"]) == 1 - assert list_invoice["htlcs"][0]["state"] == "cancelled" - - def test_cancel_cancelled(self, cln: CliCaller) -> None: - payment_hash = random.randbytes(32).hex() - cln("holdinvoice", payment_hash, "100000") - - assert len(cln("cancelholdinvoice", payment_hash)) == 0 - assert len(cln("cancelholdinvoice", payment_hash)) == 0 - - def test_cancel_non_existent(self, cln: CliCaller) -> None: - payment_hash = random.randbytes(32).hex() - res = cln("cancelholdinvoice", payment_hash) - - assert res["code"] == 2102 - assert res["message"] == "hold invoice with that payment hash does not exist" - - def test_mpp_timeout(self, cln: CliCaller) -> None: - _, payment_hash, invoice = add_hold_invoice(cln) - dec = bolt11.decode(invoice) - dec.amount_msat = MilliSatoshi(dec.amount_msat - 1000) - - less_invoice = cln("signinvoice", bolt11.encode(dec))["bolt11"] - - pay = LndPay(LndNode.One, less_invoice, timeout=5) - pay.start() - - time.sleep(0.5) - assert ( - cln( - "listholdinvoices", - payment_hash, - )["holdinvoices"][0]["state"] - == "unpaid" - ) - - pay.join() - - assert pay.res["status"] == "FAILED" - assert pay.res["failure_reason"] == "FAILURE_REASON_TIMEOUT" - assert len(pay.res["htlcs"]) == 1 - - htlc = pay.res["htlcs"][0] - assert htlc["failure"]["code"] == "MPP_TIMEOUT" - - list_invoice = cln( - "listholdinvoices", - payment_hash, - )["holdinvoices"][0] - assert list_invoice["state"] == "unpaid" - assert len(list_invoice["htlcs"]) == 1 - assert list_invoice["htlcs"][0]["state"] == "cancelled" - - def test_htlc_too_little_cltv(self, cln: CliCaller) -> None: - _, payment_hash, invoice = add_hold_invoice(cln) - dec = lnd(LndNode.One, "decodepayreq", invoice) - block_height = lnd(LndNode.One, "getinfo")["block_height"] - - routes = lnd( - LndNode.One, - "queryroutes", - dec["destination"], - dec["num_satoshis"], - ) - - time_lock = int(block_height) + int(dec["cltv_expiry"]) - 1 - routes["routes"][0]["total_time_lock"] = time_lock - routes["routes"][0]["hops"][0]["expiry"] = time_lock - - res = lnd( - LndNode.One, - "sendtoroute", - "--payment_hash", - payment_hash, - format_json(routes), - ) - - assert res["status"] == "FAILED" - assert res["failure"]["code"] == "INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS" - - list_invoice = cln( - "listholdinvoices", - payment_hash, - )["holdinvoices"][0] - assert list_invoice["state"] == "unpaid" - assert len(list_invoice["htlcs"]) == 1 - assert list_invoice["htlcs"][0]["state"] == "cancelled" - - def test_htlc_payment_secret_wrong(self, cln: CliCaller) -> None: - payment_preimage, payment_hash, invoice = add_hold_invoice(cln) - cltv = cln_con("decode", invoice)["min_final_cltv_expiry"] - - cln_invoice = cln_con( - "invoice", - "-k", - "amount_msat=10000", - f"label={uuid.uuid4()!s}", - "description=copy", - f"preimage={payment_preimage}", - f"cltv={cltv}", - )["bolt11"] - - pay = LndPay(LndNode.One, cln_invoice) - pay.start() - pay.join() - - assert pay.res["status"] == "FAILED" - assert pay.res["failure_reason"] == "FAILURE_REASON_INCORRECT_PAYMENT_DETAILS" - - list_invoice = cln( - "listholdinvoices", - payment_hash, - )["holdinvoices"][0] - assert list_invoice["state"] == "unpaid" - assert len(list_invoice["htlcs"]) == 1 - assert list_invoice["htlcs"][0]["state"] == "cancelled" - - def test_htlc_payment_secret_missing(self, cln: CliCaller) -> None: - _, payment_hash, invoice = add_hold_invoice(cln) - dec = lnd(LndNode.One, "decodepayreq", invoice) - - routes = lnd( - LndNode.One, - "queryroutes", - dec["destination"], - dec["num_satoshis"], - ) - res = lnd( - LndNode.One, - "sendtoroute", - "--payment_hash", - payment_hash, - format_json(routes), - ) - - assert res["status"] == "FAILED" - assert res["failure"]["code"] == "INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS" - - list_invoice = cln( - "listholdinvoices", - payment_hash, - )["holdinvoices"][0] - assert list_invoice["state"] == "unpaid" - assert len(list_invoice["htlcs"]) == 1 - assert list_invoice["htlcs"][0]["state"] == "cancelled" - - def test_overpayment_protection(self, cln: CliCaller) -> None: - _, payment_hash, invoice = add_hold_invoice(cln) - dec = bolt11.decode(invoice) - dec.amount_msat = MilliSatoshi((dec.amount_msat * OVERPAYMENT_FACTOR) + 1) - - overpay_invoice = cln("signinvoice", bolt11.encode(dec))["bolt11"] - - pay = LndPay(LndNode.One, overpay_invoice, timeout=5) - pay.start() - - time.sleep(0.5) - assert ( - cln( - "listholdinvoices", - payment_hash, - )["holdinvoices"][0]["state"] - == "unpaid" - ) - - pay.join() - - assert pay.res["status"] == "FAILED" - assert pay.res["failure_reason"] == "FAILURE_REASON_INCORRECT_PAYMENT_DETAILS" - - htlc = pay.res["htlcs"][0] - assert htlc["failure"]["code"] == "INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS" - - list_invoice = cln( - "listholdinvoices", - payment_hash, - )["holdinvoices"][0] - assert list_invoice["state"] == "unpaid" - assert len(list_invoice["htlcs"]) == 1 - assert list_invoice["htlcs"][0]["state"] == "cancelled" - - def test_routinghints(self, cln: CliCaller) -> None: - lnd_pubkey = lnd(LndNode.One, "getinfo")["identity_pubkey"] - hints = cln("routinghints", lnd_pubkey)["hints"] - assert len(hints) == 1 - - routes = hints[0] - assert len(routes) == 1 - assert len(routes["routes"]) == 1 - - route = routes["routes"][0] - - channel_info = next( - chan - for chan in cln_con(f"listpeerchannels {lnd_pubkey}")["channels"] - if chan["short_channel_id"] == route["short_channel_id"] - ) - - updates = channel_info["updates"]["remote"] - - assert route["base_fee"] == updates["fee_base_msat"] - assert route["cltv_expiry_delta"] == updates["cltv_expiry_delta"] - assert route["ppm_fee"] == updates["fee_proportional_millionths"] - assert route["short_channel_id"] == channel_info["short_channel_id"] - - def test_routinghints_none_found(self, cln: CliCaller) -> None: - res = cln("routinghints", "none") - assert "hints" in res - assert len(res["hints"]) == 0 - - def test_wipe_single(self, cln: CliCaller) -> None: - _, payment_hash, _ = add_hold_invoice(cln) - res = cln("dev-wipeholdinvoices", payment_hash) - - assert res["deleted_count"] == 1 - assert len(cln("listholdinvoices", payment_hash)["holdinvoices"]) == 0 - - def test_wipe(self, cln: CliCaller) -> None: - for _ in range(11): - add_hold_invoice(cln) - - invoices = len(cln("listholdinvoices")["holdinvoices"]) - - assert cln("dev-wipeholdinvoices")["deleted_count"] == invoices - assert len(cln("listholdinvoices")["holdinvoices"]) == 0 - - def test_wipe_not_found(self, cln: CliCaller) -> None: - payment_hash = random.randbytes(32).hex() - res = cln("dev-wipeholdinvoices", payment_hash) - - assert res["code"] == 2102 - assert res["message"] == "hold invoice with that payment hash does not exist" - - def test_ignore_non_hold(self, cln: CliCaller) -> None: - invoice = cln("invoice", "1000", str(uuid.uuid4()), '""')["bolt11"] - - pay = LndPay(LndNode.One, invoice) - pay.start() - pay.join() - - assert pay.res["status"] == "SUCCEEDED" - - def test_ignore_forward(self, cln: CliCaller) -> None: - cln_id = cln("getinfo")["id"] - channels = lnd(LndNode.One, "listchannels")["channels"] - cln_channel = next(c for c in channels if c["remote_pubkey"] == cln_id)["chan_id"] - - invoice = lnd(LndNode.Two, "addinvoice", "10000")["payment_request"] - - pay = LndPay(LndNode.One, invoice, outgoing_chan_id=cln_channel) - pay.start() - pay.join() - - assert pay.res["status"] == "SUCCEEDED" - assert len(pay.res["htlcs"][0]["route"]["hops"]) == 2 - - def test_plugin_still_alive(self, cln: CliCaller) -> None: - plugins = cln("plugin", "list")["plugins"] - assert any(PLUGIN_PATH in plugin["name"] for plugin in plugins) diff --git a/tools/plugins/hold/tests/test_route_hints.py b/tools/plugins/hold/tests/test_route_hints.py deleted file mode 100644 index 828f36a5..00000000 --- a/tools/plugins/hold/tests/test_route_hints.py +++ /dev/null @@ -1,39 +0,0 @@ -from plugins.hold.route_hints import RouteHints -from plugins.hold.tests.utils import LndNode, RpcPlugin, cln_con, lnd - - -class TestRouteHints: - # noinspection PyTypeChecker - rh = RouteHints(RpcPlugin()) - - def test_get_private_channels(self) -> None: - other_pubkey = lnd(LndNode.One, "getinfo")["identity_pubkey"] - - hints = self.rh.get_private_channels(other_pubkey) - assert len(hints) == 1 - - hint = hints[0] - assert len(hint.routes) == 1 - - route = hint.routes[0] - assert route.public_key == other_pubkey - - channel_info = next( - chan - for chan in cln_con(f"listpeerchannels {other_pubkey}")["channels"] - if chan["private"] - ) - updates = channel_info["updates"]["remote"] - - assert route.base_fee == updates["fee_base_msat"] - assert route.cltv_expiry_delta == updates["cltv_expiry_delta"] - assert route.ppm_fee == updates["fee_proportional_millionths"] - assert route.short_channel_id == channel_info["short_channel_id"] - - def test_get_private_channels_none_found(self) -> None: - assert ( - self.rh.get_private_channels( - "0394c0450766d4029e980dd2934fbc4ca665222e3149c2a4a7b8a6251544a12033" - ) - == [] - ) diff --git a/tools/plugins/hold/tests/test_router.py b/tools/plugins/hold/tests/test_router.py deleted file mode 100644 index e205f8cd..00000000 --- a/tools/plugins/hold/tests/test_router.py +++ /dev/null @@ -1,63 +0,0 @@ -import pytest - -from plugins.hold.router import Hop, NoRouteError, Router -from plugins.hold.tests.utils import LndNode, RpcPlugin, lnd - - -class TestRouter: - # noinspection PyTypeChecker - r = Router(RpcPlugin()) - - def test_get_route(self) -> None: - other_pubkey = lnd(LndNode.One, "getinfo")["identity_pubkey"] - route = self.r.get_route(other_pubkey, 1000, 0, None, None, None) - assert len(route) == 1 - - def test_get_route_final_cltv(self) -> None: - other_pubkey = lnd(LndNode.One, "getinfo")["identity_pubkey"] - route = self.r.get_route(other_pubkey, 1000, 0, None, 90, None) - assert len(route) == 1 - assert route[0].delay == 90 - - def test_get_route_too_little_max_cltv(self) -> None: - other_pubkey = lnd(LndNode.One, "getinfo")["identity_pubkey"] - - with pytest.raises(NoRouteError): - self.r.get_route(other_pubkey, 1000, 0, 1, None, None) - - def test_get_route_no_channels(self) -> None: - with pytest.raises(NoRouteError): - self.r.get_route( - "03aaf57c1641e070b0b84d203d223083319eeeddbb43170adf8da0f010bcecff5b,", - 1000, - 0, - None, - None, - None, - ) - - @pytest.mark.parametrize( - ("delays", "result"), - [ - ([1], 0), - ([81, 1], 0), - ([101, 100], 0), - ([120, 81, 1], 1), - ([80, 60, 40, 20, 0], 3), - ([241, 209, 169, 129, 89, 9], 4), - ], - ) - def test_parse_time(self, delays: list[int], result: int) -> None: - hops = [ - Hop( - node_id=f"{delay}", - channel="", - direction=0, - amount_msat=0, - delay=delay, - style="", - ) - for delay in delays - ] - - assert Router._most_expensive_channel(hops) == hops[result] # noqa: SLF001 diff --git a/tools/plugins/hold/tests/test_server.py b/tools/plugins/hold/tests/test_server.py deleted file mode 100644 index 0ae6b5c0..00000000 --- a/tools/plugins/hold/tests/test_server.py +++ /dev/null @@ -1,88 +0,0 @@ -import socket -from contextlib import closing -from unittest.mock import MagicMock - -import grpc -import pytest - -# noinspection PyProtectedMember -from grpc._channel import _InactiveRpcError - -from plugins.hold.protos.hold_pb2 import InvoiceRequest -from plugins.hold.protos.hold_pb2_grpc import HoldStub -from plugins.hold.server import Server - - -def free_port() -> int: - with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s: - s.bind(("", 0)) - s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - return s.getsockname()[1] - - -class TestServer: - hold = MagicMock() - plugin = MagicMock() - - @pytest.fixture(scope="class", autouse=True) - def client(self) -> HoldStub: - host = "127.0.0.1" - port = free_port() - server = Server(self.plugin, self.hold) - server.start(host, port, None) - - channel = grpc.insecure_channel(f"{host}:{port}") - hold = HoldStub(channel) - - yield hold - - channel.close() - server.stop() - - def test_log_request(self, client: HoldStub) -> None: - expected = "invoice" - self.hold.invoice.return_value = expected - - assert client.Invoice(InvoiceRequest()).bolt11 == expected - - assert self.hold.invoice.call_count == 1 - assert self.plugin.log.call_count == 2 - assert self.plugin.log.call_args_list[1][0] == ("gRPC call /hold.Hold/Invoice",) - assert self.plugin.log.call_args_list[1][1] == {"level": "debug"} - - def test_log_error(self, client: HoldStub) -> None: - class TestError(Exception): - def __init__(self, message: str) -> None: - super().__init__(message) - - self.hold.invoice.side_effect = TestError("critical error") - - with pytest.raises(_InactiveRpcError): - client.Invoice(InvoiceRequest()) - - assert self.hold.invoice.call_count == 2 - assert self.plugin.log.call_count == 4 - assert self.plugin.log.call_args_list[2][0] == ("gRPC call /hold.Hold/Invoice",) - assert self.plugin.log.call_args_list[2][1] == {"level": "debug"} - assert self.plugin.log.call_args_list[3][0] == ( - "gRPC call /hold.Hold/Invoice failed: critical error", - ) - assert self.plugin.log.call_args_list[3][1] == {"level": "warn"} - - def test_log_error_repr(self, client: HoldStub) -> None: - class CustomNameError(Exception): - pass - - self.hold.invoice.side_effect = CustomNameError() - - with pytest.raises(_InactiveRpcError): - client.Invoice(InvoiceRequest()) - - assert self.hold.invoice.call_count == 3 - assert self.plugin.log.call_count == 6 - assert self.plugin.log.call_args_list[4][0] == ("gRPC call /hold.Hold/Invoice",) - assert self.plugin.log.call_args_list[4][1] == {"level": "debug"} - assert self.plugin.log.call_args_list[5][0] == ( - f"gRPC call /hold.Hold/Invoice failed: {CustomNameError()!r}", - ) - assert self.plugin.log.call_args_list[5][1] == {"level": "warn"} diff --git a/tools/plugins/hold/tests/test_tracker.py b/tools/plugins/hold/tests/test_tracker.py deleted file mode 100644 index dbdca021..00000000 --- a/tools/plugins/hold/tests/test_tracker.py +++ /dev/null @@ -1,116 +0,0 @@ -import random - -from plugins.hold.enums import InvoiceState -from plugins.hold.tracker import InvoiceUpdate, Tracker - - -class TestTracker: - def test_track_new_payment_hash(self) -> None: - payment_hash = random.randbytes(32).hex() - - track = Tracker() - q = track.track(payment_hash) - - assert track._fwds[payment_hash].size() == 1 # noqa: SLF001 - assert track._fwds[payment_hash]._qs[0] == q # noqa: SLF001 - - def test_track_existing_payment_hash(self) -> None: - payment_hash = random.randbytes(32).hex() - track = Tracker() - - q1 = track.track(payment_hash) - q2 = track.track(payment_hash) - - assert track._fwds[payment_hash].size() == 2 # noqa: SLF001 - assert track._fwds[payment_hash]._qs[0] == q1 # noqa: SLF001 - assert track._fwds[payment_hash]._qs[1] == q2 # noqa: SLF001 - - def test_stop_tracking_empty_afterwards(self) -> None: - payment_hash = random.randbytes(32).hex() - track = Tracker() - q = track.track(payment_hash) - - track.stop_tracking(payment_hash, q) - - assert len(track._fwds) == 0 # noqa: SLF001 - - def test_stop_tracking(self) -> None: - payment_hash = random.randbytes(32).hex() - track = Tracker() - q1 = track.track(payment_hash) - q2 = track.track(payment_hash) - - track.stop_tracking(payment_hash, q1) - - assert track._fwds[payment_hash].size() == 1 # noqa: SLF001 - assert track._fwds[payment_hash]._qs[0] == q2 # noqa: SLF001 - - def test_send_update_no_queues(self) -> None: - payment_hash = random.randbytes(32).hex() - track = Tracker() - track.send_update(payment_hash, "invoice", InvoiceState.Paid) - - def test_send_update_queue(self) -> None: - payment_hash = random.randbytes(32).hex() - track = Tracker() - q = track.track(payment_hash) - - update = InvoiceState.Accepted - track.send_update(payment_hash, "invoice", update) - - assert q.get() == update - - def test_send_update_queues(self) -> None: - payment_hash = random.randbytes(32).hex() - track = Tracker() - q1 = track.track(payment_hash) - q2 = track.track(payment_hash) - - update = InvoiceState.Accepted - track.send_update(payment_hash, "invoice", update) - - assert q1.get() == update - assert q2.get() == update - - def test_track_all(self) -> None: - track = Tracker() - q = track.track_all() - - assert track._all_fwds is not None # noqa: SLF001 - assert track._all_fwds.size() == 1 # noqa: SLF001 - assert track._all_fwds._qs[0] == q # noqa: SLF001 - - def test_stop_tracking_all(self) -> None: - track = Tracker() - q1 = track.track_all() - q2 = track.track_all() - - track.stop_tracking_all(q1) - - assert track._all_fwds.size() == 1 # noqa: SLF001 - assert track._all_fwds._qs[0] == q2 # noqa: SLF001 - - def test_send_update_all(self) -> None: - payment_hash = random.randbytes(32).hex() - track = Tracker() - q = track.track_all() - - invoice = "lnbc" - update = InvoiceState.Accepted - track.send_update(payment_hash, invoice, update) - - assert q.get() == InvoiceUpdate(payment_hash, invoice, update) - - def test_send_update_single_all(self) -> None: - invoice = "lnbcrt" - payment_hash = random.randbytes(32).hex() - track = Tracker() - - q = track.track(payment_hash) - q_all = track.track_all() - - update = InvoiceState.Accepted - track.send_update(payment_hash, invoice, update) - - assert q.get() == update - assert q_all.get() == InvoiceUpdate(payment_hash, invoice, update) diff --git a/tools/plugins/hold/tests/utils.py b/tools/plugins/hold/tests/utils.py deleted file mode 100644 index 8fb4c6d9..00000000 --- a/tools/plugins/hold/tests/utils.py +++ /dev/null @@ -1,163 +0,0 @@ -import json -import os -from collections.abc import Callable -from enum import Enum -from threading import Thread -from typing import Any - -import pytest - -from plugins.hold.utils import parse_time - -PLUGIN_PATH = "/root/hold.sh" -PLUGIN_PATH_MPAY = "/root/mpay.sh" - -CliCaller = Callable[..., dict[str, Any]] - - -class RpcCaller: - @staticmethod - def getinfo() -> dict: - return cln_con("getinfo") - - @staticmethod - def listpeerchannels(peer_id: str | None = None) -> dict: - return cln_con(f"listpeerchannels {peer_id if peer_id is not None else ''}") - - @staticmethod - def listchannels(**kwargs: dict[str, str]) -> dict: - args = "listchannels -k" - for key, val in kwargs.items(): - args += f" {key}={val}" - - return cln_con(args) - - @staticmethod - def listnodes(pubkey: str | None = None) -> dict: - args = "listnodes" - - if pubkey is not None: - args += f" {pubkey}" - - return cln_con(args) - - @staticmethod - def getroute(**kwargs: dict[str, Any]) -> dict: - args = "getroute -k" - for key, val in kwargs.items(): - if key == "exclude": - args += f" {key}={str(val).replace(' ', '')}" - else: - args += f" {key if key != 'node_id' else 'id'}={val}" - - return cln_con(args) - - -class RpcPlugin: - rpc = RpcCaller() - - -class LndNode(Enum): - One = 1 - Two = 2 - - -def lnd_raw(node: LndNode, *args: str) -> str: - node_cmd = "docker exec regtest lncli --network regtest --lnddir /root/.lnd-btc" - - if node == LndNode.Two: - node_cmd += " --rpcserver localhost:10011" - - return os.popen( - f"{node_cmd} {' '.join(args)}", - ).read() - - -def lnd(node: LndNode, *args: str) -> dict[str, Any]: - return json.loads(lnd_raw(node, *args)) - - -def format_json(args: dict[str, Any] | list[Any]) -> str: - return json.dumps(args).replace('"', '\\"').replace(" ", "") - - -def connect_peers(cln: CliCaller) -> None: - cln_id = cln("getinfo")["id"] - - def lnd_connect(node: LndNode) -> None: - if len(lnd(node, "listpeers")["peers"]) == 2: - return - - lnd(node, "connect", f"{cln_id}@127.0.0.1:9737") - - for i in LndNode: - lnd_connect(i) - - -def start_plugin(cln: CliCaller, path: str = PLUGIN_PATH) -> None: - cln("plugin", "start", path) - - -def stop_plugin(cln: CliCaller, path: str = PLUGIN_PATH) -> None: - plugins = cln("plugin", "list")["plugins"] - if not any(path in plugin["name"] for plugin in plugins): - return - - cln("plugin", "stop", path) - - -class LndPay(Thread): - res: dict[str, Any] = None - - def __init__( - self, - node: LndNode, - invoice: str, - max_shard_size: int | None = None, - outgoing_chan_id: str | None = None, - timeout: int | None = None, - ) -> None: - Thread.__init__(self) - - self.node = node - self.timeout = timeout - self.invoice = invoice - self.max_shard_size = max_shard_size - self.outgoing_chan_id = outgoing_chan_id - - def run(self) -> None: - cmd = "payinvoice --force --json" - - if self.outgoing_chan_id is not None: - cmd += f" --outgoing_chan_id {self.outgoing_chan_id}" - - if self.max_shard_size is not None: - cmd += f" --max_shard_size_sat {self.max_shard_size}" - - if self.timeout is not None: - cmd += f" --timeout {self.timeout}s" - - res = lnd_raw(self.node, f"{cmd} {self.invoice} 2> /dev/null") - res = res[res.find("{") :] - self.res = json.loads(res) - - -def cln_con(*args: str) -> dict[str, Any]: - return json.load( - os.popen( - f"docker exec regtest lightning-cli {' '.join(args)}", - ) - ) - - -class TestUtils: - @pytest.mark.parametrize( - ("data", "result"), - [ - ("1970-01-01T00:00:48.1904", 0), - ("2023-09-04T00:37:36.349Z", 1693787856), - ("2023-09-05T10:56:22.874Z", 1693911382), - ], - ) - def test_parse_time(self, data: str, result: int) -> None: - assert parse_time(data) == result diff --git a/tools/plugins/hold/tracker.py b/tools/plugins/hold/tracker.py deleted file mode 100644 index 3cc12065..00000000 --- a/tools/plugins/hold/tracker.py +++ /dev/null @@ -1,88 +0,0 @@ -import threading -from dataclasses import dataclass -from queue import SimpleQueue -from typing import Generic, TypeVar - -from plugins.hold.enums import InvoiceState - - -@dataclass(frozen=True) -class InvoiceUpdate: - payment_hash: str - bolt11: str - update: InvoiceState - - -T = TypeVar("T") - - -class MultiForward(Generic[T]): - _qs: list[SimpleQueue[T]] - - def __init__(self) -> None: - self._qs = [] - - def size(self) -> int: - return len(self._qs) - - def send_update(self, update: T) -> None: - for q in self._qs: - q.put(update) - - def track(self) -> SimpleQueue[T]: - q = SimpleQueue() - self._qs.append(q) - return q - - def stop_tracking(self, q: SimpleQueue[T]) -> None: - self._qs.remove(q) - - -class Tracker: - _lock: threading.Lock - - _fwds: dict[str, MultiForward[InvoiceState]] - _all_fwds: MultiForward[InvoiceUpdate] - - def __init__(self) -> None: - self._fwds = {} - self._all_fwds = MultiForward() - self._lock = threading.Lock() - - def send_update(self, payment_hash: str, bolt11: str, update: InvoiceState) -> None: - with self._lock: - fwd = self._fwds.get(payment_hash) - if fwd is not None: - fwd.send_update(update) - - self._all_fwds.send_update( - InvoiceUpdate(payment_hash=payment_hash, bolt11=bolt11, update=update) - ) - - def track(self, payment_hash: str) -> SimpleQueue[InvoiceState]: - with self._lock: - fwd = self._fwds.get(payment_hash) - - if fwd is None: - fwd = MultiForward() - self._fwds[payment_hash] = fwd - - return fwd.track() - - def track_all(self) -> SimpleQueue[InvoiceUpdate]: - with self._lock: - return self._all_fwds.track() - - def stop_tracking(self, payment_hash: str, q: SimpleQueue[InvoiceState]) -> None: - with self._lock: - fwd = self._fwds.get(payment_hash) - if fwd is None: - return - - fwd.stop_tracking(q) - if fwd.size() == 0: - del self._fwds[payment_hash] - - def stop_tracking_all(self, q: SimpleQueue[InvoiceUpdate]) -> None: - with self._lock: - self._all_fwds.stop_tracking(q) diff --git a/tools/plugins/hold/transformers.py b/tools/plugins/hold/transformers.py deleted file mode 100644 index 3924eeb5..00000000 --- a/tools/plugins/hold/transformers.py +++ /dev/null @@ -1,213 +0,0 @@ -from typing import Any - -from bolt11.models.routehint import Route, RouteHint - -from plugins.hold import router -from plugins.hold.enums import HtlcState, InvoiceState -from plugins.hold.invoice import HoldInvoice, Htlc -from plugins.hold.protos.hold_pb2 import ( - HTLC_ACCEPTED, - HTLC_CANCELLED, - HTLC_SETTLED, - INVOICE_ACCEPTED, - INVOICE_CANCELLED, - INVOICE_PAID, - INVOICE_UNPAID, - GetRouteResponse, - Hop, - Invoice, - PayStatusResponse, - RoutingHint, - RoutingHintsResponse, -) -from plugins.hold.protos.hold_pb2 import ( - Htlc as HtlcGrpc, -) -from plugins.hold.utils import parse_time - -INVOICE_STATE_TO_GRPC = { - InvoiceState.Paid: INVOICE_PAID, - InvoiceState.Unpaid: INVOICE_UNPAID, - InvoiceState.Accepted: INVOICE_ACCEPTED, - InvoiceState.Cancelled: INVOICE_CANCELLED, -} - -HTLC_STATE_TO_GRPC = { - HtlcState.Paid: HTLC_SETTLED, - HtlcState.Accepted: HTLC_ACCEPTED, - HtlcState.Cancelled: HTLC_CANCELLED, -} - -PAY_STATUS_STATE_TO_GRPC = { - "pending": PayStatusResponse.PayStatus.Attempt.AttemptState.ATTEMPT_PENDING, - "completed": PayStatusResponse.PayStatus.Attempt.AttemptState.ATTEMPT_COMPLETED, -} - - -class Transformers: - @staticmethod - def invoice_to_grpc(invoice: HoldInvoice) -> Invoice: - return Invoice( - payment_hash=invoice.payment_hash, - payment_preimage=invoice.payment_preimage, - state=INVOICE_STATE_TO_GRPC[invoice.state], - bolt11=invoice.bolt11, - amount_msat=invoice.amount_msat, - created_at=int(invoice.created_at.timestamp()), - htlcs=[Transformers.htlc_to_grpc(htlc) for htlc in invoice.htlcs.htlcs], - ) - - @staticmethod - def htlc_to_grpc(htlc: Htlc) -> HtlcGrpc: - return HtlcGrpc( - state=HTLC_STATE_TO_GRPC[htlc.state], - msat=htlc.msat, - created_at=int(htlc.created_at.timestamp()), - short_channel_id=htlc.short_channel_id, - id=htlc.channel_id, - ) - - @staticmethod - def routing_hints_to_grpc(hints: list[RouteHint]) -> RoutingHintsResponse: - return RoutingHintsResponse( - hints=[Transformers.routing_hint_to_grpc(hint) for hint in hints] - ) - - @staticmethod - def routing_hint_to_grpc(hint: RouteHint) -> RoutingHint: - return RoutingHint(hops=[Transformers.hop_to_grpc(hop) for hop in hint.routes]) - - @staticmethod - def hop_to_grpc(hop: Route) -> Hop: - return Hop( - public_key=hop.public_key, - short_channel_id=hop.short_channel_id, - base_fee=hop.base_fee, - ppm_fee=hop.ppm_fee, - cltv_expiry_delta=hop.cltv_expiry_delta, - ) - - @staticmethod - def routing_hints_from_grpc(hints: list[RoutingHint]) -> list[RouteHint]: - return [Transformers.routing_hint_from_grpc(hint) for hint in hints] - - @staticmethod - def routing_hint_from_grpc(hint: RoutingHint) -> RouteHint: - return RouteHint(routes=[Transformers.hop_from_grpc(hop) for hop in hint.hops]) - - @staticmethod - def hop_from_grpc(hop: Hop) -> Route: - return Route( - public_key=hop.public_key, - short_channel_id=hop.short_channel_id, - base_fee=hop.base_fee, - ppm_fee=hop.ppm_fee, - cltv_expiry_delta=hop.cltv_expiry_delta, - ) - - @staticmethod - def routing_hints_from_json(hints: list[Any]) -> list[RouteHint]: - return [Transformers.routing_hint_from_json(hint) for hint in hints] - - @staticmethod - def routing_hint_from_json(hint: dict[str, Any]) -> RouteHint: - return RouteHint(routes=[Transformers.hop_from_json(hop) for hop in hint["routes"]]) - - @staticmethod - def hop_from_json(hop: dict[str, str | int]) -> Route: - return Route( - public_key=hop["public_key"], - short_channel_id=hop["short_channel_id"], - base_fee=hop["base_fee"], - ppm_fee=hop["ppm_fee"], - cltv_expiry_delta=hop["cltv_expiry_delta"], - ) - - @staticmethod - def pay_status_response_to_grpc(res: dict[str, Any]) -> PayStatusResponse: - return PayStatusResponse( - status=[ - PayStatusResponse.PayStatus( - bolt11=status["bolt11"], - amount_msat=int(status["amount_msat"]), - destination=status["destination"], - attempts=[ - Transformers.pay_status_attempt_to_grpc(attempt) - for attempt in status["attempts"] - ], - ) - for status in res["pay"] - ] - ) - - @staticmethod - def pay_status_attempt_to_grpc( - res: dict[str, Any], - ) -> PayStatusResponse.PayStatus.Attempt: - def transform_failure_data( - failure_data: dict[str, Any], - ) -> PayStatusResponse.PayStatus.Attempt.Failure.Data: - return PayStatusResponse.PayStatus.Attempt.Failure.Data( - id=failure_data["id"], - raw_message=failure_data["raw_message"], - fail_code=failure_data["failcode"], - fail_codename=failure_data["failcodename"], - erring_index=failure_data["erring_index"], - erring_node=failure_data["erring_node"], - ) - - def transform_failure( - failure: dict[str, Any], - ) -> PayStatusResponse.PayStatus.Attempt.Failure: - return PayStatusResponse.PayStatus.Attempt.Failure( - message=failure["message"], - code=failure["code"], - data=transform_failure_data(failure["data"]) if "data" in failure else None, - ) - - attempt = PayStatusResponse.PayStatus.Attempt( - strategy=res.get("strategy", ""), - start_time=parse_time(res["start_time"]), - age_in_seconds=res["age_in_seconds"], - state=PAY_STATUS_STATE_TO_GRPC[res["state"]], - success=PayStatusResponse.PayStatus.Attempt.Success( - id=res["success"]["id"], - payment_preimage=res["success"]["payment_preimage"], - ) - if "success" in res - else None, - failure=transform_failure(res["failure"]) if "failure" in res else None, - ) - - if "end_time" in res: - attempt.end_time = parse_time(res["end_time"]) - - return attempt - - @staticmethod - def route_to_grpc(route: list[router.Hop]) -> list[GetRouteResponse.Hop]: - return [ - GetRouteResponse.Hop( - id=hop.node_id, - channel=hop.channel, - direction=hop.direction, - amount_msat=hop.amount_msat, - delay=hop.delay, - style=hop.style, - ) - for hop in route - ] - - @staticmethod - def named_tuples_to_dict(val: object) -> object: - if isinstance(val, list): - return [Transformers.named_tuples_to_dict(entry) for entry in val] - - if isinstance(val, tuple) and hasattr(val, "_asdict"): - # noinspection PyProtectedMember - return Transformers.named_tuples_to_dict(val._asdict()) - - if isinstance(val, dict): - return {key: Transformers.named_tuples_to_dict(value) for key, value in val.items()} - - return val diff --git a/tools/plugins/hold/utils.py b/tools/plugins/hold/utils.py deleted file mode 100644 index 72c39925..00000000 --- a/tools/plugins/hold/utils.py +++ /dev/null @@ -1,30 +0,0 @@ -from collections.abc import Callable -from datetime import datetime, timezone -from typing import TypeVar - - -def time_now() -> datetime: - return datetime.now(tz=timezone.utc) - - -def parse_time(time: str) -> int: - try: - return int(datetime.strptime(time, "%Y-%m-%dT%H:%M:%S.%f%z").timestamp()) - except ValueError: - return 0 - - -T = TypeVar("T") - - -def partition(iterable: list[T], pred: Callable[[T], bool]) -> tuple[list[T], list[T]]: - trues = [] - falses = [] - - for item in iterable: - if pred(item): - trues.append(item) - else: - falses.append(item) - - return trues, falses