mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
litrpc: add lit-autopilot protos
In this commit we add all the proto methods and messages that we will need for the initial autopilot implementation.
This commit is contained in:
parent
edf195ebd9
commit
69516ec675
16 changed files with 5978 additions and 93 deletions
3
.github/workflows/main.yml
vendored
3
.github/workflows/main.yml
vendored
|
|
@ -114,6 +114,9 @@ jobs:
|
|||
working-directory: ./app
|
||||
run: yarn
|
||||
|
||||
- name: run check
|
||||
run: make rpc-js-compile && make protos-check
|
||||
|
||||
- name: compile rpc for golang
|
||||
run: make rpc
|
||||
|
||||
|
|
|
|||
4
Makefile
4
Makefile
|
|
@ -228,6 +228,10 @@ protos-check: protos
|
|||
@$(call print, "Verifying compiled protos.")
|
||||
if test -n "$$(git describe --dirty | grep dirty)"; then echo "Protos not properly formatted or not compiled with correct version"; git status; git diff; exit 1; fi
|
||||
|
||||
rpc-js-compile:
|
||||
@$(call print, "Compiling JSON/WASM stubs.")
|
||||
GOOS=js GOARCH=wasm $(GOBUILD) $(PKG)/litrpc
|
||||
|
||||
clean:
|
||||
@$(call print, "Cleaning source.$(NC)")
|
||||
$(RM) ./litcli-debug
|
||||
|
|
|
|||
338
app/src/types/generated/lit-sessions_pb.d.ts
generated
vendored
338
app/src/types/generated/lit-sessions_pb.d.ts
generated
vendored
|
|
@ -96,6 +96,11 @@ export namespace AddSessionResponse {
|
|||
}
|
||||
|
||||
export class Session extends jspb.Message {
|
||||
getId(): Uint8Array | string;
|
||||
getId_asU8(): Uint8Array;
|
||||
getId_asB64(): string;
|
||||
setId(value: Uint8Array | string): void;
|
||||
|
||||
getLabel(): string;
|
||||
setLabel(value: string): void;
|
||||
|
||||
|
|
@ -143,6 +148,8 @@ export class Session extends jspb.Message {
|
|||
getAccountId(): string;
|
||||
setAccountId(value: string): void;
|
||||
|
||||
getAutopilotFeatureInfoMap(): jspb.Map<string, RulesMap>;
|
||||
clearAutopilotFeatureInfoMap(): void;
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): Session.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: Session): Session.AsObject;
|
||||
|
|
@ -155,6 +162,7 @@ export class Session extends jspb.Message {
|
|||
|
||||
export namespace Session {
|
||||
export type AsObject = {
|
||||
id: Uint8Array | string,
|
||||
label: string,
|
||||
sessionState: SessionStateMap[keyof SessionStateMap],
|
||||
sessionType: SessionTypeMap[keyof SessionTypeMap],
|
||||
|
|
@ -168,6 +176,7 @@ export namespace Session {
|
|||
createdAt: string,
|
||||
macaroonRecipe?: MacaroonRecipe.AsObject,
|
||||
accountId: string,
|
||||
autopilotFeatureInfoMap: Array<[string, RulesMap.AsObject]>,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -275,11 +284,340 @@ export namespace RevokeSessionResponse {
|
|||
}
|
||||
}
|
||||
|
||||
export class RulesMap extends jspb.Message {
|
||||
getRulesMap(): jspb.Map<string, RuleValue>;
|
||||
clearRulesMap(): void;
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): RulesMap.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: RulesMap): RulesMap.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: RulesMap, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): RulesMap;
|
||||
static deserializeBinaryFromReader(message: RulesMap, reader: jspb.BinaryReader): RulesMap;
|
||||
}
|
||||
|
||||
export namespace RulesMap {
|
||||
export type AsObject = {
|
||||
rulesMap: Array<[string, RuleValue.AsObject]>,
|
||||
}
|
||||
}
|
||||
|
||||
export class RuleValue extends jspb.Message {
|
||||
hasRateLimit(): boolean;
|
||||
clearRateLimit(): void;
|
||||
getRateLimit(): RateLimit | undefined;
|
||||
setRateLimit(value?: RateLimit): void;
|
||||
|
||||
hasChanPolicyBounds(): boolean;
|
||||
clearChanPolicyBounds(): void;
|
||||
getChanPolicyBounds(): ChannelPolicyBounds | undefined;
|
||||
setChanPolicyBounds(value?: ChannelPolicyBounds): void;
|
||||
|
||||
hasHistoryLimit(): boolean;
|
||||
clearHistoryLimit(): void;
|
||||
getHistoryLimit(): HistoryLimit | undefined;
|
||||
setHistoryLimit(value?: HistoryLimit): void;
|
||||
|
||||
hasOffChainBudget(): boolean;
|
||||
clearOffChainBudget(): void;
|
||||
getOffChainBudget(): OffChainBudget | undefined;
|
||||
setOffChainBudget(value?: OffChainBudget): void;
|
||||
|
||||
hasOnChainBudget(): boolean;
|
||||
clearOnChainBudget(): void;
|
||||
getOnChainBudget(): OnChainBudget | undefined;
|
||||
setOnChainBudget(value?: OnChainBudget): void;
|
||||
|
||||
hasSendToSelf(): boolean;
|
||||
clearSendToSelf(): void;
|
||||
getSendToSelf(): SendToSelf | undefined;
|
||||
setSendToSelf(value?: SendToSelf): void;
|
||||
|
||||
hasChannelRestrict(): boolean;
|
||||
clearChannelRestrict(): void;
|
||||
getChannelRestrict(): ChannelRestrict | undefined;
|
||||
setChannelRestrict(value?: ChannelRestrict): void;
|
||||
|
||||
hasPeerRestrict(): boolean;
|
||||
clearPeerRestrict(): void;
|
||||
getPeerRestrict(): PeerRestrict | undefined;
|
||||
setPeerRestrict(value?: PeerRestrict): void;
|
||||
|
||||
getValueCase(): RuleValue.ValueCase;
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): RuleValue.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: RuleValue): RuleValue.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: RuleValue, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): RuleValue;
|
||||
static deserializeBinaryFromReader(message: RuleValue, reader: jspb.BinaryReader): RuleValue;
|
||||
}
|
||||
|
||||
export namespace RuleValue {
|
||||
export type AsObject = {
|
||||
rateLimit?: RateLimit.AsObject,
|
||||
chanPolicyBounds?: ChannelPolicyBounds.AsObject,
|
||||
historyLimit?: HistoryLimit.AsObject,
|
||||
offChainBudget?: OffChainBudget.AsObject,
|
||||
onChainBudget?: OnChainBudget.AsObject,
|
||||
sendToSelf?: SendToSelf.AsObject,
|
||||
channelRestrict?: ChannelRestrict.AsObject,
|
||||
peerRestrict?: PeerRestrict.AsObject,
|
||||
}
|
||||
|
||||
export enum ValueCase {
|
||||
VALUE_NOT_SET = 0,
|
||||
RATE_LIMIT = 1,
|
||||
CHAN_POLICY_BOUNDS = 2,
|
||||
HISTORY_LIMIT = 3,
|
||||
OFF_CHAIN_BUDGET = 4,
|
||||
ON_CHAIN_BUDGET = 5,
|
||||
SEND_TO_SELF = 6,
|
||||
CHANNEL_RESTRICT = 7,
|
||||
PEER_RESTRICT = 8,
|
||||
}
|
||||
}
|
||||
|
||||
export class RateLimit extends jspb.Message {
|
||||
hasReadLimit(): boolean;
|
||||
clearReadLimit(): void;
|
||||
getReadLimit(): Rate | undefined;
|
||||
setReadLimit(value?: Rate): void;
|
||||
|
||||
hasWriteLimit(): boolean;
|
||||
clearWriteLimit(): void;
|
||||
getWriteLimit(): Rate | undefined;
|
||||
setWriteLimit(value?: Rate): void;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): RateLimit.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: RateLimit): RateLimit.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: RateLimit, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): RateLimit;
|
||||
static deserializeBinaryFromReader(message: RateLimit, reader: jspb.BinaryReader): RateLimit;
|
||||
}
|
||||
|
||||
export namespace RateLimit {
|
||||
export type AsObject = {
|
||||
readLimit?: Rate.AsObject,
|
||||
writeLimit?: Rate.AsObject,
|
||||
}
|
||||
}
|
||||
|
||||
export class Rate extends jspb.Message {
|
||||
getIterations(): number;
|
||||
setIterations(value: number): void;
|
||||
|
||||
getNumHours(): number;
|
||||
setNumHours(value: number): void;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): Rate.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: Rate): Rate.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: Rate, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): Rate;
|
||||
static deserializeBinaryFromReader(message: Rate, reader: jspb.BinaryReader): Rate;
|
||||
}
|
||||
|
||||
export namespace Rate {
|
||||
export type AsObject = {
|
||||
iterations: number,
|
||||
numHours: number,
|
||||
}
|
||||
}
|
||||
|
||||
export class HistoryLimit extends jspb.Message {
|
||||
getStartTime(): string;
|
||||
setStartTime(value: string): void;
|
||||
|
||||
getDuration(): string;
|
||||
setDuration(value: string): void;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): HistoryLimit.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: HistoryLimit): HistoryLimit.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: HistoryLimit, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): HistoryLimit;
|
||||
static deserializeBinaryFromReader(message: HistoryLimit, reader: jspb.BinaryReader): HistoryLimit;
|
||||
}
|
||||
|
||||
export namespace HistoryLimit {
|
||||
export type AsObject = {
|
||||
startTime: string,
|
||||
duration: string,
|
||||
}
|
||||
}
|
||||
|
||||
export class ChannelPolicyBounds extends jspb.Message {
|
||||
getMinBaseMsat(): string;
|
||||
setMinBaseMsat(value: string): void;
|
||||
|
||||
getMaxBaseMsat(): string;
|
||||
setMaxBaseMsat(value: string): void;
|
||||
|
||||
getMinRatePpm(): number;
|
||||
setMinRatePpm(value: number): void;
|
||||
|
||||
getMaxRatePpm(): number;
|
||||
setMaxRatePpm(value: number): void;
|
||||
|
||||
getMinCltvDelta(): number;
|
||||
setMinCltvDelta(value: number): void;
|
||||
|
||||
getMaxCltvDelta(): number;
|
||||
setMaxCltvDelta(value: number): void;
|
||||
|
||||
getMinHtlcMsat(): string;
|
||||
setMinHtlcMsat(value: string): void;
|
||||
|
||||
getMaxHtlcMsat(): string;
|
||||
setMaxHtlcMsat(value: string): void;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): ChannelPolicyBounds.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: ChannelPolicyBounds): ChannelPolicyBounds.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: ChannelPolicyBounds, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): ChannelPolicyBounds;
|
||||
static deserializeBinaryFromReader(message: ChannelPolicyBounds, reader: jspb.BinaryReader): ChannelPolicyBounds;
|
||||
}
|
||||
|
||||
export namespace ChannelPolicyBounds {
|
||||
export type AsObject = {
|
||||
minBaseMsat: string,
|
||||
maxBaseMsat: string,
|
||||
minRatePpm: number,
|
||||
maxRatePpm: number,
|
||||
minCltvDelta: number,
|
||||
maxCltvDelta: number,
|
||||
minHtlcMsat: string,
|
||||
maxHtlcMsat: string,
|
||||
}
|
||||
}
|
||||
|
||||
export class OffChainBudget extends jspb.Message {
|
||||
getMaxAmtMsat(): string;
|
||||
setMaxAmtMsat(value: string): void;
|
||||
|
||||
getMaxFeesMsat(): string;
|
||||
setMaxFeesMsat(value: string): void;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): OffChainBudget.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: OffChainBudget): OffChainBudget.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: OffChainBudget, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): OffChainBudget;
|
||||
static deserializeBinaryFromReader(message: OffChainBudget, reader: jspb.BinaryReader): OffChainBudget;
|
||||
}
|
||||
|
||||
export namespace OffChainBudget {
|
||||
export type AsObject = {
|
||||
maxAmtMsat: string,
|
||||
maxFeesMsat: string,
|
||||
}
|
||||
}
|
||||
|
||||
export class OnChainBudget extends jspb.Message {
|
||||
getAbsoluteAmtSats(): string;
|
||||
setAbsoluteAmtSats(value: string): void;
|
||||
|
||||
getMaxSatPerVByte(): string;
|
||||
setMaxSatPerVByte(value: string): void;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): OnChainBudget.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: OnChainBudget): OnChainBudget.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: OnChainBudget, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): OnChainBudget;
|
||||
static deserializeBinaryFromReader(message: OnChainBudget, reader: jspb.BinaryReader): OnChainBudget;
|
||||
}
|
||||
|
||||
export namespace OnChainBudget {
|
||||
export type AsObject = {
|
||||
absoluteAmtSats: string,
|
||||
maxSatPerVByte: string,
|
||||
}
|
||||
}
|
||||
|
||||
export class SendToSelf extends jspb.Message {
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): SendToSelf.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: SendToSelf): SendToSelf.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: SendToSelf, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): SendToSelf;
|
||||
static deserializeBinaryFromReader(message: SendToSelf, reader: jspb.BinaryReader): SendToSelf;
|
||||
}
|
||||
|
||||
export namespace SendToSelf {
|
||||
export type AsObject = {
|
||||
}
|
||||
}
|
||||
|
||||
export class ChannelRestrict extends jspb.Message {
|
||||
clearChannelIdsList(): void;
|
||||
getChannelIdsList(): Array<string>;
|
||||
setChannelIdsList(value: Array<string>): void;
|
||||
addChannelIds(value: string, index?: number): string;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): ChannelRestrict.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: ChannelRestrict): ChannelRestrict.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: ChannelRestrict, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): ChannelRestrict;
|
||||
static deserializeBinaryFromReader(message: ChannelRestrict, reader: jspb.BinaryReader): ChannelRestrict;
|
||||
}
|
||||
|
||||
export namespace ChannelRestrict {
|
||||
export type AsObject = {
|
||||
channelIdsList: Array<string>,
|
||||
}
|
||||
}
|
||||
|
||||
export class PeerRestrict extends jspb.Message {
|
||||
clearPeerIdsList(): void;
|
||||
getPeerIdsList(): Array<string>;
|
||||
setPeerIdsList(value: Array<string>): void;
|
||||
addPeerIds(value: string, index?: number): string;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): PeerRestrict.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: PeerRestrict): PeerRestrict.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: PeerRestrict, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): PeerRestrict;
|
||||
static deserializeBinaryFromReader(message: PeerRestrict, reader: jspb.BinaryReader): PeerRestrict;
|
||||
}
|
||||
|
||||
export namespace PeerRestrict {
|
||||
export type AsObject = {
|
||||
peerIdsList: Array<string>,
|
||||
}
|
||||
}
|
||||
|
||||
export interface SessionTypeMap {
|
||||
TYPE_MACAROON_READONLY: 0;
|
||||
TYPE_MACAROON_ADMIN: 1;
|
||||
TYPE_MACAROON_CUSTOM: 2;
|
||||
TYPE_UI_PASSWORD: 3;
|
||||
TYPE_AUTOPILOT: 4;
|
||||
TYPE_MACAROON_ACCOUNT: 5;
|
||||
}
|
||||
|
||||
|
|
|
|||
2389
app/src/types/generated/lit-sessions_pb.js
generated
2389
app/src/types/generated/lit-sessions_pb.js
generated
File diff suppressed because it is too large
Load diff
|
|
@ -887,6 +887,7 @@ export const poolRegisterSidecar: POOL.SidecarTicket.AsObject = {
|
|||
export const litListSessions: LIT.ListSessionsResponse.AsObject = {
|
||||
sessionsList: [
|
||||
{
|
||||
id: '',
|
||||
devServer: true,
|
||||
expiryTimestampSeconds: '253370782800',
|
||||
label: 'Default Session',
|
||||
|
|
@ -899,8 +900,73 @@ export const litListSessions: LIT.ListSessionsResponse.AsObject = {
|
|||
sessionType: LIT.SessionType.TYPE_UI_PASSWORD,
|
||||
createdAt: '253300000000',
|
||||
accountId: '',
|
||||
autopilotFeatureInfoMap: [
|
||||
[
|
||||
'SampleFeature',
|
||||
{
|
||||
rulesMap: [
|
||||
[
|
||||
'channel-policy-bounds',
|
||||
{
|
||||
chanPolicyBounds: {
|
||||
minBaseMsat: '0',
|
||||
maxBaseMsat: '10',
|
||||
minRatePpm: 1,
|
||||
maxRatePpm: 10,
|
||||
minCltvDelta: 18,
|
||||
maxCltvDelta: 18,
|
||||
minHtlcMsat: '0',
|
||||
maxHtlcMsat: '0',
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
'channel-restriction',
|
||||
{
|
||||
channelRestrict: {
|
||||
channelIdsList: [],
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
'history-limit',
|
||||
{
|
||||
historyLimit: {
|
||||
startTime: '0',
|
||||
duration: '0',
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
'peer-restriction',
|
||||
{
|
||||
peerRestrict: {
|
||||
peerIdsList: [],
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
'rate-limit',
|
||||
{
|
||||
rateLimit: {
|
||||
readLimit: {
|
||||
iterations: 50,
|
||||
numHours: 1,
|
||||
},
|
||||
writeLimit: {
|
||||
iterations: 50,
|
||||
numHours: 50,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
{
|
||||
id: '',
|
||||
devServer: true,
|
||||
expiryTimestampSeconds: '253370782800',
|
||||
label: 'Default Session',
|
||||
|
|
@ -913,6 +979,70 @@ export const litListSessions: LIT.ListSessionsResponse.AsObject = {
|
|||
sessionType: LIT.SessionType.TYPE_UI_PASSWORD,
|
||||
createdAt: '253300000000',
|
||||
accountId: '',
|
||||
autopilotFeatureInfoMap: [
|
||||
[
|
||||
'SampleFeature',
|
||||
{
|
||||
rulesMap: [
|
||||
[
|
||||
'channel-policy-bounds',
|
||||
{
|
||||
chanPolicyBounds: {
|
||||
minBaseMsat: '0',
|
||||
maxBaseMsat: '10',
|
||||
minRatePpm: 1,
|
||||
maxRatePpm: 10,
|
||||
minCltvDelta: 18,
|
||||
maxCltvDelta: 18,
|
||||
minHtlcMsat: '0',
|
||||
maxHtlcMsat: '0',
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
'channel-restriction',
|
||||
{
|
||||
channelRestrict: {
|
||||
channelIdsList: [],
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
'history-limit',
|
||||
{
|
||||
historyLimit: {
|
||||
startTime: '0',
|
||||
duration: '0',
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
'peer-restriction',
|
||||
{
|
||||
peerRestrict: {
|
||||
peerIdsList: [],
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
'rate-limit',
|
||||
{
|
||||
rateLimit: {
|
||||
readLimit: {
|
||||
iterations: 50,
|
||||
numHours: 1,
|
||||
},
|
||||
writeLimit: {
|
||||
iterations: 50,
|
||||
numHours: 50,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
|
||||
"github.com/lightninglabs/faraday/frdrpc"
|
||||
"github.com/lightninglabs/lightning-terminal/litrpc"
|
||||
"github.com/lightninglabs/loop/looprpc"
|
||||
"github.com/lightninglabs/pool/poolrpc"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
|
|
@ -41,4 +42,7 @@ var Registrations = []StubPackageRegistration{
|
|||
looprpc.RegisterSwapClientJSONCallbacks,
|
||||
poolrpc.RegisterTraderJSONCallbacks,
|
||||
frdrpc.RegisterFaradayServerJSONCallbacks,
|
||||
litrpc.RegisterSessionsJSONCallbacks,
|
||||
litrpc.RegisterAccountsJSONCallbacks,
|
||||
litrpc.RegisterAutopilotJSONCallbacks,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,12 +12,14 @@ ARG PROTOBUF_VERSION
|
|||
ARG GRPC_GATEWAY_VERSION
|
||||
|
||||
ENV PROTOC_GEN_GO_GRPC_VERSION="v1.1.0"
|
||||
ENV FALAFEL_VERSION="v0.9.1"
|
||||
|
||||
RUN cd /tmp \
|
||||
&& go get google.golang.org/protobuf/cmd/protoc-gen-go@${PROTOBUF_VERSION} \
|
||||
&& go get google.golang.org/grpc/cmd/protoc-gen-go-grpc@${PROTOC_GEN_GO_GRPC_VERSION} \
|
||||
&& go get github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@${GRPC_GATEWAY_VERSION} \
|
||||
&& go get github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@${GRPC_GATEWAY_VERSION}
|
||||
&& go get github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@${GRPC_GATEWAY_VERSION} \
|
||||
&& go get github.com/lightninglabs/falafel@${FALAFEL_VERSION}
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
|
|
|
|||
123
litrpc/accounts.pb.json.go
Normal file
123
litrpc/accounts.pb.json.go
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
// Code generated by falafel 0.9.1. DO NOT EDIT.
|
||||
// source: lit-accounts.proto
|
||||
|
||||
package litrpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
gateway "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
)
|
||||
|
||||
func RegisterAccountsJSONCallbacks(registry map[string]func(ctx context.Context,
|
||||
conn *grpc.ClientConn, reqJSON string, callback func(string, error))) {
|
||||
|
||||
marshaler := &gateway.JSONPb{
|
||||
MarshalOptions: protojson.MarshalOptions{
|
||||
UseProtoNames: true,
|
||||
EmitUnpopulated: true,
|
||||
},
|
||||
}
|
||||
|
||||
registry["litrpc.Accounts.CreateAccount"] = func(ctx context.Context,
|
||||
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
|
||||
|
||||
req := &CreateAccountRequest{}
|
||||
err := marshaler.Unmarshal([]byte(reqJSON), req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
client := NewAccountsClient(conn)
|
||||
resp, err := client.CreateAccount(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.UpdateAccount"] = func(ctx context.Context,
|
||||
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
|
||||
|
||||
req := &UpdateAccountRequest{}
|
||||
err := marshaler.Unmarshal([]byte(reqJSON), req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
client := NewAccountsClient(conn)
|
||||
resp, err := client.UpdateAccount(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)) {
|
||||
|
||||
req := &ListAccountsRequest{}
|
||||
err := marshaler.Unmarshal([]byte(reqJSON), req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
client := NewAccountsClient(conn)
|
||||
resp, err := client.ListAccounts(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.RemoveAccount"] = func(ctx context.Context,
|
||||
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
|
||||
|
||||
req := &RemoveAccountRequest{}
|
||||
err := marshaler.Unmarshal([]byte(reqJSON), req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
client := NewAccountsClient(conn)
|
||||
resp, err := client.RemoveAccount(ctx, req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
respBytes, err := marshaler.Marshal(resp)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
callback(string(respBytes), nil)
|
||||
}
|
||||
}
|
||||
123
litrpc/autopilot.pb.json.go
Normal file
123
litrpc/autopilot.pb.json.go
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
// Code generated by falafel 0.9.1. DO NOT EDIT.
|
||||
// source: lit-autopilot.proto
|
||||
|
||||
package litrpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
gateway "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
)
|
||||
|
||||
func RegisterAutopilotJSONCallbacks(registry map[string]func(ctx context.Context,
|
||||
conn *grpc.ClientConn, reqJSON string, callback func(string, error))) {
|
||||
|
||||
marshaler := &gateway.JSONPb{
|
||||
MarshalOptions: protojson.MarshalOptions{
|
||||
UseProtoNames: true,
|
||||
EmitUnpopulated: true,
|
||||
},
|
||||
}
|
||||
|
||||
registry["litrpc.Autopilot.ListAutopilotFeatures"] = func(ctx context.Context,
|
||||
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
|
||||
|
||||
req := &ListAutopilotFeaturesRequest{}
|
||||
err := marshaler.Unmarshal([]byte(reqJSON), req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
client := NewAutopilotClient(conn)
|
||||
resp, err := client.ListAutopilotFeatures(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.Autopilot.AddAutopilotSession"] = func(ctx context.Context,
|
||||
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
|
||||
|
||||
req := &AddAutopilotSessionRequest{}
|
||||
err := marshaler.Unmarshal([]byte(reqJSON), req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
client := NewAutopilotClient(conn)
|
||||
resp, err := client.AddAutopilotSession(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.Autopilot.ListAutopilotSessions"] = func(ctx context.Context,
|
||||
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
|
||||
|
||||
req := &ListAutopilotSessionsRequest{}
|
||||
err := marshaler.Unmarshal([]byte(reqJSON), req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
client := NewAutopilotClient(conn)
|
||||
resp, err := client.ListAutopilotSessions(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.Autopilot.RevokeAutopilotSession"] = func(ctx context.Context,
|
||||
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
|
||||
|
||||
req := &RevokeAutopilotSessionRequest{}
|
||||
err := marshaler.Unmarshal([]byte(reqJSON), req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
client := NewAutopilotClient(conn)
|
||||
resp, err := client.RevokeAutopilotSession(ctx, req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
respBytes, err := marshaler.Marshal(resp)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
callback(string(respBytes), nil)
|
||||
}
|
||||
}
|
||||
|
|
@ -4,12 +4,27 @@ set -e
|
|||
|
||||
# generate compiles the *.pb.go stubs from the *.proto files.
|
||||
function generate() {
|
||||
# Generate the gRPC bindings for all proto files.
|
||||
for file in ./*.proto; do
|
||||
protoc -I/usr/local/include -I. -I.. \
|
||||
# Generate the gRPC bindings for all proto files.
|
||||
protoc -I. -I.. \
|
||||
--go_out . --go_opt paths=source_relative \
|
||||
--go-grpc_out . --go-grpc_opt paths=source_relative \
|
||||
"${file}"
|
||||
|
||||
# Only generate JSON/WASM stubs if requested.
|
||||
if [[ "$1" == "no-wasm" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Generate the JSON/WASM autopilot stubs.
|
||||
falafel=$(which falafel)
|
||||
pkg="litrpc"
|
||||
opts="package_name=$pkg,js_stubs=1"
|
||||
protoc -I. -I.. \
|
||||
--plugin=protoc-gen-custom=$falafel\
|
||||
--custom_out=. \
|
||||
--custom_opt="$opts" \
|
||||
"${file}"
|
||||
done
|
||||
}
|
||||
|
||||
|
|
|
|||
1111
litrpc/lit-autopilot.pb.go
Normal file
1111
litrpc/lit-autopilot.pb.go
Normal file
File diff suppressed because it is too large
Load diff
174
litrpc/lit-autopilot.proto
Normal file
174
litrpc/lit-autopilot.proto
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
syntax = "proto3";
|
||||
|
||||
import "lit-sessions.proto";
|
||||
|
||||
package litrpc;
|
||||
|
||||
option go_package = "github.com/lightninglabs/lightning-terminal/litrpc";
|
||||
|
||||
service Autopilot {
|
||||
rpc ListAutopilotFeatures (ListAutopilotFeaturesRequest)
|
||||
returns (ListAutopilotFeaturesResponse);
|
||||
|
||||
rpc AddAutopilotSession (AddAutopilotSessionRequest)
|
||||
returns (AddAutopilotSessionResponse);
|
||||
|
||||
rpc ListAutopilotSessions (ListAutopilotSessionsRequest)
|
||||
returns (ListAutopilotSessionsResponse);
|
||||
|
||||
rpc RevokeAutopilotSession (RevokeAutopilotSessionRequest)
|
||||
returns (RevokeAutopilotSessionResponse);
|
||||
}
|
||||
|
||||
message AddAutopilotSessionRequest {
|
||||
/*
|
||||
A human readable label to assign to the session.
|
||||
*/
|
||||
string label = 1;
|
||||
|
||||
/*
|
||||
The unix timestamp at which this session should be revoked.
|
||||
*/
|
||||
uint64 expiry_timestamp_seconds = 2 [jstype = JS_STRING];
|
||||
|
||||
/*
|
||||
The address of the mailbox server to connect to for this session.
|
||||
*/
|
||||
string mailbox_server_addr = 3;
|
||||
|
||||
/*
|
||||
Set to true if tls should be skipped for when connecting to the mailbox.
|
||||
*/
|
||||
bool dev_server = 4;
|
||||
|
||||
/*
|
||||
The features that the session should subscribe to. Each feature maps to
|
||||
a FeatureConfig that should be applied to that feature.
|
||||
*/
|
||||
map<string, FeatureConfig> features = 5;
|
||||
|
||||
/*
|
||||
Rules that apply to the entire session. By default, no rules will apply
|
||||
to the entire session.
|
||||
*/
|
||||
RulesMap session_rules = 6;
|
||||
|
||||
/*
|
||||
Set to true of the session should not make use of the privacy mapper.
|
||||
*/
|
||||
bool no_privacy_mapper = 7;
|
||||
}
|
||||
|
||||
message FeatureConfig {
|
||||
/*
|
||||
The RulesMap acts as an override map. In other words, by default the rules
|
||||
values recommended by the Auto Pilot server will be used but the RulesMap
|
||||
can be used to override the defaults.
|
||||
*/
|
||||
RulesMap rules = 1;
|
||||
|
||||
/*
|
||||
Serialised configuration for the feature.
|
||||
*/
|
||||
bytes config = 2;
|
||||
}
|
||||
|
||||
message ListAutopilotSessionsRequest {
|
||||
}
|
||||
|
||||
message ListAutopilotSessionsResponse {
|
||||
/*
|
||||
A list of the Autopilot sessions.
|
||||
*/
|
||||
repeated Session sessions = 1;
|
||||
}
|
||||
|
||||
message AddAutopilotSessionResponse {
|
||||
/*
|
||||
Details of the session that was just created.
|
||||
*/
|
||||
Session session = 1;
|
||||
}
|
||||
|
||||
message ListAutopilotFeaturesRequest {
|
||||
}
|
||||
|
||||
message ListAutopilotFeaturesResponse {
|
||||
/*
|
||||
A map of feature names to Feature objects describing the feature.
|
||||
*/
|
||||
map<string, Feature> features = 1;
|
||||
}
|
||||
|
||||
message RevokeAutopilotSessionRequest {
|
||||
bytes local_public_key = 1;
|
||||
}
|
||||
|
||||
message RevokeAutopilotSessionResponse {
|
||||
}
|
||||
|
||||
message Feature {
|
||||
/*
|
||||
Name is the name of the Autopilot feature.
|
||||
*/
|
||||
string name = 1;
|
||||
|
||||
/*
|
||||
A human readable description of what the feature offers.
|
||||
*/
|
||||
string description = 2;
|
||||
|
||||
/*
|
||||
A map of rules that make sense for this feature. Each rule is accompanied
|
||||
with appropriate default values for the feature along with minimum and
|
||||
maximum values for the rules.
|
||||
*/
|
||||
map<string, RuleValues> rules = 3;
|
||||
|
||||
/*
|
||||
A list of URI permissions required by the feature.
|
||||
*/
|
||||
repeated Permissions permissions_list = 4;
|
||||
|
||||
/*
|
||||
A boolean indicating if the user would need to upgrade their Litd version in
|
||||
order to subscribe to the Autopilot feature. This will be true if the
|
||||
feature rules set contains a rule that Litd is unaware of.
|
||||
*/
|
||||
bool requires_upgrade = 5;
|
||||
}
|
||||
|
||||
message RuleValues {
|
||||
/*
|
||||
Whether or not the users version of Litd is aware of this rule.
|
||||
*/
|
||||
bool known = 1;
|
||||
|
||||
/*
|
||||
The default values for the rule that the Autopilot server recommends for
|
||||
the associated feature.
|
||||
*/
|
||||
RuleValue defaults = 2;
|
||||
|
||||
/*
|
||||
The minimum sane value for this rule for the associated feature.
|
||||
*/
|
||||
RuleValue min_value = 3;
|
||||
|
||||
/*
|
||||
The maximum sane value for this rule for the associated feature.
|
||||
*/
|
||||
RuleValue max_value = 4;
|
||||
}
|
||||
|
||||
message Permissions {
|
||||
/*
|
||||
The URI in question.
|
||||
*/
|
||||
string method = 1;
|
||||
|
||||
/*
|
||||
A list of the permissions required for this method.
|
||||
*/
|
||||
repeated MacaroonPermission operations = 2;
|
||||
}
|
||||
209
litrpc/lit-autopilot_grpc.pb.go
Normal file
209
litrpc/lit-autopilot_grpc.pb.go
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
|
||||
package litrpc
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// AutopilotClient is the client API for Autopilot service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type AutopilotClient interface {
|
||||
ListAutopilotFeatures(ctx context.Context, in *ListAutopilotFeaturesRequest, opts ...grpc.CallOption) (*ListAutopilotFeaturesResponse, error)
|
||||
AddAutopilotSession(ctx context.Context, in *AddAutopilotSessionRequest, opts ...grpc.CallOption) (*AddAutopilotSessionResponse, error)
|
||||
ListAutopilotSessions(ctx context.Context, in *ListAutopilotSessionsRequest, opts ...grpc.CallOption) (*ListAutopilotSessionsResponse, error)
|
||||
RevokeAutopilotSession(ctx context.Context, in *RevokeAutopilotSessionRequest, opts ...grpc.CallOption) (*RevokeAutopilotSessionResponse, error)
|
||||
}
|
||||
|
||||
type autopilotClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewAutopilotClient(cc grpc.ClientConnInterface) AutopilotClient {
|
||||
return &autopilotClient{cc}
|
||||
}
|
||||
|
||||
func (c *autopilotClient) ListAutopilotFeatures(ctx context.Context, in *ListAutopilotFeaturesRequest, opts ...grpc.CallOption) (*ListAutopilotFeaturesResponse, error) {
|
||||
out := new(ListAutopilotFeaturesResponse)
|
||||
err := c.cc.Invoke(ctx, "/litrpc.Autopilot/ListAutopilotFeatures", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *autopilotClient) AddAutopilotSession(ctx context.Context, in *AddAutopilotSessionRequest, opts ...grpc.CallOption) (*AddAutopilotSessionResponse, error) {
|
||||
out := new(AddAutopilotSessionResponse)
|
||||
err := c.cc.Invoke(ctx, "/litrpc.Autopilot/AddAutopilotSession", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *autopilotClient) ListAutopilotSessions(ctx context.Context, in *ListAutopilotSessionsRequest, opts ...grpc.CallOption) (*ListAutopilotSessionsResponse, error) {
|
||||
out := new(ListAutopilotSessionsResponse)
|
||||
err := c.cc.Invoke(ctx, "/litrpc.Autopilot/ListAutopilotSessions", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *autopilotClient) RevokeAutopilotSession(ctx context.Context, in *RevokeAutopilotSessionRequest, opts ...grpc.CallOption) (*RevokeAutopilotSessionResponse, error) {
|
||||
out := new(RevokeAutopilotSessionResponse)
|
||||
err := c.cc.Invoke(ctx, "/litrpc.Autopilot/RevokeAutopilotSession", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// AutopilotServer is the server API for Autopilot service.
|
||||
// All implementations must embed UnimplementedAutopilotServer
|
||||
// for forward compatibility
|
||||
type AutopilotServer interface {
|
||||
ListAutopilotFeatures(context.Context, *ListAutopilotFeaturesRequest) (*ListAutopilotFeaturesResponse, error)
|
||||
AddAutopilotSession(context.Context, *AddAutopilotSessionRequest) (*AddAutopilotSessionResponse, error)
|
||||
ListAutopilotSessions(context.Context, *ListAutopilotSessionsRequest) (*ListAutopilotSessionsResponse, error)
|
||||
RevokeAutopilotSession(context.Context, *RevokeAutopilotSessionRequest) (*RevokeAutopilotSessionResponse, error)
|
||||
mustEmbedUnimplementedAutopilotServer()
|
||||
}
|
||||
|
||||
// UnimplementedAutopilotServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedAutopilotServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedAutopilotServer) ListAutopilotFeatures(context.Context, *ListAutopilotFeaturesRequest) (*ListAutopilotFeaturesResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ListAutopilotFeatures not implemented")
|
||||
}
|
||||
func (UnimplementedAutopilotServer) AddAutopilotSession(context.Context, *AddAutopilotSessionRequest) (*AddAutopilotSessionResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method AddAutopilotSession not implemented")
|
||||
}
|
||||
func (UnimplementedAutopilotServer) ListAutopilotSessions(context.Context, *ListAutopilotSessionsRequest) (*ListAutopilotSessionsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ListAutopilotSessions not implemented")
|
||||
}
|
||||
func (UnimplementedAutopilotServer) RevokeAutopilotSession(context.Context, *RevokeAutopilotSessionRequest) (*RevokeAutopilotSessionResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method RevokeAutopilotSession not implemented")
|
||||
}
|
||||
func (UnimplementedAutopilotServer) mustEmbedUnimplementedAutopilotServer() {}
|
||||
|
||||
// UnsafeAutopilotServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to AutopilotServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeAutopilotServer interface {
|
||||
mustEmbedUnimplementedAutopilotServer()
|
||||
}
|
||||
|
||||
func RegisterAutopilotServer(s grpc.ServiceRegistrar, srv AutopilotServer) {
|
||||
s.RegisterService(&Autopilot_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Autopilot_ListAutopilotFeatures_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListAutopilotFeaturesRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AutopilotServer).ListAutopilotFeatures(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/litrpc.Autopilot/ListAutopilotFeatures",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AutopilotServer).ListAutopilotFeatures(ctx, req.(*ListAutopilotFeaturesRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Autopilot_AddAutopilotSession_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(AddAutopilotSessionRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AutopilotServer).AddAutopilotSession(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/litrpc.Autopilot/AddAutopilotSession",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AutopilotServer).AddAutopilotSession(ctx, req.(*AddAutopilotSessionRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Autopilot_ListAutopilotSessions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListAutopilotSessionsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AutopilotServer).ListAutopilotSessions(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/litrpc.Autopilot/ListAutopilotSessions",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AutopilotServer).ListAutopilotSessions(ctx, req.(*ListAutopilotSessionsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Autopilot_RevokeAutopilotSession_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(RevokeAutopilotSessionRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AutopilotServer).RevokeAutopilotSession(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/litrpc.Autopilot/RevokeAutopilotSession",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AutopilotServer).RevokeAutopilotSession(ctx, req.(*RevokeAutopilotSessionRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Autopilot_ServiceDesc is the grpc.ServiceDesc for Autopilot service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Autopilot_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "litrpc.Autopilot",
|
||||
HandlerType: (*AutopilotServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "ListAutopilotFeatures",
|
||||
Handler: _Autopilot_ListAutopilotFeatures_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "AddAutopilotSession",
|
||||
Handler: _Autopilot_AddAutopilotSession_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListAutopilotSessions",
|
||||
Handler: _Autopilot_ListAutopilotSessions_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "RevokeAutopilotSession",
|
||||
Handler: _Autopilot_RevokeAutopilotSession_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "lit-autopilot.proto",
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -19,7 +19,7 @@ enum SessionType {
|
|||
TYPE_MACAROON_ADMIN = 1;
|
||||
TYPE_MACAROON_CUSTOM = 2;
|
||||
TYPE_UI_PASSWORD = 3;
|
||||
reserved 4;
|
||||
TYPE_AUTOPILOT = 4;
|
||||
TYPE_MACAROON_ACCOUNT = 5;
|
||||
}
|
||||
|
||||
|
|
@ -95,10 +95,7 @@ message Session {
|
|||
|
||||
string account_id = 13;
|
||||
|
||||
/*
|
||||
Field number 15 is reserved for future use.
|
||||
*/
|
||||
reserved 15;
|
||||
map<string, RulesMap> autopilot_feature_info = 15;
|
||||
|
||||
/*
|
||||
The unix timestamp indicating the time at which the session was revoked.
|
||||
|
|
@ -130,3 +127,125 @@ message RevokeSessionRequest {
|
|||
|
||||
message RevokeSessionResponse {
|
||||
}
|
||||
|
||||
message RulesMap {
|
||||
/*
|
||||
A map of rule name to RuleValue. The RuleValue should be parsed based on
|
||||
the name of the rule.
|
||||
*/
|
||||
map<string, RuleValue> rules = 1;
|
||||
}
|
||||
|
||||
message RuleValue {
|
||||
oneof value {
|
||||
RateLimit rate_limit = 1;
|
||||
ChannelPolicyBounds chan_policy_bounds = 2;
|
||||
HistoryLimit history_limit = 3;
|
||||
OffChainBudget off_chain_budget = 4;
|
||||
OnChainBudget on_chain_budget = 5;
|
||||
SendToSelf send_to_self = 6;
|
||||
ChannelRestrict channel_restrict = 7;
|
||||
PeerRestrict peer_restrict = 8;
|
||||
}
|
||||
}
|
||||
|
||||
message RateLimit {
|
||||
/*
|
||||
The rate limit for read-only calls.
|
||||
*/
|
||||
Rate read_limit = 1;
|
||||
|
||||
/*
|
||||
The rate limit for write/execution calls.
|
||||
*/
|
||||
Rate write_limit = 2;
|
||||
}
|
||||
|
||||
message Rate {
|
||||
/*
|
||||
The number of times a call is allowed in num_hours number of hours.
|
||||
*/
|
||||
uint32 iterations = 1;
|
||||
|
||||
/*
|
||||
The number of hours in which the iterations count takes place over.
|
||||
*/
|
||||
uint32 num_hours = 2;
|
||||
}
|
||||
|
||||
message HistoryLimit {
|
||||
/*
|
||||
The absolute unix timestamp in seconds before which no information should
|
||||
be shared. This should only be set if duration is not set.
|
||||
*/
|
||||
uint64 start_time = 1 [jstype = JS_STRING];
|
||||
|
||||
/*
|
||||
The maximum relative duration in seconds that a request is allowed to query
|
||||
for. This should only be set if start_time is not set.
|
||||
*/
|
||||
uint64 duration = 2 [jstype = JS_STRING];
|
||||
}
|
||||
|
||||
message ChannelPolicyBounds {
|
||||
/*
|
||||
The minimum base fee in msat that the autopilot can set for a channel.
|
||||
*/
|
||||
uint64 min_base_msat = 1 [jstype = JS_STRING];
|
||||
|
||||
/*
|
||||
The maximum base fee in msat that the autopilot can set for a channel.
|
||||
*/
|
||||
uint64 max_base_msat = 2 [jstype = JS_STRING];
|
||||
|
||||
/*
|
||||
The minimum ppm fee in msat that the autopilot can set for a channel.
|
||||
*/
|
||||
uint32 min_rate_ppm = 3;
|
||||
|
||||
/*
|
||||
The maximum ppm fee in msat that the autopilot can set for a channel.
|
||||
*/
|
||||
uint32 max_rate_ppm = 4;
|
||||
|
||||
/*
|
||||
The minimum cltv delta that the autopilot may set for a channel.
|
||||
*/
|
||||
uint32 min_cltv_delta = 5;
|
||||
|
||||
/*
|
||||
The maximum cltv delta that the autopilot may set for a channel.
|
||||
*/
|
||||
uint32 max_cltv_delta = 6;
|
||||
|
||||
/*
|
||||
The minimum htlc msat that the autopilot may set for a channel.
|
||||
*/
|
||||
uint64 min_htlc_msat = 7 [jstype = JS_STRING];
|
||||
|
||||
/*
|
||||
The maximum htlc msat that the autopilot may set for a channel.
|
||||
*/
|
||||
uint64 max_htlc_msat = 8 [jstype = JS_STRING];
|
||||
}
|
||||
|
||||
message OffChainBudget {
|
||||
uint64 max_amt_msat = 1 [jstype = JS_STRING];
|
||||
uint64 max_fees_msat = 2 [jstype = JS_STRING];
|
||||
}
|
||||
|
||||
message OnChainBudget {
|
||||
uint64 absolute_amt_sats = 1 [jstype = JS_STRING];
|
||||
uint64 max_sat_per_v_byte = 2 [jstype = JS_STRING];
|
||||
}
|
||||
|
||||
message SendToSelf {
|
||||
}
|
||||
|
||||
message ChannelRestrict {
|
||||
repeated uint64 channel_ids = 1 [jstype = JS_STRING];
|
||||
}
|
||||
|
||||
message PeerRestrict {
|
||||
repeated string peer_ids = 1;
|
||||
}
|
||||
98
litrpc/sessions.pb.json.go
Normal file
98
litrpc/sessions.pb.json.go
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
// Code generated by falafel 0.9.1. DO NOT EDIT.
|
||||
// source: lit-sessions.proto
|
||||
|
||||
package litrpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
gateway "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
)
|
||||
|
||||
func RegisterSessionsJSONCallbacks(registry map[string]func(ctx context.Context,
|
||||
conn *grpc.ClientConn, reqJSON string, callback func(string, error))) {
|
||||
|
||||
marshaler := &gateway.JSONPb{
|
||||
MarshalOptions: protojson.MarshalOptions{
|
||||
UseProtoNames: true,
|
||||
EmitUnpopulated: true,
|
||||
},
|
||||
}
|
||||
|
||||
registry["litrpc.Sessions.AddSession"] = func(ctx context.Context,
|
||||
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
|
||||
|
||||
req := &AddSessionRequest{}
|
||||
err := marshaler.Unmarshal([]byte(reqJSON), req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
client := NewSessionsClient(conn)
|
||||
resp, err := client.AddSession(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.Sessions.ListSessions"] = func(ctx context.Context,
|
||||
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
|
||||
|
||||
req := &ListSessionsRequest{}
|
||||
err := marshaler.Unmarshal([]byte(reqJSON), req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
client := NewSessionsClient(conn)
|
||||
resp, err := client.ListSessions(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.Sessions.RevokeSession"] = func(ctx context.Context,
|
||||
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
|
||||
|
||||
req := &RevokeSessionRequest{}
|
||||
err := marshaler.Unmarshal([]byte(reqJSON), req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
client := NewSessionsClient(conn)
|
||||
resp, err := client.RevokeSession(ctx, req)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
|
||||
respBytes, err := marshaler.Marshal(resp)
|
||||
if err != nil {
|
||||
callback("", err)
|
||||
return
|
||||
}
|
||||
callback(string(respBytes), nil)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue