From db60278f16894fc74b9316b099a9d3958b736971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Tigerstr=C3=B6m?= Date: Wed, 5 Feb 2025 17:37:20 +0100 Subject: [PATCH 1/6] litrpc: run `go mod tidy` The current go.sum file was out of sync with the go.mod file. This commit updates the go.sum file by running `go mod tidy` to match the go.mod file. --- litrpc/go.sum | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/litrpc/go.sum b/litrpc/go.sum index 8a51a441b..3d4d4561e 100644 --- a/litrpc/go.sum +++ b/litrpc/go.sum @@ -1510,8 +1510,7 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= From 3e8c6d728d9a884f2a7a45a5442991de95accd54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Tigerstr=C3=B6m?= Date: Wed, 5 Feb 2025 17:46:27 +0100 Subject: [PATCH 2/6] multi: add CreditAccount & DebitAccount endpoints This commit introduces the structure for new endpoints in the accounts subsystem, enabling balance adjustments by crediting or debiting a specified amount. This contrasts with the existing `UpdateAccount` implementation, which directly sets the balance to a fixed value. For more details on the drawbacks of the current implementation, see [issue #648](https://github.com/lightninglabs/lightning-terminal/issues/648). The actual implementation of the endpoints will be introduced in subsequent commits. --- app/src/types/generated/lit-accounts_pb.d.ts | 131 ++ app/src/types/generated/lit-accounts_pb.js | 1165 +++++++++++++++-- .../generated/lit-accounts_pb_service.d.ts | 38 + .../generated/lit-accounts_pb_service.js | 80 ++ litrpc/accounts.pb.json.go | 50 + litrpc/lit-accounts.pb.go | 547 +++++++- litrpc/lit-accounts.pb.gw.go | 222 ++++ litrpc/lit-accounts.proto | 52 + litrpc/lit-accounts.swagger.json | 153 +++ litrpc/lit-accounts.yaml | 6 + litrpc/lit-accounts_grpc.pb.go | 84 ++ perms/permissions.go | 8 + proto/lit-accounts.proto | 52 + 13 files changed, 2433 insertions(+), 155 deletions(-) diff --git a/app/src/types/generated/lit-accounts_pb.d.ts b/app/src/types/generated/lit-accounts_pb.d.ts index d461827ce..9be91c4a2 100644 --- a/app/src/types/generated/lit-accounts_pb.d.ts +++ b/app/src/types/generated/lit-accounts_pb.d.ts @@ -195,6 +195,102 @@ export namespace UpdateAccountRequest { } } +export class CreditAccountRequest extends jspb.Message { + hasAccount(): boolean; + clearAccount(): void; + getAccount(): AccountIdentifier | undefined; + setAccount(value?: AccountIdentifier): void; + + getAmount(): string; + setAmount(value: string): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): CreditAccountRequest.AsObject; + static toObject(includeInstance: boolean, msg: CreditAccountRequest): CreditAccountRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: CreditAccountRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): CreditAccountRequest; + static deserializeBinaryFromReader(message: CreditAccountRequest, reader: jspb.BinaryReader): CreditAccountRequest; +} + +export namespace CreditAccountRequest { + export type AsObject = { + account?: AccountIdentifier.AsObject, + amount: string, + } +} + +export class CreditAccountResponse extends jspb.Message { + hasAccount(): boolean; + clearAccount(): void; + getAccount(): Account | undefined; + setAccount(value?: Account): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): CreditAccountResponse.AsObject; + static toObject(includeInstance: boolean, msg: CreditAccountResponse): CreditAccountResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: CreditAccountResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): CreditAccountResponse; + static deserializeBinaryFromReader(message: CreditAccountResponse, reader: jspb.BinaryReader): CreditAccountResponse; +} + +export namespace CreditAccountResponse { + export type AsObject = { + account?: Account.AsObject, + } +} + +export class DebitAccountRequest extends jspb.Message { + hasAccount(): boolean; + clearAccount(): void; + getAccount(): AccountIdentifier | undefined; + setAccount(value?: AccountIdentifier): void; + + getAmount(): string; + setAmount(value: string): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): DebitAccountRequest.AsObject; + static toObject(includeInstance: boolean, msg: DebitAccountRequest): DebitAccountRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: DebitAccountRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): DebitAccountRequest; + static deserializeBinaryFromReader(message: DebitAccountRequest, reader: jspb.BinaryReader): DebitAccountRequest; +} + +export namespace DebitAccountRequest { + export type AsObject = { + account?: AccountIdentifier.AsObject, + amount: string, + } +} + +export class DebitAccountResponse extends jspb.Message { + hasAccount(): boolean; + clearAccount(): void; + getAccount(): Account | undefined; + setAccount(value?: Account): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): DebitAccountResponse.AsObject; + static toObject(includeInstance: boolean, msg: DebitAccountResponse): DebitAccountResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: DebitAccountResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): DebitAccountResponse; + static deserializeBinaryFromReader(message: DebitAccountResponse, reader: jspb.BinaryReader): DebitAccountResponse; +} + +export namespace DebitAccountResponse { + export type AsObject = { + account?: Account.AsObject, + } +} + export class ListAccountsRequest extends jspb.Message { serializeBinary(): Uint8Array; toObject(includeInstance?: boolean): ListAccountsRequest.AsObject; @@ -297,3 +393,38 @@ export namespace RemoveAccountResponse { } } +export class AccountIdentifier extends jspb.Message { + hasId(): boolean; + clearId(): void; + getId(): string; + setId(value: string): void; + + hasLabel(): boolean; + clearLabel(): void; + getLabel(): string; + setLabel(value: string): void; + + getIdentifierCase(): AccountIdentifier.IdentifierCase; + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): AccountIdentifier.AsObject; + static toObject(includeInstance: boolean, msg: AccountIdentifier): AccountIdentifier.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: AccountIdentifier, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): AccountIdentifier; + static deserializeBinaryFromReader(message: AccountIdentifier, reader: jspb.BinaryReader): AccountIdentifier; +} + +export namespace AccountIdentifier { + export type AsObject = { + id: string, + label: string, + } + + export enum IdentifierCase { + IDENTIFIER_NOT_SET = 0, + ID = 1, + LABEL = 2, + } +} + diff --git a/app/src/types/generated/lit-accounts_pb.js b/app/src/types/generated/lit-accounts_pb.js index 3d118ebbd..8baadb613 100644 --- a/app/src/types/generated/lit-accounts_pb.js +++ b/app/src/types/generated/lit-accounts_pb.js @@ -25,11 +25,17 @@ var global = Function('return this')(); goog.exportSymbol('proto.litrpc.Account', null, global); +goog.exportSymbol('proto.litrpc.AccountIdentifier', null, global); +goog.exportSymbol('proto.litrpc.AccountIdentifier.IdentifierCase', null, global); goog.exportSymbol('proto.litrpc.AccountInfoRequest', null, global); goog.exportSymbol('proto.litrpc.AccountInvoice', null, global); goog.exportSymbol('proto.litrpc.AccountPayment', null, global); goog.exportSymbol('proto.litrpc.CreateAccountRequest', null, global); goog.exportSymbol('proto.litrpc.CreateAccountResponse', null, global); +goog.exportSymbol('proto.litrpc.CreditAccountRequest', null, global); +goog.exportSymbol('proto.litrpc.CreditAccountResponse', null, global); +goog.exportSymbol('proto.litrpc.DebitAccountRequest', null, global); +goog.exportSymbol('proto.litrpc.DebitAccountResponse', null, global); goog.exportSymbol('proto.litrpc.ListAccountsRequest', null, global); goog.exportSymbol('proto.litrpc.ListAccountsResponse', null, global); goog.exportSymbol('proto.litrpc.RemoveAccountRequest', null, global); @@ -161,6 +167,90 @@ if (goog.DEBUG && !COMPILED) { */ proto.litrpc.UpdateAccountRequest.displayName = 'proto.litrpc.UpdateAccountRequest'; } +/** + * 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.litrpc.CreditAccountRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.litrpc.CreditAccountRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.litrpc.CreditAccountRequest.displayName = 'proto.litrpc.CreditAccountRequest'; +} +/** + * 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.litrpc.CreditAccountResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.litrpc.CreditAccountResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.litrpc.CreditAccountResponse.displayName = 'proto.litrpc.CreditAccountResponse'; +} +/** + * 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.litrpc.DebitAccountRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.litrpc.DebitAccountRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.litrpc.DebitAccountRequest.displayName = 'proto.litrpc.DebitAccountRequest'; +} +/** + * 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.litrpc.DebitAccountResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.litrpc.DebitAccountResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.litrpc.DebitAccountResponse.displayName = 'proto.litrpc.DebitAccountResponse'; +} /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -266,6 +356,27 @@ if (goog.DEBUG && !COMPILED) { */ proto.litrpc.RemoveAccountResponse.displayName = 'proto.litrpc.RemoveAccountResponse'; } +/** + * 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.litrpc.AccountIdentifier = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, proto.litrpc.AccountIdentifier.oneofGroups_); +}; +goog.inherits(proto.litrpc.AccountIdentifier, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.litrpc.AccountIdentifier.displayName = 'proto.litrpc.AccountIdentifier'; +} @@ -1658,8 +1769,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.litrpc.ListAccountsRequest.prototype.toObject = function(opt_includeInstance) { - return proto.litrpc.ListAccountsRequest.toObject(opt_includeInstance, this); +proto.litrpc.CreditAccountRequest.prototype.toObject = function(opt_includeInstance) { + return proto.litrpc.CreditAccountRequest.toObject(opt_includeInstance, this); }; @@ -1668,13 +1779,14 @@ proto.litrpc.ListAccountsRequest.prototype.toObject = function(opt_includeInstan * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.litrpc.ListAccountsRequest} msg The msg instance to transform. + * @param {!proto.litrpc.CreditAccountRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.litrpc.ListAccountsRequest.toObject = function(includeInstance, msg) { +proto.litrpc.CreditAccountRequest.toObject = function(includeInstance, msg) { var f, obj = { - + account: (f = msg.getAccount()) && proto.litrpc.AccountIdentifier.toObject(includeInstance, f), + amount: jspb.Message.getFieldWithDefault(msg, 2, "0") }; if (includeInstance) { @@ -1688,29 +1800,38 @@ proto.litrpc.ListAccountsRequest.toObject = function(includeInstance, msg) { /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.litrpc.ListAccountsRequest} + * @return {!proto.litrpc.CreditAccountRequest} */ -proto.litrpc.ListAccountsRequest.deserializeBinary = function(bytes) { +proto.litrpc.CreditAccountRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.litrpc.ListAccountsRequest; - return proto.litrpc.ListAccountsRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.litrpc.CreditAccountRequest; + return proto.litrpc.CreditAccountRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.litrpc.ListAccountsRequest} msg The message object to deserialize into. + * @param {!proto.litrpc.CreditAccountRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.litrpc.ListAccountsRequest} + * @return {!proto.litrpc.CreditAccountRequest} */ -proto.litrpc.ListAccountsRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.litrpc.CreditAccountRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; } var field = reader.getFieldNumber(); switch (field) { + case 1: + var value = new proto.litrpc.AccountIdentifier; + reader.readMessage(value,proto.litrpc.AccountIdentifier.deserializeBinaryFromReader); + msg.setAccount(value); + break; + case 2: + var value = /** @type {string} */ (reader.readUint64String()); + msg.setAmount(value); + break; default: reader.skipField(); break; @@ -1724,9 +1845,9 @@ proto.litrpc.ListAccountsRequest.deserializeBinaryFromReader = function(msg, rea * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.litrpc.ListAccountsRequest.prototype.serializeBinary = function() { +proto.litrpc.CreditAccountRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.litrpc.ListAccountsRequest.serializeBinaryToWriter(this, writer); + proto.litrpc.CreditAccountRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -1734,22 +1855,85 @@ proto.litrpc.ListAccountsRequest.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.litrpc.ListAccountsRequest} message + * @param {!proto.litrpc.CreditAccountRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.litrpc.ListAccountsRequest.serializeBinaryToWriter = function(message, writer) { +proto.litrpc.CreditAccountRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; + f = message.getAccount(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.litrpc.AccountIdentifier.serializeBinaryToWriter + ); + } + f = message.getAmount(); + if (parseInt(f, 10) !== 0) { + writer.writeUint64String( + 2, + f + ); + } +}; + + +/** + * optional AccountIdentifier account = 1; + * @return {?proto.litrpc.AccountIdentifier} + */ +proto.litrpc.CreditAccountRequest.prototype.getAccount = function() { + return /** @type{?proto.litrpc.AccountIdentifier} */ ( + jspb.Message.getWrapperField(this, proto.litrpc.AccountIdentifier, 1)); }; +/** + * @param {?proto.litrpc.AccountIdentifier|undefined} value + * @return {!proto.litrpc.CreditAccountRequest} returns this +*/ +proto.litrpc.CreditAccountRequest.prototype.setAccount = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + /** - * List of repeated fields within this message type. - * @private {!Array} - * @const + * Clears the message field making it undefined. + * @return {!proto.litrpc.CreditAccountRequest} returns this */ -proto.litrpc.ListAccountsResponse.repeatedFields_ = [1]; +proto.litrpc.CreditAccountRequest.prototype.clearAccount = function() { + return this.setAccount(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.litrpc.CreditAccountRequest.prototype.hasAccount = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional uint64 amount = 2; + * @return {string} + */ +proto.litrpc.CreditAccountRequest.prototype.getAmount = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.litrpc.CreditAccountRequest} returns this + */ +proto.litrpc.CreditAccountRequest.prototype.setAmount = function(value) { + return jspb.Message.setProto3StringIntField(this, 2, value); +}; + + @@ -1766,8 +1950,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.litrpc.ListAccountsResponse.prototype.toObject = function(opt_includeInstance) { - return proto.litrpc.ListAccountsResponse.toObject(opt_includeInstance, this); +proto.litrpc.CreditAccountResponse.prototype.toObject = function(opt_includeInstance) { + return proto.litrpc.CreditAccountResponse.toObject(opt_includeInstance, this); }; @@ -1776,14 +1960,13 @@ proto.litrpc.ListAccountsResponse.prototype.toObject = function(opt_includeInsta * @param {boolean|undefined} includeInstance Deprecated. Whether to include * the JSPB instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.litrpc.ListAccountsResponse} msg The msg instance to transform. + * @param {!proto.litrpc.CreditAccountResponse} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.litrpc.ListAccountsResponse.toObject = function(includeInstance, msg) { +proto.litrpc.CreditAccountResponse.toObject = function(includeInstance, msg) { var f, obj = { - accountsList: jspb.Message.toObjectList(msg.getAccountsList(), - proto.litrpc.Account.toObject, includeInstance) + account: (f = msg.getAccount()) && proto.litrpc.Account.toObject(includeInstance, f) }; if (includeInstance) { @@ -1797,23 +1980,23 @@ proto.litrpc.ListAccountsResponse.toObject = function(includeInstance, msg) { /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.litrpc.ListAccountsResponse} + * @return {!proto.litrpc.CreditAccountResponse} */ -proto.litrpc.ListAccountsResponse.deserializeBinary = function(bytes) { +proto.litrpc.CreditAccountResponse.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.litrpc.ListAccountsResponse; - return proto.litrpc.ListAccountsResponse.deserializeBinaryFromReader(msg, reader); + var msg = new proto.litrpc.CreditAccountResponse; + return proto.litrpc.CreditAccountResponse.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.litrpc.ListAccountsResponse} msg The message object to deserialize into. + * @param {!proto.litrpc.CreditAccountResponse} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.litrpc.ListAccountsResponse} + * @return {!proto.litrpc.CreditAccountResponse} */ -proto.litrpc.ListAccountsResponse.deserializeBinaryFromReader = function(msg, reader) { +proto.litrpc.CreditAccountResponse.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -1823,7 +2006,7 @@ proto.litrpc.ListAccountsResponse.deserializeBinaryFromReader = function(msg, re case 1: var value = new proto.litrpc.Account; reader.readMessage(value,proto.litrpc.Account.deserializeBinaryFromReader); - msg.addAccounts(value); + msg.setAccount(value); break; default: reader.skipField(); @@ -1838,9 +2021,9 @@ proto.litrpc.ListAccountsResponse.deserializeBinaryFromReader = function(msg, re * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.litrpc.ListAccountsResponse.prototype.serializeBinary = function() { +proto.litrpc.CreditAccountResponse.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.litrpc.ListAccountsResponse.serializeBinaryToWriter(this, writer); + proto.litrpc.CreditAccountResponse.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -1848,15 +2031,15 @@ proto.litrpc.ListAccountsResponse.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.litrpc.ListAccountsResponse} message + * @param {!proto.litrpc.CreditAccountResponse} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.litrpc.ListAccountsResponse.serializeBinaryToWriter = function(message, writer) { +proto.litrpc.CreditAccountResponse.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getAccountsList(); - if (f.length > 0) { - writer.writeRepeatedMessage( + f = message.getAccount(); + if (f != null) { + writer.writeMessage( 1, f, proto.litrpc.Account.serializeBinaryToWriter @@ -1866,40 +2049,39 @@ proto.litrpc.ListAccountsResponse.serializeBinaryToWriter = function(message, wr /** - * repeated Account accounts = 1; - * @return {!Array} + * optional Account account = 1; + * @return {?proto.litrpc.Account} */ -proto.litrpc.ListAccountsResponse.prototype.getAccountsList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.litrpc.Account, 1)); +proto.litrpc.CreditAccountResponse.prototype.getAccount = function() { + return /** @type{?proto.litrpc.Account} */ ( + jspb.Message.getWrapperField(this, proto.litrpc.Account, 1)); }; /** - * @param {!Array} value - * @return {!proto.litrpc.ListAccountsResponse} returns this + * @param {?proto.litrpc.Account|undefined} value + * @return {!proto.litrpc.CreditAccountResponse} returns this */ -proto.litrpc.ListAccountsResponse.prototype.setAccountsList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 1, value); +proto.litrpc.CreditAccountResponse.prototype.setAccount = function(value) { + return jspb.Message.setWrapperField(this, 1, value); }; /** - * @param {!proto.litrpc.Account=} opt_value - * @param {number=} opt_index - * @return {!proto.litrpc.Account} + * Clears the message field making it undefined. + * @return {!proto.litrpc.CreditAccountResponse} returns this */ -proto.litrpc.ListAccountsResponse.prototype.addAccounts = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.litrpc.Account, opt_index); +proto.litrpc.CreditAccountResponse.prototype.clearAccount = function() { + return this.setAccount(undefined); }; /** - * Clears the list making it empty but non-null. - * @return {!proto.litrpc.ListAccountsResponse} returns this + * Returns whether this field is set. + * @return {boolean} */ -proto.litrpc.ListAccountsResponse.prototype.clearAccountsList = function() { - return this.setAccountsList([]); +proto.litrpc.CreditAccountResponse.prototype.hasAccount = function() { + return jspb.Message.getField(this, 1) != null; }; @@ -1919,8 +2101,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * http://goto/soy-param-migration * @return {!Object} */ -proto.litrpc.AccountInfoRequest.prototype.toObject = function(opt_includeInstance) { - return proto.litrpc.AccountInfoRequest.toObject(opt_includeInstance, this); +proto.litrpc.DebitAccountRequest.prototype.toObject = function(opt_includeInstance) { + return proto.litrpc.DebitAccountRequest.toObject(opt_includeInstance, this); }; @@ -1929,14 +2111,14 @@ proto.litrpc.AccountInfoRequest.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.litrpc.AccountInfoRequest} msg The msg instance to transform. + * @param {!proto.litrpc.DebitAccountRequest} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.litrpc.AccountInfoRequest.toObject = function(includeInstance, msg) { +proto.litrpc.DebitAccountRequest.toObject = function(includeInstance, msg) { var f, obj = { - id: jspb.Message.getFieldWithDefault(msg, 1, ""), - label: jspb.Message.getFieldWithDefault(msg, 2, "") + account: (f = msg.getAccount()) && proto.litrpc.AccountIdentifier.toObject(includeInstance, f), + amount: jspb.Message.getFieldWithDefault(msg, 3, "0") }; if (includeInstance) { @@ -1950,23 +2132,23 @@ proto.litrpc.AccountInfoRequest.toObject = function(includeInstance, msg) { /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.litrpc.AccountInfoRequest} + * @return {!proto.litrpc.DebitAccountRequest} */ -proto.litrpc.AccountInfoRequest.deserializeBinary = function(bytes) { +proto.litrpc.DebitAccountRequest.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.litrpc.AccountInfoRequest; - return proto.litrpc.AccountInfoRequest.deserializeBinaryFromReader(msg, reader); + var msg = new proto.litrpc.DebitAccountRequest; + return proto.litrpc.DebitAccountRequest.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.litrpc.AccountInfoRequest} msg The message object to deserialize into. + * @param {!proto.litrpc.DebitAccountRequest} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.litrpc.AccountInfoRequest} + * @return {!proto.litrpc.DebitAccountRequest} */ -proto.litrpc.AccountInfoRequest.deserializeBinaryFromReader = function(msg, reader) { +proto.litrpc.DebitAccountRequest.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -1974,12 +2156,13 @@ proto.litrpc.AccountInfoRequest.deserializeBinaryFromReader = function(msg, read var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setId(value); + var value = new proto.litrpc.AccountIdentifier; + reader.readMessage(value,proto.litrpc.AccountIdentifier.deserializeBinaryFromReader); + msg.setAccount(value); break; - case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setLabel(value); + case 3: + var value = /** @type {string} */ (reader.readUint64String()); + msg.setAmount(value); break; default: reader.skipField(); @@ -1994,9 +2177,9 @@ proto.litrpc.AccountInfoRequest.deserializeBinaryFromReader = function(msg, read * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.litrpc.AccountInfoRequest.prototype.serializeBinary = function() { +proto.litrpc.DebitAccountRequest.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.litrpc.AccountInfoRequest.serializeBinaryToWriter(this, writer); + proto.litrpc.DebitAccountRequest.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -2004,15 +2187,607 @@ proto.litrpc.AccountInfoRequest.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.litrpc.AccountInfoRequest} message + * @param {!proto.litrpc.DebitAccountRequest} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.litrpc.AccountInfoRequest.serializeBinaryToWriter = function(message, writer) { +proto.litrpc.DebitAccountRequest.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getId(); - if (f.length > 0) { - writer.writeString( + f = message.getAccount(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.litrpc.AccountIdentifier.serializeBinaryToWriter + ); + } + f = message.getAmount(); + if (parseInt(f, 10) !== 0) { + writer.writeUint64String( + 3, + f + ); + } +}; + + +/** + * optional AccountIdentifier account = 1; + * @return {?proto.litrpc.AccountIdentifier} + */ +proto.litrpc.DebitAccountRequest.prototype.getAccount = function() { + return /** @type{?proto.litrpc.AccountIdentifier} */ ( + jspb.Message.getWrapperField(this, proto.litrpc.AccountIdentifier, 1)); +}; + + +/** + * @param {?proto.litrpc.AccountIdentifier|undefined} value + * @return {!proto.litrpc.DebitAccountRequest} returns this +*/ +proto.litrpc.DebitAccountRequest.prototype.setAccount = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.litrpc.DebitAccountRequest} returns this + */ +proto.litrpc.DebitAccountRequest.prototype.clearAccount = function() { + return this.setAccount(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.litrpc.DebitAccountRequest.prototype.hasAccount = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional uint64 amount = 3; + * @return {string} + */ +proto.litrpc.DebitAccountRequest.prototype.getAmount = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.litrpc.DebitAccountRequest} returns this + */ +proto.litrpc.DebitAccountRequest.prototype.setAmount = function(value) { + return jspb.Message.setProto3StringIntField(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.litrpc.DebitAccountResponse.prototype.toObject = function(opt_includeInstance) { + return proto.litrpc.DebitAccountResponse.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.litrpc.DebitAccountResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.DebitAccountResponse.toObject = function(includeInstance, msg) { + var f, obj = { + account: (f = msg.getAccount()) && proto.litrpc.Account.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.litrpc.DebitAccountResponse} + */ +proto.litrpc.DebitAccountResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.litrpc.DebitAccountResponse; + return proto.litrpc.DebitAccountResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.litrpc.DebitAccountResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.litrpc.DebitAccountResponse} + */ +proto.litrpc.DebitAccountResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.litrpc.Account; + reader.readMessage(value,proto.litrpc.Account.deserializeBinaryFromReader); + msg.setAccount(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.litrpc.DebitAccountResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.litrpc.DebitAccountResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.litrpc.DebitAccountResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.DebitAccountResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getAccount(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.litrpc.Account.serializeBinaryToWriter + ); + } +}; + + +/** + * optional Account account = 1; + * @return {?proto.litrpc.Account} + */ +proto.litrpc.DebitAccountResponse.prototype.getAccount = function() { + return /** @type{?proto.litrpc.Account} */ ( + jspb.Message.getWrapperField(this, proto.litrpc.Account, 1)); +}; + + +/** + * @param {?proto.litrpc.Account|undefined} value + * @return {!proto.litrpc.DebitAccountResponse} returns this +*/ +proto.litrpc.DebitAccountResponse.prototype.setAccount = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.litrpc.DebitAccountResponse} returns this + */ +proto.litrpc.DebitAccountResponse.prototype.clearAccount = function() { + return this.setAccount(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.litrpc.DebitAccountResponse.prototype.hasAccount = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.litrpc.ListAccountsRequest.prototype.toObject = function(opt_includeInstance) { + return proto.litrpc.ListAccountsRequest.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.litrpc.ListAccountsRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.ListAccountsRequest.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.litrpc.ListAccountsRequest} + */ +proto.litrpc.ListAccountsRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.litrpc.ListAccountsRequest; + return proto.litrpc.ListAccountsRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.litrpc.ListAccountsRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.litrpc.ListAccountsRequest} + */ +proto.litrpc.ListAccountsRequest.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.litrpc.ListAccountsRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.litrpc.ListAccountsRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.litrpc.ListAccountsRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.ListAccountsRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.litrpc.ListAccountsResponse.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.litrpc.ListAccountsResponse.prototype.toObject = function(opt_includeInstance) { + return proto.litrpc.ListAccountsResponse.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.litrpc.ListAccountsResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.ListAccountsResponse.toObject = function(includeInstance, msg) { + var f, obj = { + accountsList: jspb.Message.toObjectList(msg.getAccountsList(), + proto.litrpc.Account.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.litrpc.ListAccountsResponse} + */ +proto.litrpc.ListAccountsResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.litrpc.ListAccountsResponse; + return proto.litrpc.ListAccountsResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.litrpc.ListAccountsResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.litrpc.ListAccountsResponse} + */ +proto.litrpc.ListAccountsResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.litrpc.Account; + reader.readMessage(value,proto.litrpc.Account.deserializeBinaryFromReader); + msg.addAccounts(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.litrpc.ListAccountsResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.litrpc.ListAccountsResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.litrpc.ListAccountsResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.ListAccountsResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getAccountsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 1, + f, + proto.litrpc.Account.serializeBinaryToWriter + ); + } +}; + + +/** + * repeated Account accounts = 1; + * @return {!Array} + */ +proto.litrpc.ListAccountsResponse.prototype.getAccountsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.litrpc.Account, 1)); +}; + + +/** + * @param {!Array} value + * @return {!proto.litrpc.ListAccountsResponse} returns this +*/ +proto.litrpc.ListAccountsResponse.prototype.setAccountsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); +}; + + +/** + * @param {!proto.litrpc.Account=} opt_value + * @param {number=} opt_index + * @return {!proto.litrpc.Account} + */ +proto.litrpc.ListAccountsResponse.prototype.addAccounts = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.litrpc.Account, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.litrpc.ListAccountsResponse} returns this + */ +proto.litrpc.ListAccountsResponse.prototype.clearAccountsList = function() { + return this.setAccountsList([]); +}; + + + + + +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.litrpc.AccountInfoRequest.prototype.toObject = function(opt_includeInstance) { + return proto.litrpc.AccountInfoRequest.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.litrpc.AccountInfoRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.AccountInfoRequest.toObject = function(includeInstance, msg) { + var f, obj = { + id: jspb.Message.getFieldWithDefault(msg, 1, ""), + label: 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.litrpc.AccountInfoRequest} + */ +proto.litrpc.AccountInfoRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.litrpc.AccountInfoRequest; + return proto.litrpc.AccountInfoRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.litrpc.AccountInfoRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.litrpc.AccountInfoRequest} + */ +proto.litrpc.AccountInfoRequest.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.setId(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setLabel(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.litrpc.AccountInfoRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.litrpc.AccountInfoRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.litrpc.AccountInfoRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.AccountInfoRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getId(); + if (f.length > 0) { + writer.writeString( 1, f ); @@ -2324,4 +3099,226 @@ proto.litrpc.RemoveAccountResponse.serializeBinaryToWriter = function(message, w }; + +/** + * 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.litrpc.AccountIdentifier.oneofGroups_ = [[1,2]]; + +/** + * @enum {number} + */ +proto.litrpc.AccountIdentifier.IdentifierCase = { + IDENTIFIER_NOT_SET: 0, + ID: 1, + LABEL: 2 +}; + +/** + * @return {proto.litrpc.AccountIdentifier.IdentifierCase} + */ +proto.litrpc.AccountIdentifier.prototype.getIdentifierCase = function() { + return /** @type {proto.litrpc.AccountIdentifier.IdentifierCase} */(jspb.Message.computeOneofCase(this, proto.litrpc.AccountIdentifier.oneofGroups_[0])); +}; + + + +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.litrpc.AccountIdentifier.prototype.toObject = function(opt_includeInstance) { + return proto.litrpc.AccountIdentifier.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.litrpc.AccountIdentifier} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.AccountIdentifier.toObject = function(includeInstance, msg) { + var f, obj = { + id: jspb.Message.getFieldWithDefault(msg, 1, ""), + label: 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.litrpc.AccountIdentifier} + */ +proto.litrpc.AccountIdentifier.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.litrpc.AccountIdentifier; + return proto.litrpc.AccountIdentifier.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.litrpc.AccountIdentifier} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.litrpc.AccountIdentifier} + */ +proto.litrpc.AccountIdentifier.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.setId(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setLabel(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.litrpc.AccountIdentifier.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.litrpc.AccountIdentifier.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.litrpc.AccountIdentifier} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.litrpc.AccountIdentifier.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeString( + 2, + f + ); + } +}; + + +/** + * optional string id = 1; + * @return {string} + */ +proto.litrpc.AccountIdentifier.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.litrpc.AccountIdentifier} returns this + */ +proto.litrpc.AccountIdentifier.prototype.setId = function(value) { + return jspb.Message.setOneofField(this, 1, proto.litrpc.AccountIdentifier.oneofGroups_[0], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.litrpc.AccountIdentifier} returns this + */ +proto.litrpc.AccountIdentifier.prototype.clearId = function() { + return jspb.Message.setOneofField(this, 1, proto.litrpc.AccountIdentifier.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.litrpc.AccountIdentifier.prototype.hasId = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional string label = 2; + * @return {string} + */ +proto.litrpc.AccountIdentifier.prototype.getLabel = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.litrpc.AccountIdentifier} returns this + */ +proto.litrpc.AccountIdentifier.prototype.setLabel = function(value) { + return jspb.Message.setOneofField(this, 2, proto.litrpc.AccountIdentifier.oneofGroups_[0], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.litrpc.AccountIdentifier} returns this + */ +proto.litrpc.AccountIdentifier.prototype.clearLabel = function() { + return jspb.Message.setOneofField(this, 2, proto.litrpc.AccountIdentifier.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.litrpc.AccountIdentifier.prototype.hasLabel = function() { + return jspb.Message.getField(this, 2) != null; +}; + + goog.object.extend(exports, proto.litrpc); diff --git a/app/src/types/generated/lit-accounts_pb_service.d.ts b/app/src/types/generated/lit-accounts_pb_service.d.ts index 448e29a9d..33a0d2be6 100644 --- a/app/src/types/generated/lit-accounts_pb_service.d.ts +++ b/app/src/types/generated/lit-accounts_pb_service.d.ts @@ -22,6 +22,24 @@ type AccountsUpdateAccount = { readonly responseType: typeof lit_accounts_pb.Account; }; +type AccountsCreditAccount = { + readonly methodName: string; + readonly service: typeof Accounts; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof lit_accounts_pb.CreditAccountRequest; + readonly responseType: typeof lit_accounts_pb.CreditAccountResponse; +}; + +type AccountsDebitAccount = { + readonly methodName: string; + readonly service: typeof Accounts; + readonly requestStream: false; + readonly responseStream: false; + readonly requestType: typeof lit_accounts_pb.DebitAccountRequest; + readonly responseType: typeof lit_accounts_pb.DebitAccountResponse; +}; + type AccountsListAccounts = { readonly methodName: string; readonly service: typeof Accounts; @@ -53,6 +71,8 @@ export class Accounts { static readonly serviceName: string; static readonly CreateAccount: AccountsCreateAccount; static readonly UpdateAccount: AccountsUpdateAccount; + static readonly CreditAccount: AccountsCreditAccount; + static readonly DebitAccount: AccountsDebitAccount; static readonly ListAccounts: AccountsListAccounts; static readonly AccountInfo: AccountsAccountInfo; static readonly RemoveAccount: AccountsRemoveAccount; @@ -108,6 +128,24 @@ export class AccountsClient { requestMessage: lit_accounts_pb.UpdateAccountRequest, callback: (error: ServiceError|null, responseMessage: lit_accounts_pb.Account|null) => void ): UnaryResponse; + creditAccount( + requestMessage: lit_accounts_pb.CreditAccountRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError|null, responseMessage: lit_accounts_pb.CreditAccountResponse|null) => void + ): UnaryResponse; + creditAccount( + requestMessage: lit_accounts_pb.CreditAccountRequest, + callback: (error: ServiceError|null, responseMessage: lit_accounts_pb.CreditAccountResponse|null) => void + ): UnaryResponse; + debitAccount( + requestMessage: lit_accounts_pb.DebitAccountRequest, + metadata: grpc.Metadata, + callback: (error: ServiceError|null, responseMessage: lit_accounts_pb.DebitAccountResponse|null) => void + ): UnaryResponse; + debitAccount( + requestMessage: lit_accounts_pb.DebitAccountRequest, + callback: (error: ServiceError|null, responseMessage: lit_accounts_pb.DebitAccountResponse|null) => void + ): UnaryResponse; listAccounts( requestMessage: lit_accounts_pb.ListAccountsRequest, metadata: grpc.Metadata, diff --git a/app/src/types/generated/lit-accounts_pb_service.js b/app/src/types/generated/lit-accounts_pb_service.js index ed4583b95..bf169c3b4 100644 --- a/app/src/types/generated/lit-accounts_pb_service.js +++ b/app/src/types/generated/lit-accounts_pb_service.js @@ -28,6 +28,24 @@ Accounts.UpdateAccount = { responseType: lit_accounts_pb.Account }; +Accounts.CreditAccount = { + methodName: "CreditAccount", + service: Accounts, + requestStream: false, + responseStream: false, + requestType: lit_accounts_pb.CreditAccountRequest, + responseType: lit_accounts_pb.CreditAccountResponse +}; + +Accounts.DebitAccount = { + methodName: "DebitAccount", + service: Accounts, + requestStream: false, + responseStream: false, + requestType: lit_accounts_pb.DebitAccountRequest, + responseType: lit_accounts_pb.DebitAccountResponse +}; + Accounts.ListAccounts = { methodName: "ListAccounts", service: Accounts, @@ -124,6 +142,68 @@ AccountsClient.prototype.updateAccount = function updateAccount(requestMessage, }; }; +AccountsClient.prototype.creditAccount = function creditAccount(requestMessage, metadata, callback) { + if (arguments.length === 2) { + callback = arguments[1]; + } + var client = grpc.unary(Accounts.CreditAccount, { + request: requestMessage, + host: this.serviceHost, + metadata: metadata, + transport: this.options.transport, + debug: this.options.debug, + onEnd: function (response) { + if (callback) { + if (response.status !== grpc.Code.OK) { + var err = new Error(response.statusMessage); + err.code = response.status; + err.metadata = response.trailers; + callback(err, null); + } else { + callback(null, response.message); + } + } + } + }); + return { + cancel: function () { + callback = null; + client.close(); + } + }; +}; + +AccountsClient.prototype.debitAccount = function debitAccount(requestMessage, metadata, callback) { + if (arguments.length === 2) { + callback = arguments[1]; + } + var client = grpc.unary(Accounts.DebitAccount, { + request: requestMessage, + host: this.serviceHost, + metadata: metadata, + transport: this.options.transport, + debug: this.options.debug, + onEnd: function (response) { + if (callback) { + if (response.status !== grpc.Code.OK) { + var err = new Error(response.statusMessage); + err.code = response.status; + err.metadata = response.trailers; + callback(err, null); + } else { + callback(null, response.message); + } + } + } + }); + return { + cancel: function () { + callback = null; + client.close(); + } + }; +}; + AccountsClient.prototype.listAccounts = function listAccounts(requestMessage, metadata, callback) { if (arguments.length === 2) { callback = arguments[1]; diff --git a/litrpc/accounts.pb.json.go b/litrpc/accounts.pb.json.go index f8cf5c089..37773a39c 100644 --- a/litrpc/accounts.pb.json.go +++ b/litrpc/accounts.pb.json.go @@ -71,6 +71,56 @@ func RegisterAccountsJSONCallbacks(registry map[string]func(ctx context.Context, callback(string(respBytes), nil) } + registry["litrpc.Accounts.CreditAccount"] = func(ctx context.Context, + conn *grpc.ClientConn, reqJSON string, callback func(string, error)) { + + req := &CreditAccountRequest{} + err := marshaler.Unmarshal([]byte(reqJSON), req) + if err != nil { + callback("", err) + return + } + + client := NewAccountsClient(conn) + resp, err := client.CreditAccount(ctx, req) + if err != nil { + callback("", err) + return + } + + respBytes, err := marshaler.Marshal(resp) + if err != nil { + callback("", err) + return + } + callback(string(respBytes), nil) + } + + registry["litrpc.Accounts.DebitAccount"] = func(ctx context.Context, + conn *grpc.ClientConn, reqJSON string, callback func(string, error)) { + + req := &DebitAccountRequest{} + err := marshaler.Unmarshal([]byte(reqJSON), req) + if err != nil { + callback("", err) + return + } + + client := NewAccountsClient(conn) + resp, err := client.DebitAccount(ctx, req) + if err != nil { + callback("", err) + return + } + + respBytes, err := marshaler.Marshal(resp) + if err != nil { + callback("", err) + return + } + callback(string(respBytes), nil) + } + registry["litrpc.Accounts.ListAccounts"] = func(ctx context.Context, conn *grpc.ClientConn, reqJSON string, callback func(string, error)) { diff --git a/litrpc/lit-accounts.pb.go b/litrpc/lit-accounts.pb.go index 903a8473e..ad8c20304 100644 --- a/litrpc/lit-accounts.pb.go +++ b/litrpc/lit-accounts.pb.go @@ -452,6 +452,216 @@ func (x *UpdateAccountRequest) GetLabel() string { return "" } +type CreditAccountRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The identifier of the account to credit. + Account *AccountIdentifier `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` + // The amount by which the account's balance should be credited. + Amount uint64 `protobuf:"varint,2,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (x *CreditAccountRequest) Reset() { + *x = CreditAccountRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_lit_accounts_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreditAccountRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreditAccountRequest) ProtoMessage() {} + +func (x *CreditAccountRequest) ProtoReflect() protoreflect.Message { + mi := &file_lit_accounts_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreditAccountRequest.ProtoReflect.Descriptor instead. +func (*CreditAccountRequest) Descriptor() ([]byte, []int) { + return file_lit_accounts_proto_rawDescGZIP(), []int{6} +} + +func (x *CreditAccountRequest) GetAccount() *AccountIdentifier { + if x != nil { + return x.Account + } + return nil +} + +func (x *CreditAccountRequest) GetAmount() uint64 { + if x != nil { + return x.Amount + } + return 0 +} + +type CreditAccountResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The credited account. + Account *Account `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` +} + +func (x *CreditAccountResponse) Reset() { + *x = CreditAccountResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_lit_accounts_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreditAccountResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreditAccountResponse) ProtoMessage() {} + +func (x *CreditAccountResponse) ProtoReflect() protoreflect.Message { + mi := &file_lit_accounts_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreditAccountResponse.ProtoReflect.Descriptor instead. +func (*CreditAccountResponse) Descriptor() ([]byte, []int) { + return file_lit_accounts_proto_rawDescGZIP(), []int{7} +} + +func (x *CreditAccountResponse) GetAccount() *Account { + if x != nil { + return x.Account + } + return nil +} + +type DebitAccountRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The identifier of the account to debit. + Account *AccountIdentifier `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` + // The amount by which the account's balance should be debited. + Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (x *DebitAccountRequest) Reset() { + *x = DebitAccountRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_lit_accounts_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DebitAccountRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DebitAccountRequest) ProtoMessage() {} + +func (x *DebitAccountRequest) ProtoReflect() protoreflect.Message { + mi := &file_lit_accounts_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DebitAccountRequest.ProtoReflect.Descriptor instead. +func (*DebitAccountRequest) Descriptor() ([]byte, []int) { + return file_lit_accounts_proto_rawDescGZIP(), []int{8} +} + +func (x *DebitAccountRequest) GetAccount() *AccountIdentifier { + if x != nil { + return x.Account + } + return nil +} + +func (x *DebitAccountRequest) GetAmount() uint64 { + if x != nil { + return x.Amount + } + return 0 +} + +type DebitAccountResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The debited account. + Account *Account `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` +} + +func (x *DebitAccountResponse) Reset() { + *x = DebitAccountResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_lit_accounts_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DebitAccountResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DebitAccountResponse) ProtoMessage() {} + +func (x *DebitAccountResponse) ProtoReflect() protoreflect.Message { + mi := &file_lit_accounts_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DebitAccountResponse.ProtoReflect.Descriptor instead. +func (*DebitAccountResponse) Descriptor() ([]byte, []int) { + return file_lit_accounts_proto_rawDescGZIP(), []int{9} +} + +func (x *DebitAccountResponse) GetAccount() *Account { + if x != nil { + return x.Account + } + return nil +} + type ListAccountsRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -461,7 +671,7 @@ type ListAccountsRequest struct { func (x *ListAccountsRequest) Reset() { *x = ListAccountsRequest{} if protoimpl.UnsafeEnabled { - mi := &file_lit_accounts_proto_msgTypes[6] + mi := &file_lit_accounts_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -474,7 +684,7 @@ func (x *ListAccountsRequest) String() string { func (*ListAccountsRequest) ProtoMessage() {} func (x *ListAccountsRequest) ProtoReflect() protoreflect.Message { - mi := &file_lit_accounts_proto_msgTypes[6] + mi := &file_lit_accounts_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -487,7 +697,7 @@ func (x *ListAccountsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListAccountsRequest.ProtoReflect.Descriptor instead. func (*ListAccountsRequest) Descriptor() ([]byte, []int) { - return file_lit_accounts_proto_rawDescGZIP(), []int{6} + return file_lit_accounts_proto_rawDescGZIP(), []int{10} } type ListAccountsResponse struct { @@ -502,7 +712,7 @@ type ListAccountsResponse struct { func (x *ListAccountsResponse) Reset() { *x = ListAccountsResponse{} if protoimpl.UnsafeEnabled { - mi := &file_lit_accounts_proto_msgTypes[7] + mi := &file_lit_accounts_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -515,7 +725,7 @@ func (x *ListAccountsResponse) String() string { func (*ListAccountsResponse) ProtoMessage() {} func (x *ListAccountsResponse) ProtoReflect() protoreflect.Message { - mi := &file_lit_accounts_proto_msgTypes[7] + mi := &file_lit_accounts_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -528,7 +738,7 @@ func (x *ListAccountsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListAccountsResponse.ProtoReflect.Descriptor instead. func (*ListAccountsResponse) Descriptor() ([]byte, []int) { - return file_lit_accounts_proto_rawDescGZIP(), []int{7} + return file_lit_accounts_proto_rawDescGZIP(), []int{11} } func (x *ListAccountsResponse) GetAccounts() []*Account { @@ -554,7 +764,7 @@ type AccountInfoRequest struct { func (x *AccountInfoRequest) Reset() { *x = AccountInfoRequest{} if protoimpl.UnsafeEnabled { - mi := &file_lit_accounts_proto_msgTypes[8] + mi := &file_lit_accounts_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -567,7 +777,7 @@ func (x *AccountInfoRequest) String() string { func (*AccountInfoRequest) ProtoMessage() {} func (x *AccountInfoRequest) ProtoReflect() protoreflect.Message { - mi := &file_lit_accounts_proto_msgTypes[8] + mi := &file_lit_accounts_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -580,7 +790,7 @@ func (x *AccountInfoRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AccountInfoRequest.ProtoReflect.Descriptor instead. func (*AccountInfoRequest) Descriptor() ([]byte, []int) { - return file_lit_accounts_proto_rawDescGZIP(), []int{8} + return file_lit_accounts_proto_rawDescGZIP(), []int{12} } func (x *AccountInfoRequest) GetId() string { @@ -613,7 +823,7 @@ type RemoveAccountRequest struct { func (x *RemoveAccountRequest) Reset() { *x = RemoveAccountRequest{} if protoimpl.UnsafeEnabled { - mi := &file_lit_accounts_proto_msgTypes[9] + mi := &file_lit_accounts_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -626,7 +836,7 @@ func (x *RemoveAccountRequest) String() string { func (*RemoveAccountRequest) ProtoMessage() {} func (x *RemoveAccountRequest) ProtoReflect() protoreflect.Message { - mi := &file_lit_accounts_proto_msgTypes[9] + mi := &file_lit_accounts_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -639,7 +849,7 @@ func (x *RemoveAccountRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveAccountRequest.ProtoReflect.Descriptor instead. func (*RemoveAccountRequest) Descriptor() ([]byte, []int) { - return file_lit_accounts_proto_rawDescGZIP(), []int{9} + return file_lit_accounts_proto_rawDescGZIP(), []int{13} } func (x *RemoveAccountRequest) GetId() string { @@ -665,7 +875,7 @@ type RemoveAccountResponse struct { func (x *RemoveAccountResponse) Reset() { *x = RemoveAccountResponse{} if protoimpl.UnsafeEnabled { - mi := &file_lit_accounts_proto_msgTypes[10] + mi := &file_lit_accounts_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -678,7 +888,7 @@ func (x *RemoveAccountResponse) String() string { func (*RemoveAccountResponse) ProtoMessage() {} func (x *RemoveAccountResponse) ProtoReflect() protoreflect.Message { - mi := &file_lit_accounts_proto_msgTypes[10] + mi := &file_lit_accounts_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -691,9 +901,92 @@ func (x *RemoveAccountResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveAccountResponse.ProtoReflect.Descriptor instead. func (*RemoveAccountResponse) Descriptor() ([]byte, []int) { - return file_lit_accounts_proto_rawDescGZIP(), []int{10} + return file_lit_accounts_proto_rawDescGZIP(), []int{14} +} + +type AccountIdentifier struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Identifier: + // + // *AccountIdentifier_Id + // *AccountIdentifier_Label + Identifier isAccountIdentifier_Identifier `protobuf_oneof:"identifier"` +} + +func (x *AccountIdentifier) Reset() { + *x = AccountIdentifier{} + if protoimpl.UnsafeEnabled { + mi := &file_lit_accounts_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AccountIdentifier) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AccountIdentifier) ProtoMessage() {} + +func (x *AccountIdentifier) ProtoReflect() protoreflect.Message { + mi := &file_lit_accounts_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AccountIdentifier.ProtoReflect.Descriptor instead. +func (*AccountIdentifier) Descriptor() ([]byte, []int) { + return file_lit_accounts_proto_rawDescGZIP(), []int{15} +} + +func (m *AccountIdentifier) GetIdentifier() isAccountIdentifier_Identifier { + if m != nil { + return m.Identifier + } + return nil +} + +func (x *AccountIdentifier) GetId() string { + if x, ok := x.GetIdentifier().(*AccountIdentifier_Id); ok { + return x.Id + } + return "" +} + +func (x *AccountIdentifier) GetLabel() string { + if x, ok := x.GetIdentifier().(*AccountIdentifier_Label); ok { + return x.Label + } + return "" +} + +type isAccountIdentifier_Identifier interface { + isAccountIdentifier_Identifier() +} + +type AccountIdentifier_Id struct { + // The ID of the account. + Id string `protobuf:"bytes,1,opt,name=id,proto3,oneof"` +} + +type AccountIdentifier_Label struct { + // The label of the account. + Label string `protobuf:"bytes,2,opt,name=label,proto3,oneof"` } +func (*AccountIdentifier_Id) isAccountIdentifier_Identifier() {} + +func (*AccountIdentifier_Label) isAccountIdentifier_Identifier() {} + var File_lit_accounts_proto protoreflect.FileDescriptor var file_lit_accounts_proto_rawDesc = []byte{ @@ -749,7 +1042,28 @@ var file_lit_accounts_proto_rawDesc = []byte{ 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x22, 0x15, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, + 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x22, 0x63, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x64, 0x69, 0x74, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x33, + 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x19, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x42, 0x0a, 0x15, 0x43, + 0x72, 0x65, 0x64, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, + 0x62, 0x0a, 0x13, 0x44, 0x65, 0x62, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x33, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, + 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, + 0x65, 0x72, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61, + 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x61, 0x6d, 0x6f, + 0x75, 0x6e, 0x74, 0x22, 0x41, 0x0a, 0x14, 0x44, 0x65, 0x62, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x07, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6c, + 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x15, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x43, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2b, 0x0a, 0x08, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, @@ -764,34 +1078,48 @@ var file_lit_accounts_proto_rawDesc = []byte{ 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x22, 0x17, 0x0a, 0x15, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xed, 0x02, 0x0a, 0x08, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x73, 0x12, 0x4c, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x12, 0x1c, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x1d, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x3e, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x12, 0x1c, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x0f, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x12, 0x49, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, - 0x12, 0x1b, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, - 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x0b, 0x41, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x2e, 0x6c, 0x69, 0x74, - 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, - 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x4c, 0x0a, 0x0d, 0x52, 0x65, 0x6d, 0x6f, 0x76, - 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1c, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, - 0x63, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, - 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, 0x67, 0x6c, 0x61, 0x62, - 0x73, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, 0x67, 0x2d, 0x74, 0x65, 0x72, 0x6d, - 0x69, 0x6e, 0x61, 0x6c, 0x2f, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x4b, 0x0a, 0x11, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x05, + 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x05, 0x6c, + 0x61, 0x62, 0x65, 0x6c, 0x42, 0x0c, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, + 0x65, 0x72, 0x32, 0x86, 0x04, 0x0a, 0x08, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x12, + 0x4c, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x12, 0x1c, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, + 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, + 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1c, + 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x6c, + 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x4c, 0x0a, + 0x0d, 0x43, 0x72, 0x65, 0x64, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1c, + 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x64, 0x69, 0x74, 0x41, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x6c, + 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x64, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x0c, 0x44, + 0x65, 0x62, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1b, 0x2e, 0x6c, 0x69, + 0x74, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x62, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, + 0x63, 0x2e, 0x44, 0x65, 0x62, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x12, 0x1b, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, + 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, + 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x3a, 0x0a, 0x0b, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, + 0x12, 0x1a, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x6c, + 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x4c, 0x0a, + 0x0d, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1c, + 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x41, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x6c, + 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x41, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x34, 0x5a, 0x32, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, + 0x69, 0x6e, 0x67, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, + 0x67, 0x2d, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x2f, 0x6c, 0x69, 0x74, 0x72, 0x70, + 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -806,7 +1134,7 @@ func file_lit_accounts_proto_rawDescGZIP() []byte { return file_lit_accounts_proto_rawDescData } -var file_lit_accounts_proto_msgTypes = make([]protoimpl.MessageInfo, 11) +var file_lit_accounts_proto_msgTypes = make([]protoimpl.MessageInfo, 16) var file_lit_accounts_proto_goTypes = []any{ (*CreateAccountRequest)(nil), // 0: litrpc.CreateAccountRequest (*CreateAccountResponse)(nil), // 1: litrpc.CreateAccountResponse @@ -814,32 +1142,45 @@ var file_lit_accounts_proto_goTypes = []any{ (*AccountInvoice)(nil), // 3: litrpc.AccountInvoice (*AccountPayment)(nil), // 4: litrpc.AccountPayment (*UpdateAccountRequest)(nil), // 5: litrpc.UpdateAccountRequest - (*ListAccountsRequest)(nil), // 6: litrpc.ListAccountsRequest - (*ListAccountsResponse)(nil), // 7: litrpc.ListAccountsResponse - (*AccountInfoRequest)(nil), // 8: litrpc.AccountInfoRequest - (*RemoveAccountRequest)(nil), // 9: litrpc.RemoveAccountRequest - (*RemoveAccountResponse)(nil), // 10: litrpc.RemoveAccountResponse + (*CreditAccountRequest)(nil), // 6: litrpc.CreditAccountRequest + (*CreditAccountResponse)(nil), // 7: litrpc.CreditAccountResponse + (*DebitAccountRequest)(nil), // 8: litrpc.DebitAccountRequest + (*DebitAccountResponse)(nil), // 9: litrpc.DebitAccountResponse + (*ListAccountsRequest)(nil), // 10: litrpc.ListAccountsRequest + (*ListAccountsResponse)(nil), // 11: litrpc.ListAccountsResponse + (*AccountInfoRequest)(nil), // 12: litrpc.AccountInfoRequest + (*RemoveAccountRequest)(nil), // 13: litrpc.RemoveAccountRequest + (*RemoveAccountResponse)(nil), // 14: litrpc.RemoveAccountResponse + (*AccountIdentifier)(nil), // 15: litrpc.AccountIdentifier } var file_lit_accounts_proto_depIdxs = []int32{ 2, // 0: litrpc.CreateAccountResponse.account:type_name -> litrpc.Account 3, // 1: litrpc.Account.invoices:type_name -> litrpc.AccountInvoice 4, // 2: litrpc.Account.payments:type_name -> litrpc.AccountPayment - 2, // 3: litrpc.ListAccountsResponse.accounts:type_name -> litrpc.Account - 0, // 4: litrpc.Accounts.CreateAccount:input_type -> litrpc.CreateAccountRequest - 5, // 5: litrpc.Accounts.UpdateAccount:input_type -> litrpc.UpdateAccountRequest - 6, // 6: litrpc.Accounts.ListAccounts:input_type -> litrpc.ListAccountsRequest - 8, // 7: litrpc.Accounts.AccountInfo:input_type -> litrpc.AccountInfoRequest - 9, // 8: litrpc.Accounts.RemoveAccount:input_type -> litrpc.RemoveAccountRequest - 1, // 9: litrpc.Accounts.CreateAccount:output_type -> litrpc.CreateAccountResponse - 2, // 10: litrpc.Accounts.UpdateAccount:output_type -> litrpc.Account - 7, // 11: litrpc.Accounts.ListAccounts:output_type -> litrpc.ListAccountsResponse - 2, // 12: litrpc.Accounts.AccountInfo:output_type -> litrpc.Account - 10, // 13: litrpc.Accounts.RemoveAccount:output_type -> litrpc.RemoveAccountResponse - 9, // [9:14] is the sub-list for method output_type - 4, // [4:9] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 15, // 3: litrpc.CreditAccountRequest.account:type_name -> litrpc.AccountIdentifier + 2, // 4: litrpc.CreditAccountResponse.account:type_name -> litrpc.Account + 15, // 5: litrpc.DebitAccountRequest.account:type_name -> litrpc.AccountIdentifier + 2, // 6: litrpc.DebitAccountResponse.account:type_name -> litrpc.Account + 2, // 7: litrpc.ListAccountsResponse.accounts:type_name -> litrpc.Account + 0, // 8: litrpc.Accounts.CreateAccount:input_type -> litrpc.CreateAccountRequest + 5, // 9: litrpc.Accounts.UpdateAccount:input_type -> litrpc.UpdateAccountRequest + 6, // 10: litrpc.Accounts.CreditAccount:input_type -> litrpc.CreditAccountRequest + 8, // 11: litrpc.Accounts.DebitAccount:input_type -> litrpc.DebitAccountRequest + 10, // 12: litrpc.Accounts.ListAccounts:input_type -> litrpc.ListAccountsRequest + 12, // 13: litrpc.Accounts.AccountInfo:input_type -> litrpc.AccountInfoRequest + 13, // 14: litrpc.Accounts.RemoveAccount:input_type -> litrpc.RemoveAccountRequest + 1, // 15: litrpc.Accounts.CreateAccount:output_type -> litrpc.CreateAccountResponse + 2, // 16: litrpc.Accounts.UpdateAccount:output_type -> litrpc.Account + 7, // 17: litrpc.Accounts.CreditAccount:output_type -> litrpc.CreditAccountResponse + 9, // 18: litrpc.Accounts.DebitAccount:output_type -> litrpc.DebitAccountResponse + 11, // 19: litrpc.Accounts.ListAccounts:output_type -> litrpc.ListAccountsResponse + 2, // 20: litrpc.Accounts.AccountInfo:output_type -> litrpc.Account + 14, // 21: litrpc.Accounts.RemoveAccount:output_type -> litrpc.RemoveAccountResponse + 15, // [15:22] is the sub-list for method output_type + 8, // [8:15] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name } func init() { file_lit_accounts_proto_init() } @@ -921,7 +1262,7 @@ func file_lit_accounts_proto_init() { } } file_lit_accounts_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*ListAccountsRequest); i { + switch v := v.(*CreditAccountRequest); i { case 0: return &v.state case 1: @@ -933,7 +1274,7 @@ func file_lit_accounts_proto_init() { } } file_lit_accounts_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*ListAccountsResponse); i { + switch v := v.(*CreditAccountResponse); i { case 0: return &v.state case 1: @@ -945,7 +1286,7 @@ func file_lit_accounts_proto_init() { } } file_lit_accounts_proto_msgTypes[8].Exporter = func(v any, i int) any { - switch v := v.(*AccountInfoRequest); i { + switch v := v.(*DebitAccountRequest); i { case 0: return &v.state case 1: @@ -957,7 +1298,7 @@ func file_lit_accounts_proto_init() { } } file_lit_accounts_proto_msgTypes[9].Exporter = func(v any, i int) any { - switch v := v.(*RemoveAccountRequest); i { + switch v := v.(*DebitAccountResponse); i { case 0: return &v.state case 1: @@ -969,6 +1310,54 @@ func file_lit_accounts_proto_init() { } } file_lit_accounts_proto_msgTypes[10].Exporter = func(v any, i int) any { + switch v := v.(*ListAccountsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_lit_accounts_proto_msgTypes[11].Exporter = func(v any, i int) any { + switch v := v.(*ListAccountsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_lit_accounts_proto_msgTypes[12].Exporter = func(v any, i int) any { + switch v := v.(*AccountInfoRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_lit_accounts_proto_msgTypes[13].Exporter = func(v any, i int) any { + switch v := v.(*RemoveAccountRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_lit_accounts_proto_msgTypes[14].Exporter = func(v any, i int) any { switch v := v.(*RemoveAccountResponse); i { case 0: return &v.state @@ -980,6 +1369,22 @@ func file_lit_accounts_proto_init() { return nil } } + file_lit_accounts_proto_msgTypes[15].Exporter = func(v any, i int) any { + switch v := v.(*AccountIdentifier); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_lit_accounts_proto_msgTypes[15].OneofWrappers = []any{ + (*AccountIdentifier_Id)(nil), + (*AccountIdentifier_Label)(nil), } type x struct{} out := protoimpl.TypeBuilder{ @@ -987,7 +1392,7 @@ func file_lit_accounts_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_lit_accounts_proto_rawDesc, NumEnums: 0, - NumMessages: 11, + NumMessages: 16, NumExtensions: 0, NumServices: 1, }, diff --git a/litrpc/lit-accounts.pb.gw.go b/litrpc/lit-accounts.pb.gw.go index 2c867c3be..9db31213d 100644 --- a/litrpc/lit-accounts.pb.gw.go +++ b/litrpc/lit-accounts.pb.gw.go @@ -117,6 +117,126 @@ func local_request_Accounts_UpdateAccount_0(ctx context.Context, marshaler runti } +func request_Accounts_CreditAccount_0(ctx context.Context, marshaler runtime.Marshaler, client AccountsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreditAccountRequest + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["account.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "account.id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "account.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "account.id", err) + } + + msg, err := client.CreditAccount(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Accounts_CreditAccount_0(ctx context.Context, marshaler runtime.Marshaler, server AccountsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq CreditAccountRequest + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["account.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "account.id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "account.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "account.id", err) + } + + msg, err := server.CreditAccount(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Accounts_DebitAccount_0(ctx context.Context, marshaler runtime.Marshaler, client AccountsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DebitAccountRequest + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["account.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "account.id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "account.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "account.id", err) + } + + msg, err := client.DebitAccount(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Accounts_DebitAccount_0(ctx context.Context, marshaler runtime.Marshaler, server AccountsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DebitAccountRequest + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["account.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "account.id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "account.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "account.id", err) + } + + msg, err := server.DebitAccount(ctx, &protoReq) + return msg, metadata, err + +} + func request_Accounts_ListAccounts_0(ctx context.Context, marshaler runtime.Marshaler, client AccountsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq ListAccountsRequest var metadata runtime.ServerMetadata @@ -262,6 +382,56 @@ func RegisterAccountsHandlerServer(ctx context.Context, mux *runtime.ServeMux, s }) + mux.Handle("POST", pattern_Accounts_CreditAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/litrpc.Accounts/CreditAccount", runtime.WithHTTPPathPattern("/v1/accounts/credit/{account.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Accounts_CreditAccount_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Accounts_CreditAccount_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Accounts_DebitAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/litrpc.Accounts/DebitAccount", runtime.WithHTTPPathPattern("/v1/accounts/debit/{account.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Accounts_DebitAccount_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Accounts_DebitAccount_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Accounts_ListAccounts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -397,6 +567,50 @@ func RegisterAccountsHandlerClient(ctx context.Context, mux *runtime.ServeMux, c }) + mux.Handle("POST", pattern_Accounts_CreditAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/litrpc.Accounts/CreditAccount", runtime.WithHTTPPathPattern("/v1/accounts/credit/{account.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Accounts_CreditAccount_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Accounts_CreditAccount_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_Accounts_DebitAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/litrpc.Accounts/DebitAccount", runtime.WithHTTPPathPattern("/v1/accounts/debit/{account.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Accounts_DebitAccount_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_Accounts_DebitAccount_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Accounts_ListAccounts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -449,6 +663,10 @@ var ( pattern_Accounts_UpdateAccount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "accounts", "id"}, "")) + pattern_Accounts_CreditAccount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "accounts", "credit", "account.id"}, "")) + + pattern_Accounts_DebitAccount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "accounts", "debit", "account.id"}, "")) + pattern_Accounts_ListAccounts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "accounts"}, "")) pattern_Accounts_RemoveAccount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "accounts", "id"}, "")) @@ -459,6 +677,10 @@ var ( forward_Accounts_UpdateAccount_0 = runtime.ForwardResponseMessage + forward_Accounts_CreditAccount_0 = runtime.ForwardResponseMessage + + forward_Accounts_DebitAccount_0 = runtime.ForwardResponseMessage + forward_Accounts_ListAccounts_0 = runtime.ForwardResponseMessage forward_Accounts_RemoveAccount_0 = runtime.ForwardResponseMessage diff --git a/litrpc/lit-accounts.proto b/litrpc/lit-accounts.proto index 209183a12..ba616cdff 100644 --- a/litrpc/lit-accounts.proto +++ b/litrpc/lit-accounts.proto @@ -25,6 +25,18 @@ service Accounts { */ rpc UpdateAccount (UpdateAccountRequest) returns (Account); + /* litcli: `accounts update credit` + CreditAccount increases the balance of an existing account in the account + database. + */ + rpc CreditAccount (CreditAccountRequest) returns (CreditAccountResponse); + + /* litcli: `accounts update debit` + DebitAccount decreases the balance of an existing account in the account + database. + */ + rpc DebitAccount (DebitAccountRequest) returns (DebitAccountResponse); + /* litcli: `accounts list` ListAccounts returns all accounts that are currently stored in the account database. @@ -148,6 +160,36 @@ message UpdateAccountRequest { string label = 4; } +message CreditAccountRequest { + // The identifier of the account to credit. + AccountIdentifier account = 1; + + /* + The amount by which the account's balance should be credited. + */ + uint64 amount = 2; +} + +message CreditAccountResponse { + // The credited account. + Account account = 1; +} + +message DebitAccountRequest { + // The identifier of the account to debit. + AccountIdentifier account = 1; + + /* + The amount by which the account's balance should be debited. + */ + uint64 amount = 3; +} + +message DebitAccountResponse { + // The debited account. + Account account = 1; +} + message ListAccountsRequest { } @@ -186,3 +228,13 @@ message RemoveAccountRequest { message RemoveAccountResponse { } + +message AccountIdentifier { + oneof identifier { + // The ID of the account. + string id = 1; + + // The label of the account. + string label = 2; + } +} \ No newline at end of file diff --git a/litrpc/lit-accounts.swagger.json b/litrpc/lit-accounts.swagger.json index 09a226165..65cf5b51d 100644 --- a/litrpc/lit-accounts.swagger.json +++ b/litrpc/lit-accounts.swagger.json @@ -71,6 +71,86 @@ ] } }, + "/v1/accounts/credit/{account.id}": { + "post": { + "summary": "litcli: `accounts update credit`\nCreditAccount increases the balance of an existing account in the account\ndatabase.", + "operationId": "Accounts_CreditAccount", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/litrpcCreditAccountResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "account.id", + "description": "The ID of the account.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/AccountsCreditAccountBody" + } + } + ], + "tags": [ + "Accounts" + ] + } + }, + "/v1/accounts/debit/{account.id}": { + "post": { + "summary": "litcli: `accounts update debit`\nDebitAccount decreases the balance of an existing account in the account\ndatabase.", + "operationId": "Accounts_DebitAccount", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/litrpcDebitAccountResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "account.id", + "description": "The ID of the account.", + "in": "path", + "required": true, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/AccountsDebitAccountBody" + } + } + ], + "tags": [ + "Accounts" + ] + } + }, "/v1/accounts/{id}": { "delete": { "summary": "litcli: `accounts remove`\nRemoveAccount removes the given account from the account database.", @@ -150,6 +230,48 @@ } }, "definitions": { + "AccountsCreditAccountBody": { + "type": "object", + "properties": { + "account": { + "type": "object", + "properties": { + "label": { + "type": "string", + "description": "The label of the account." + } + }, + "description": "The identifier of the account to credit.", + "title": "The identifier of the account to credit." + }, + "amount": { + "type": "string", + "format": "uint64", + "description": "The amount by which the account's balance should be credited." + } + } + }, + "AccountsDebitAccountBody": { + "type": "object", + "properties": { + "account": { + "type": "object", + "properties": { + "label": { + "type": "string", + "description": "The label of the account." + } + }, + "description": "The identifier of the account to debit.", + "title": "The identifier of the account to debit." + }, + "amount": { + "type": "string", + "format": "uint64", + "description": "The amount by which the account's balance should be debited." + } + } + }, "AccountsUpdateAccountBody": { "type": "object", "properties": { @@ -218,6 +340,19 @@ } } }, + "litrpcAccountIdentifier": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The ID of the account." + }, + "label": { + "type": "string", + "description": "The label of the account." + } + } + }, "litrpcAccountInvoice": { "type": "object", "properties": { @@ -280,6 +415,24 @@ } } }, + "litrpcCreditAccountResponse": { + "type": "object", + "properties": { + "account": { + "$ref": "#/definitions/litrpcAccount", + "description": "The credited account." + } + } + }, + "litrpcDebitAccountResponse": { + "type": "object", + "properties": { + "account": { + "$ref": "#/definitions/litrpcAccount", + "description": "The debited account." + } + } + }, "litrpcListAccountsResponse": { "type": "object", "properties": { diff --git a/litrpc/lit-accounts.yaml b/litrpc/lit-accounts.yaml index b4e9c773b..7fa8e2d6e 100644 --- a/litrpc/lit-accounts.yaml +++ b/litrpc/lit-accounts.yaml @@ -15,3 +15,9 @@ http: get: "/v1/accounts" - selector: litrpc.Accounts.RemoveAccount delete: "/v1/accounts/{id}" + - selector: litrpc.Accounts.CreditAccount + post: "/v1/accounts/credit/{account.id}" + body: "*" + - selector: litrpc.Accounts.DebitAccount + post: "/v1/accounts/debit/{account.id}" + body: "*" diff --git a/litrpc/lit-accounts_grpc.pb.go b/litrpc/lit-accounts_grpc.pb.go index 2a643f041..7b6e72eba 100644 --- a/litrpc/lit-accounts_grpc.pb.go +++ b/litrpc/lit-accounts_grpc.pb.go @@ -34,6 +34,14 @@ type AccountsClient interface { // litcli: `accounts update` // UpdateAccount updates an existing account in the account database. UpdateAccount(ctx context.Context, in *UpdateAccountRequest, opts ...grpc.CallOption) (*Account, error) + // litcli: `accounts update credit` + // CreditAccount increases the balance of an existing account in the account + // database. + CreditAccount(ctx context.Context, in *CreditAccountRequest, opts ...grpc.CallOption) (*CreditAccountResponse, error) + // litcli: `accounts update debit` + // DebitAccount decreases the balance of an existing account in the account + // database. + DebitAccount(ctx context.Context, in *DebitAccountRequest, opts ...grpc.CallOption) (*DebitAccountResponse, error) // litcli: `accounts list` // ListAccounts returns all accounts that are currently stored in the account // database. @@ -72,6 +80,24 @@ func (c *accountsClient) UpdateAccount(ctx context.Context, in *UpdateAccountReq return out, nil } +func (c *accountsClient) CreditAccount(ctx context.Context, in *CreditAccountRequest, opts ...grpc.CallOption) (*CreditAccountResponse, error) { + out := new(CreditAccountResponse) + err := c.cc.Invoke(ctx, "/litrpc.Accounts/CreditAccount", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *accountsClient) DebitAccount(ctx context.Context, in *DebitAccountRequest, opts ...grpc.CallOption) (*DebitAccountResponse, error) { + out := new(DebitAccountResponse) + err := c.cc.Invoke(ctx, "/litrpc.Accounts/DebitAccount", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *accountsClient) ListAccounts(ctx context.Context, in *ListAccountsRequest, opts ...grpc.CallOption) (*ListAccountsResponse, error) { out := new(ListAccountsResponse) err := c.cc.Invoke(ctx, "/litrpc.Accounts/ListAccounts", in, out, opts...) @@ -119,6 +145,14 @@ type AccountsServer interface { // litcli: `accounts update` // UpdateAccount updates an existing account in the account database. UpdateAccount(context.Context, *UpdateAccountRequest) (*Account, error) + // litcli: `accounts update credit` + // CreditAccount increases the balance of an existing account in the account + // database. + CreditAccount(context.Context, *CreditAccountRequest) (*CreditAccountResponse, error) + // litcli: `accounts update debit` + // DebitAccount decreases the balance of an existing account in the account + // database. + DebitAccount(context.Context, *DebitAccountRequest) (*DebitAccountResponse, error) // litcli: `accounts list` // ListAccounts returns all accounts that are currently stored in the account // database. @@ -142,6 +176,12 @@ func (UnimplementedAccountsServer) CreateAccount(context.Context, *CreateAccount func (UnimplementedAccountsServer) UpdateAccount(context.Context, *UpdateAccountRequest) (*Account, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateAccount not implemented") } +func (UnimplementedAccountsServer) CreditAccount(context.Context, *CreditAccountRequest) (*CreditAccountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreditAccount not implemented") +} +func (UnimplementedAccountsServer) DebitAccount(context.Context, *DebitAccountRequest) (*DebitAccountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DebitAccount not implemented") +} func (UnimplementedAccountsServer) ListAccounts(context.Context, *ListAccountsRequest) (*ListAccountsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListAccounts not implemented") } @@ -200,6 +240,42 @@ func _Accounts_UpdateAccount_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Accounts_CreditAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreditAccountRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AccountsServer).CreditAccount(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/litrpc.Accounts/CreditAccount", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AccountsServer).CreditAccount(ctx, req.(*CreditAccountRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Accounts_DebitAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DebitAccountRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AccountsServer).DebitAccount(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/litrpc.Accounts/DebitAccount", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AccountsServer).DebitAccount(ctx, req.(*DebitAccountRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Accounts_ListAccounts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ListAccountsRequest) if err := dec(in); err != nil { @@ -269,6 +345,14 @@ var Accounts_ServiceDesc = grpc.ServiceDesc{ MethodName: "UpdateAccount", Handler: _Accounts_UpdateAccount_Handler, }, + { + MethodName: "CreditAccount", + Handler: _Accounts_CreditAccount_Handler, + }, + { + MethodName: "DebitAccount", + Handler: _Accounts_DebitAccount_Handler, + }, { MethodName: "ListAccounts", Handler: _Accounts_ListAccounts_Handler, diff --git a/perms/permissions.go b/perms/permissions.go index d05318613..e2f2f8e07 100644 --- a/perms/permissions.go +++ b/perms/permissions.go @@ -28,6 +28,14 @@ var ( Entity: "account", Action: "write", }}, + "/litrpc.Accounts/CreditAccount": {{ + Entity: "account", + Action: "write", + }}, + "/litrpc.Accounts/DebitAccount": {{ + Entity: "account", + Action: "write", + }}, "/litrpc.Accounts/ListAccounts": {{ Entity: "account", Action: "read", diff --git a/proto/lit-accounts.proto b/proto/lit-accounts.proto index bc016819d..35c44fcce 100644 --- a/proto/lit-accounts.proto +++ b/proto/lit-accounts.proto @@ -25,6 +25,18 @@ service Accounts { */ rpc UpdateAccount (UpdateAccountRequest) returns (Account); + /* litcli: `accounts update credit` + CreditAccount increases the balance of an existing account in the account + database. + */ + rpc CreditAccount (CreditAccountRequest) returns (CreditAccountResponse); + + /* litcli: `accounts update debit` + DebitAccount decreases the balance of an existing account in the account + database. + */ + rpc DebitAccount (DebitAccountRequest) returns (DebitAccountResponse); + /* litcli: `accounts list` ListAccounts returns all accounts that are currently stored in the account database. @@ -148,6 +160,36 @@ message UpdateAccountRequest { string label = 4; } +message CreditAccountRequest { + // The identifier of the account to credit. + AccountIdentifier account = 1; + + /* + The amount by which the account's balance should be credited. + */ + uint64 amount = 2 [jstype = JS_STRING]; +} + +message CreditAccountResponse { + // The credited account. + Account account = 1; +} + +message DebitAccountRequest { + // The identifier of the account to debit. + AccountIdentifier account = 1; + + /* + The amount by which the account's balance should be debited. + */ + uint64 amount = 3 [jstype = JS_STRING]; +} + +message DebitAccountResponse { + // The debited account. + Account account = 1; +} + message ListAccountsRequest { } @@ -186,3 +228,13 @@ message RemoveAccountRequest { message RemoveAccountResponse { } + +message AccountIdentifier { + oneof identifier { + // The ID of the account. + string id = 1; + + // The label of the account. + string label = 2; + } +} \ No newline at end of file From b2ec5974df7e62a2cd626e56283d514b8cbffc9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Tigerstr=C3=B6m?= Date: Tue, 11 Feb 2025 19:14:36 +0100 Subject: [PATCH 3/6] accounts: implement CreditAccount & DebitAccount This commit implements the `CreditAccount` and `DebitAccount` endpoints for the accounts subsystem. --- accounts/checkers_test.go | 12 ++++++ accounts/interface.go | 10 +++++ accounts/rpcserver.go | 77 +++++++++++++++++++++++++++++++++++++++ accounts/service.go | 50 +++++++++++++++++++++++++ 4 files changed, 149 insertions(+) diff --git a/accounts/checkers_test.go b/accounts/checkers_test.go index 3f1f28d76..0e6ef37ab 100644 --- a/accounts/checkers_test.go +++ b/accounts/checkers_test.go @@ -63,6 +63,18 @@ type mockService struct { *requestValuesStore } +func (m *mockService) CreditAccount(_ context.Context, _ AccountID, + _ lnwire.MilliSatoshi) (*OffChainBalanceAccount, error) { + + return nil, nil +} + +func (m *mockService) DebitAccount(_ context.Context, _ AccountID, + _ lnwire.MilliSatoshi) (*OffChainBalanceAccount, error) { + + return nil, nil +} + func newMockService() *mockService { return &mockService{ acctBalanceMsat: 0, diff --git a/accounts/interface.go b/accounts/interface.go index ef0e7d3ec..760732f11 100644 --- a/accounts/interface.go +++ b/accounts/interface.go @@ -331,6 +331,16 @@ type Service interface { PaymentErrored(ctx context.Context, id AccountID, hash lntypes.Hash) error + // CreditAccount increases the balance of an existing account in the + // database. + CreditAccount(ctx context.Context, accountID AccountID, + amount lnwire.MilliSatoshi) (*OffChainBalanceAccount, error) + + // DebitAccount decreases the balance of an existing account in the + // database. + DebitAccount(ctx context.Context, accountID AccountID, + amount lnwire.MilliSatoshi) (*OffChainBalanceAccount, error) + RequestValuesStore } diff --git a/accounts/rpcserver.go b/accounts/rpcserver.go index 5795696cc..ce1291c17 100644 --- a/accounts/rpcserver.go +++ b/accounts/rpcserver.go @@ -130,6 +130,83 @@ func (s *RPCServer) UpdateAccount(ctx context.Context, return marshalAccount(account), nil } +// CreditAccount increases the balance of an existing account in the account +// database, by the given amount. +func (s *RPCServer) CreditAccount(ctx context.Context, + req *litrpc.CreditAccountRequest) (*litrpc.CreditAccountResponse, + error) { + + if req.GetAccount() == nil { + return nil, fmt.Errorf("account param must be specified") + } + + var id, label string + + switch idType := req.Account.Identifier.(type) { + case *litrpc.AccountIdentifier_Id: + id = idType.Id + case *litrpc.AccountIdentifier_Label: + label = idType.Label + } + + log.Infof("[creditaccount] id=%s, label=%v, amount=%d", id, label, + req.Amount) + + amount := lnwire.MilliSatoshi(req.Amount * 1000) + + accountID, err := s.findAccount(ctx, id, label) + if err != nil { + return nil, err + } + + account, err := s.service.CreditAccount(ctx, accountID, amount) + if err != nil { + return nil, err + } + + return &litrpc.CreditAccountResponse{ + Account: marshalAccount(account), + }, nil +} + +// DebitAccount decreases the balance of an existing account in the account +// database, by the given amount. +func (s *RPCServer) DebitAccount(ctx context.Context, + req *litrpc.DebitAccountRequest) (*litrpc.DebitAccountResponse, error) { + + if req.GetAccount() == nil { + return nil, fmt.Errorf("account param must be specified") + } + + var id, label string + + switch idType := req.Account.Identifier.(type) { + case *litrpc.AccountIdentifier_Id: + id = idType.Id + case *litrpc.AccountIdentifier_Label: + label = idType.Label + } + + log.Infof("[debitaccount] id=%s, label=%v, amount=%d", id, label, + req.Amount) + + amount := lnwire.MilliSatoshi(req.Amount * 1000) + + accountID, err := s.findAccount(ctx, id, label) + if err != nil { + return nil, err + } + + account, err := s.service.DebitAccount(ctx, accountID, amount) + if err != nil { + return nil, err + } + + return &litrpc.DebitAccountResponse{ + Account: marshalAccount(account), + }, nil +} + // ListAccounts returns all accounts that are currently stored in the account // database. func (s *RPCServer) ListAccounts(ctx context.Context, diff --git a/accounts/service.go b/accounts/service.go index 098c4a8fa..102b9ea84 100644 --- a/accounts/service.go +++ b/accounts/service.go @@ -345,6 +345,56 @@ func (s *InterceptorService) UpdateAccount(ctx context.Context, return s.store.Account(ctx, accountID) } +// CreditAccount increases the balance of an existing account in the database. +func (s *InterceptorService) CreditAccount(ctx context.Context, + accountID AccountID, + amount lnwire.MilliSatoshi) (*OffChainBalanceAccount, error) { + + s.Lock() + defer s.Unlock() + + // As this function updates account balances, we require that the + // service is running before we execute it. + if !s.isRunningUnsafe() { + // This case can only happen if the service is disabled while + // we're processing a request. + return nil, ErrAccountServiceDisabled + } + + // Credit the account in the db. + err := s.store.CreditAccount(ctx, accountID, amount) + if err != nil { + return nil, fmt.Errorf("unable to credit account: %w", err) + } + + return s.store.Account(ctx, accountID) +} + +// DebitAccount decreases the balance of an existing account in the database. +func (s *InterceptorService) DebitAccount(ctx context.Context, + accountID AccountID, + amount lnwire.MilliSatoshi) (*OffChainBalanceAccount, error) { + + s.Lock() + defer s.Unlock() + + // As this function updates account balances, we require that the + // service is running before we execute it. + if !s.isRunningUnsafe() { + // This case can only happen if the service is disabled while + // we're processing a request. + return nil, ErrAccountServiceDisabled + } + + // Debit the account in the db. + err := s.store.DebitAccount(ctx, accountID, amount) + if err != nil { + return nil, fmt.Errorf("unable to debit account: %w", err) + } + + return s.store.Account(ctx, accountID) +} + // Account retrieves an account from the bolt DB and un-marshals it. If the // account cannot be found, then ErrAccNotFound is returned. func (s *InterceptorService) Account(ctx context.Context, From 5a020191612cabade98c5587b12b663a7a2ae6d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Tigerstr=C3=B6m?= Date: Wed, 5 Feb 2025 18:05:24 +0100 Subject: [PATCH 4/6] litcli: add accounts `credit` & `debit` commands This commit implements the `credit` and `debit` commands in `litcli`, allowing users to increase or decrease the balance of an existing off-chain account, respectively. --- cmd/litcli/accounts.go | 157 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) diff --git a/cmd/litcli/accounts.go b/cmd/litcli/accounts.go index 3e5468af3..d444e0b63 100644 --- a/cmd/litcli/accounts.go +++ b/cmd/litcli/accounts.go @@ -2,6 +2,7 @@ package main import ( "encoding/hex" + "errors" "fmt" "os" "strconv" @@ -173,6 +174,10 @@ var updateAccountCommand = cli.Command{ }, }, Action: updateAccount, + Subcommands: []cli.Command{ + creditCommand, + debitCommand, + }, } func updateAccount(cli *cli.Context) error { @@ -232,6 +237,125 @@ func updateAccount(cli *cli.Context) error { return nil } +var creditCommand = cli.Command{ + Name: "credit", + ShortName: "c", + Usage: "Increase an account's balance by the given amount.", + ArgsUsage: "[id | label] amount", + Description: "Increases an existing off-chain account's balance by " + + "the given amount.", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: idName, + Usage: "The ID of the account to credit.", + }, + cli.StringFlag{ + Name: labelName, + Usage: "(optional) The unique label of the account.", + }, + cli.Uint64Flag{ + Name: "amount", + Usage: "The amount to credit the account.", + }, + }, + Action: creditBalance, +} + +func creditBalance(cli *cli.Context) error { + return updateBalance(cli, true) +} + +var debitCommand = cli.Command{ + Name: "debit", + ShortName: "d", + Usage: "Decrease an account's balance by the given amount.", + ArgsUsage: "[id | label] amount", + Description: "Decreases an existing off-chain account's balance by " + + "the given amount.", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: idName, + Usage: "The ID of the account to debit.", + }, + cli.StringFlag{ + Name: labelName, + Usage: "(optional) The unique label of the account.", + }, + cli.Uint64Flag{ + Name: "amount", + Usage: "The amount to debit the account.", + }, + }, + Action: debitBalance, +} + +func debitBalance(cli *cli.Context) error { + return updateBalance(cli, false) +} + +func updateBalance(cli *cli.Context, add bool) error { + ctx := getContext() + clientConn, cleanup, err := connectClient(cli, false) + if err != nil { + return err + } + defer cleanup() + client := litrpc.NewAccountsClient(clientConn) + + account, args, err := parseAccountIdentifier(cli) + if err != nil { + return err + } + + if (!cli.IsSet("amount") && len(args) != 1) || + (cli.IsSet("amount") && len(args) != 0) { + + return errors.New("invalid number of arguments") + } + + var amount uint64 + switch { + case cli.IsSet("amount"): + amount = cli.Uint64("amount") + case args.Present(): + amount, err = strconv.ParseUint(args.First(), 10, 64) + if err != nil { + return fmt.Errorf("unable to decode amount %v", err) + } + args = args.Tail() + default: + return errors.New("must set a value for amount") + } + + if add { + req := &litrpc.CreditAccountRequest{ + Account: account, + Amount: amount, + } + + resp, err := client.CreditAccount(ctx, req) + if err != nil { + return err + } + + printRespJSON(resp) + } else { + req := &litrpc.DebitAccountRequest{ + Account: account, + Amount: amount, + } + + resp, err := client.DebitAccount(ctx, req) + if err != nil { + return err + } + + printRespJSON(resp) + } + + return nil +} + var listAccountsCommand = cli.Command{ Name: "list", ShortName: "l", @@ -348,6 +472,39 @@ func removeAccount(cli *cli.Context) error { return err } +// parseAccountIdentifier parses either the id or label from the command line, +// and returns the account identifier. +func parseAccountIdentifier(ctx *cli.Context) ( + *litrpc.AccountIdentifier, cli.Args, error) { + + id, label, args, err := parseIDOrLabel(ctx) + if err != nil { + return nil, nil, err + } + + if id == "" && label == "" { + return nil, nil, fmt.Errorf("id argument missing") + } + + if id != "" { + identifier := &litrpc.AccountIdentifier{ + Identifier: &litrpc.AccountIdentifier_Id{ + Id: id, + }, + } + + return identifier, args, nil + } else { + identifier := &litrpc.AccountIdentifier{ + Identifier: &litrpc.AccountIdentifier_Label{ + Label: label, + }, + } + + return identifier, args, nil + } +} + // parseIDOrLabel parses either the id or label from the command line. func parseIDOrLabel(ctx *cli.Context) (string, string, cli.Args, error) { var ( From 5b6edb4f0cb186f24629137d704926d68db87eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Tigerstr=C3=B6m?= Date: Thu, 6 Feb 2025 01:40:45 +0100 Subject: [PATCH 5/6] docs: add release notes for v0.14.2-alpha --- docs/release-notes/release-notes-0.14.2.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/release-notes-0.14.2.md b/docs/release-notes/release-notes-0.14.2.md index b2353a0a5..dde9396af 100644 --- a/docs/release-notes/release-notes-0.14.2.md +++ b/docs/release-notes/release-notes-0.14.2.md @@ -11,7 +11,6 @@ - [Faraday](#faraday) - [Taproot Assets](#taproot-assets) - [Contributors](#contributors-alphabetical-order) - ## Lightning Terminal ### Bug Fixes @@ -28,6 +27,11 @@ ## RPC Updates +* [Add account credit and debit + commands](https://github.com/lightninglabs/lightning-terminal/pull/974) that + allow increasing or decreasing the balance of an off-chain account by a + specified amount. + ## Integrated Binary Updates ### LND @@ -42,4 +46,5 @@ # Contributors (Alphabetical Order) -* Elle Mouton \ No newline at end of file +* Elle Mouton +* Viktor From 0c520cef183c8bf852ee80ab629720b078062411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Tigerstr=C3=B6m?= Date: Tue, 11 Feb 2025 20:57:46 +0100 Subject: [PATCH 6/6] multi: add `accounts u --new_balance` deprecation This commit adds a deprecation notice regarding the `accounts update --new_balance` flag. This flag will be removed in the next major release of lit. --- cmd/litcli/accounts.go | 7 +- docs/release-notes/release-notes-0.14.2.md | 7 + litrpc/lit-accounts.pb.go | 177 +++++++++++---------- litrpc/lit-accounts.proto | 8 +- litrpc/lit-accounts.swagger.json | 2 +- proto/lit-accounts.proto | 8 +- 6 files changed, 115 insertions(+), 94 deletions(-) diff --git a/cmd/litcli/accounts.go b/cmd/litcli/accounts.go index d444e0b63..7816879d2 100644 --- a/cmd/litcli/accounts.go +++ b/cmd/litcli/accounts.go @@ -160,9 +160,10 @@ var updateAccountCommand = cli.Command{ }, cli.Int64Flag{ Name: "new_balance", - Usage: "The new balance of the account; -1 means do " + - "not update the balance.", - Value: -1, + Usage: "(deprecated) The new balance of the account; " + + "-1 means do not update the balance.", + Value: -1, + Hidden: true, }, cli.Int64Flag{ Name: "new_expiration_date", diff --git a/docs/release-notes/release-notes-0.14.2.md b/docs/release-notes/release-notes-0.14.2.md index dde9396af..53d01b8ac 100644 --- a/docs/release-notes/release-notes-0.14.2.md +++ b/docs/release-notes/release-notes-0.14.2.md @@ -32,6 +32,13 @@ allow increasing or decreasing the balance of an off-chain account by a specified amount. + +* The [`accounts update` `--new_balance` flag has been + deprecated](https://github.com/lightninglabs/lightning-terminal/pull/974). + Use the `accounts update credit` and `accounts update debit` commands + instead, to update an account's balance. The flag will no longer be + supported in Lightning Terminal `v0.16.0-alpha`. + ## Integrated Binary Updates ### LND diff --git a/litrpc/lit-accounts.pb.go b/litrpc/lit-accounts.pb.go index ad8c20304..84567e40a 100644 --- a/litrpc/lit-accounts.pb.go +++ b/litrpc/lit-accounts.pb.go @@ -382,7 +382,11 @@ type UpdateAccountRequest struct { // The ID of the account to update. Either the ID or the label must be set. Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - // The new account balance to set. Set to -1 to not update the balance. + // Deprecated, use the `litcli update credit` or `litcli update debit` + // commands instead. The new account balance to set. Set to -1 to not + // update the balance. + // + // Deprecated: Marked as deprecated in lit-accounts.proto. AccountBalance int64 `protobuf:"varint,2,opt,name=account_balance,json=accountBalance,proto3" json:"account_balance,omitempty"` // The new account expiry to set. Set to -1 to not update the expiry. Set to 0 // to never expire. @@ -431,6 +435,7 @@ func (x *UpdateAccountRequest) GetId() string { return "" } +// Deprecated: Marked as deprecated in lit-accounts.proto. func (x *UpdateAccountRequest) GetAccountBalance() int64 { if x != nil { return x.AccountBalance @@ -1033,93 +1038,93 @@ var file_lit_accounts_proto_rawDesc = []byte{ 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x66, 0x75, 0x6c, 0x6c, 0x5f, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x66, 0x75, 0x6c, 0x6c, 0x41, - 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x8e, 0x01, 0x0a, 0x14, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x92, 0x01, 0x0a, 0x14, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x27, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2b, 0x0a, 0x0f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x65, 0x78, 0x70, 0x69, 0x72, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x0e, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x61, 0x74, 0x65, - 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x22, 0x63, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x64, 0x69, 0x74, - 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x33, - 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x19, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x42, 0x0a, 0x15, 0x43, - 0x72, 0x65, 0x64, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, - 0x62, 0x0a, 0x13, 0x44, 0x65, 0x62, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x33, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, - 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, - 0x65, 0x72, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61, - 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x61, 0x6d, 0x6f, - 0x75, 0x6e, 0x74, 0x22, 0x41, 0x0a, 0x14, 0x44, 0x65, 0x62, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x07, 0x61, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6c, - 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x15, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x43, 0x0a, - 0x14, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2b, 0x0a, 0x08, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, - 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x08, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x73, 0x22, 0x3a, 0x0a, 0x12, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x6e, 0x66, - 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, - 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x22, 0x3c, - 0x0a, 0x14, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x22, 0x17, 0x0a, 0x15, - 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x4b, 0x0a, 0x11, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x05, - 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x05, 0x6c, - 0x61, 0x62, 0x65, 0x6c, 0x42, 0x0c, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, - 0x65, 0x72, 0x32, 0x86, 0x04, 0x0a, 0x08, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x12, - 0x4c, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x12, 0x1c, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, - 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, - 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1c, - 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x6c, - 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x4c, 0x0a, - 0x0d, 0x43, 0x72, 0x65, 0x64, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1c, - 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x64, 0x69, 0x74, 0x41, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x6c, - 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x64, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x0c, 0x44, - 0x65, 0x62, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1b, 0x2e, 0x6c, 0x69, - 0x74, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x62, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, - 0x63, 0x2e, 0x44, 0x65, 0x62, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x12, 0x1b, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, - 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, - 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x3a, 0x0a, 0x0b, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, - 0x12, 0x1a, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0f, 0x2e, 0x6c, - 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x4c, 0x0a, - 0x0d, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1c, - 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x41, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x6c, - 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x41, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x34, 0x5a, 0x32, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, - 0x69, 0x6e, 0x67, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, - 0x67, 0x2d, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x2f, 0x6c, 0x69, 0x74, 0x72, 0x70, - 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0e, 0x61, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x65, + 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x61, 0x74, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x44, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x22, 0x63, 0x0a, 0x14, 0x43, 0x72, + 0x65, 0x64, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x33, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x07, + 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, + 0x42, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x64, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6c, 0x69, 0x74, 0x72, + 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x22, 0x62, 0x0a, 0x13, 0x44, 0x65, 0x62, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x33, 0x0a, 0x07, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6c, 0x69, + 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, + 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x41, 0x0a, 0x14, 0x44, 0x65, 0x62, 0x69, 0x74, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x29, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0f, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x15, 0x0a, 0x13, 0x4c, 0x69, + 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x22, 0x43, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2b, 0x0a, 0x08, 0x61, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6c, 0x69, + 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x08, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x22, 0x3a, 0x0a, 0x12, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, + 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x61, 0x62, + 0x65, 0x6c, 0x22, 0x3c, 0x0a, 0x14, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x41, 0x63, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x61, + 0x62, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, + 0x22, 0x17, 0x0a, 0x15, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x4b, 0x0a, 0x11, 0x41, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x10, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x16, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, + 0x00, 0x52, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x42, 0x0c, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x32, 0x86, 0x04, 0x0a, 0x08, 0x41, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x73, 0x12, 0x4c, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1c, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x3e, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x12, 0x1c, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x0f, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x12, 0x4c, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x64, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x12, 0x1c, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x64, + 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x1d, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x64, 0x69, 0x74, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x49, 0x0a, 0x0c, 0x44, 0x65, 0x62, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, + 0x1b, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x62, 0x69, 0x74, 0x41, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x6c, + 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x62, 0x69, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x0c, 0x4c, 0x69, + 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x12, 0x1b, 0x2e, 0x6c, 0x69, 0x74, + 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, + 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x0b, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x0f, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x12, 0x4c, 0x0a, 0x0d, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x12, 0x1c, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x6d, 0x6f, + 0x76, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x1d, 0x2e, 0x6c, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, + 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, + 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, 0x67, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x6c, 0x69, 0x67, 0x68, + 0x74, 0x6e, 0x69, 0x6e, 0x67, 0x2d, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x2f, 0x6c, + 0x69, 0x74, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/litrpc/lit-accounts.proto b/litrpc/lit-accounts.proto index ba616cdff..5827e08a2 100644 --- a/litrpc/lit-accounts.proto +++ b/litrpc/lit-accounts.proto @@ -144,8 +144,12 @@ message UpdateAccountRequest { // The ID of the account to update. Either the ID or the label must be set. string id = 1; - // The new account balance to set. Set to -1 to not update the balance. - int64 account_balance = 2; + /* + Deprecated, use the `litcli update credit` or `litcli update debit` + commands instead. The new account balance to set. Set to -1 to not + update the balance. + */ + int64 account_balance = 2 [deprecated = true]; /* The new account expiry to set. Set to -1 to not update the expiry. Set to 0 diff --git a/litrpc/lit-accounts.swagger.json b/litrpc/lit-accounts.swagger.json index 65cf5b51d..f93ae42fa 100644 --- a/litrpc/lit-accounts.swagger.json +++ b/litrpc/lit-accounts.swagger.json @@ -278,7 +278,7 @@ "account_balance": { "type": "string", "format": "int64", - "description": "The new account balance to set. Set to -1 to not update the balance." + "description": "Deprecated, use the `litcli update credit` or `litcli update debit`\ncommands instead. The new account balance to set. Set to -1 to not\nupdate the balance." }, "expiration_date": { "type": "string", diff --git a/proto/lit-accounts.proto b/proto/lit-accounts.proto index 35c44fcce..dbf721081 100644 --- a/proto/lit-accounts.proto +++ b/proto/lit-accounts.proto @@ -144,8 +144,12 @@ message UpdateAccountRequest { // The ID of the account to update. Either the ID or the label must be set. string id = 1; - // The new account balance to set. Set to -1 to not update the balance. - int64 account_balance = 2 [jstype = JS_STRING]; + /* + Deprecated, use the `litcli update credit` or `litcli update debit` + commands instead. The new account balance to set. Set to -1 to not + update the balance. + */ + int64 account_balance = 2 [deprecated = true, jstype = JS_STRING]; /* The new account expiry to set. Set to -1 to not update the expiry. Set to 0