diff --git a/libs/gl-client-py/Makefile b/libs/gl-client-py/Makefile index 63cf91168..d277e1e71 100644 --- a/libs/gl-client-py/Makefile +++ b/libs/gl-client-py/Makefile @@ -10,6 +10,19 @@ PYVERSION=$(shell cd libs && cargo metadata --format-version 1 | jq -r '.package PYDIR=${REPO}/libs/gl-client-py PROTODIR=${REPO}/libs/proto +# The protobuf gencode embeds a hard assertion that the runtime is at +# least as new as the protoc that produced it, so regenerating with a +# newer toolchain than the deployed runtime breaks every consumer at +# import time. Pin the generator and run it isolated from the ambient +# venv, so the checked-in stubs do not depend on who regenerated them. +# Bump deliberately, together with the `protobuf` runtime bound in +# pyproject.toml. +PROTOC_TOOLCHAIN = \ + uv run --no-project \ + --with grpcio-tools==1.78.0 \ + --with mypy-protobuf==5.0.0 \ + python -m grpc_tools.protoc + PYPROTOC_OPTS = \ -I ${PROTODIR} \ --python_out=${PYDIR} \ @@ -35,8 +48,8 @@ ${PYPROTOS}: pygrpc pygrpc: ${PROTOSRC} cp ${PYDIR}/../proto/glclient/scheduler.proto ${PYDIR}/glclient/ cp ${PYDIR}/../proto/glclient/greenlight.proto ${PYDIR}/glclient/ - cd ${PYDIR}; uv run python -m grpc_tools.protoc ${PYPROTOC_OPTS} glclient/scheduler.proto - cd ${PYDIR}; uv run python -m grpc_tools.protoc ${PYPROTOC_OPTS} glclient/greenlight.proto + cd ${PYDIR}; ${PROTOC_TOOLCHAIN} ${PYPROTOC_OPTS} glclient/scheduler.proto + cd ${PYDIR}; ${PROTOC_TOOLCHAIN} ${PYPROTOC_OPTS} glclient/greenlight.proto check-py: #uv run --reinstall-package='gl-sdk' --all-packages mypy ${PYDIR}/glclient diff --git a/libs/gl-client-py/glclient/scheduler.proto b/libs/gl-client-py/glclient/scheduler.proto index 3bb15f32e..73880cd8c 100644 --- a/libs/gl-client-py/glclient/scheduler.proto +++ b/libs/gl-client-py/glclient/scheduler.proto @@ -26,8 +26,10 @@ import "glclient/greenlight.proto"; // Users are authenticated using mTLS authentication. Applications are // provisioned with an anonymous keypair that is not bound to a node, // allowing access only to the unauthenticated endpoints -// `Scheduler.GetChallenge`, `Scheduler.Register` and -// `Scheduler.Recover`. This allows them to register or recover a +// `Scheduler.GetChallenge`, `Scheduler.Register`, +// `Scheduler.Recover` and +// `Scheduler.CheckLightningAvailability`. This allows them to +// register or recover a // node, but doesn't give access to the node itself. Upon registering // or recovering an account the user receives a keypair that is bound // to the specific node. Once the user receives their personal mTLS @@ -82,6 +84,25 @@ service Scheduler { // error being returned. rpc GetChallenge(ChallengeRequest) returns (ChallengeResponse) {} + // Reports whether the Lightning account backed by `node_id` may + // be surfaced to the user. This is a feature gate for downstream + // applications: greenlight relays the question to its Lightning + // Service Provider, which answers based on whether it has + // previously granted this node a slot (grants are sticky) or has + // the capacity to grant one now. + // + // Unlike the other node-scoped calls this one is deliberately + // available *before* registration, since an application has to + // decide whether to offer Lightning at all before it creates a + // node. There is therefore no mTLS identity to derive the node + // from, and the caller names the `node_id` it is asking about. + // + // The answer is advisory and may change: a node that is not + // available today may become available once the LSP has capacity + // again. Applications should treat an error as "unknown" rather + // than as a negative answer. + rpc CheckLightningAvailability(CheckLightningAvailabilityRequest) returns (CheckLightningAvailabilityResponse) {} + // Scheduling takes a previously registered node, locates a // free slot in greenlight's infrastructure and allocates it // to run the node. The node then goes through the startup @@ -248,6 +269,18 @@ enum ChallengeScope { RECOVER = 1; } +message CheckLightningAvailabilityRequest { + // 33 bytes node public key. The node need not be registered + // with greenlight yet. + bytes node_id = 1; +}; + +message CheckLightningAvailabilityResponse { + // Whether the Lightning account backed by this node may be + // surfaced to the user. + bool available = 1; +}; + message RegistrationRequest { // 33 bytes node public key. bytes node_id = 1; diff --git a/libs/gl-client-py/glclient/scheduler_pb2.py b/libs/gl-client-py/glclient/scheduler_pb2.py index 0acdb1461..e2280a7b8 100644 --- a/libs/gl-client-py/glclient/scheduler_pb2.py +++ b/libs/gl-client-py/glclient/scheduler_pb2.py @@ -25,7 +25,7 @@ from glclient import greenlight_pb2 as glclient_dot_greenlight__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x18glclient/scheduler.proto\x12\tscheduler\x1a\x19glclient/greenlight.proto\"9\n\x19\x41\x64\x64OutgoingWebhookRequest\x12\x0f\n\x07node_id\x18\x01 \x01(\x0c\x12\x0b\n\x03uri\x18\x02 \x01(\t\"8\n\x1a\x41\x64\x64OutgoingWebhookResponse\x12\n\n\x02id\x18\x01 \x01(\x03\x12\x0e\n\x06secret\x18\x02 \x01(\t\".\n\x1bListOutgoingWebhooksRequest\x12\x0f\n\x07node_id\x18\x01 \x01(\x0c\"\"\n\x07Webhook\x12\n\n\x02id\x18\x01 \x01(\x03\x12\x0b\n\x03uri\x18\x02 \x01(\t\"M\n\x1cListOutgoingWebhooksResponse\x12-\n\x11outgoing_webhooks\x18\x01 \x03(\x0b\x32\x12.scheduler.Webhook\"=\n\x1d\x44\x65leteOutgoingWebhooksRequest\x12\x0f\n\x07node_id\x18\x01 \x01(\x0c\x12\x0b\n\x03ids\x18\x02 \x03(\x03\"I\n\"RotateOutgoingWebhookSecretRequest\x12\x0f\n\x07node_id\x18\x01 \x01(\x0c\x12\x12\n\nwebhook_id\x18\x02 \x01(\x03\"\'\n\x15WebhookSecretResponse\x12\x0e\n\x06secret\x18\x01 \x01(\t\"M\n\x10\x43hallengeRequest\x12(\n\x05scope\x18\x01 \x01(\x0e\x32\x19.scheduler.ChallengeScope\x12\x0f\n\x07node_id\x18\x02 \x01(\x0c\"&\n\x11\x43hallengeResponse\x12\x11\n\tchallenge\x18\x01 \x01(\x0c\"\xea\x01\n\x13RegistrationRequest\x12\x0f\n\x07node_id\x18\x01 \x01(\x0c\x12\x11\n\tbip32_key\x18\x02 \x01(\x0c\x12\x0f\n\x07network\x18\x04 \x01(\t\x12\x11\n\tchallenge\x18\x05 \x01(\x0c\x12\x11\n\tsignature\x18\x06 \x01(\x0c\x12\x14\n\x0csigner_proto\x18\x07 \x01(\t\x12\x10\n\x08init_msg\x18\x08 \x01(\x0c\x12\x0b\n\x03\x63sr\x18\t \x01(\x0c\x12\x13\n\x0binvite_code\x18\n \x01(\t\x12.\n\x0bstartupmsgs\x18\x03 \x03(\x0b\x32\x19.scheduler.StartupMessage\"\\\n\x14RegistrationResponse\x12\x13\n\x0b\x64\x65vice_cert\x18\x01 \x01(\t\x12\x12\n\ndevice_key\x18\x02 \x01(\t\x12\x0c\n\x04rune\x18\x03 \x01(\t\x12\r\n\x05\x63reds\x18\x04 \x01(\x0c\"\"\n\x0fScheduleRequest\x12\x0f\n\x07node_id\x18\x01 \x01(\x0c\"0\n\x0fNodeInfoRequest\x12\x0f\n\x07node_id\x18\x01 \x01(\x0c\x12\x0c\n\x04wait\x18\x02 \x01(\x08\"I\n\x10NodeInfoResponse\x12\x0f\n\x07node_id\x18\x01 \x01(\x0c\x12\x10\n\x08grpc_uri\x18\x02 \x01(\t\x12\x12\n\nsession_id\x18\x03 \x01(\x04\"U\n\x0fRecoveryRequest\x12\x11\n\tchallenge\x18\x01 \x01(\x0c\x12\x11\n\tsignature\x18\x02 \x01(\x0c\x12\x0f\n\x07node_id\x18\x03 \x01(\x0c\x12\x0b\n\x03\x63sr\x18\t \x01(\x0c\"X\n\x10RecoveryResponse\x12\x13\n\x0b\x64\x65vice_cert\x18\x01 \x01(\t\x12\x12\n\ndevice_key\x18\x02 \x01(\t\x12\x0c\n\x04rune\x18\x03 \x01(\t\x12\r\n\x05\x63reds\x18\x04 \x01(\x0c\"m\n\x0eUpgradeRequest\x12\x16\n\x0esigner_version\x18\x01 \x01(\t\x12\x13\n\x07initmsg\x18\x02 \x01(\x0c\x42\x02\x18\x01\x12.\n\x0bstartupmsgs\x18\x03 \x03(\x0b\x32\x19.scheduler.StartupMessage\"&\n\x0fUpgradeResponse\x12\x13\n\x0bold_version\x18\x01 \x01(\t\"3\n\x0eStartupMessage\x12\x0f\n\x07request\x18\x01 \x01(\x0c\x12\x10\n\x08response\x18\x02 \x01(\x0c\"\x18\n\x16ListInviteCodesRequest\"J\n\x17ListInviteCodesResponse\x12/\n\x10invite_code_list\x18\x01 \x03(\x0b\x32\x15.scheduler.InviteCode\"/\n\nInviteCode\x12\x0c\n\x04\x63ode\x18\x01 \x01(\t\x12\x13\n\x0bis_redeemed\x18\x02 \x01(\x08\"\x13\n\x11\x45xportNodeRequest\"!\n\x12\x45xportNodeResponse\x12\x0b\n\x03url\x18\x01 \x01(\t\"m\n\x0fSignerRejection\x12\x0b\n\x03msg\x18\x01 \x01(\t\x12\'\n\x07request\x18\x02 \x01(\x0b\x32\x16.greenlight.HsmRequest\x12\x13\n\x0bgit_version\x18\x03 \x01(\t\x12\x0f\n\x07node_id\x18\x04 \x01(\x0c\"s\n\x11PairDeviceRequest\x12\x11\n\tdevice_id\x18\x01 \x01(\t\x12\x0b\n\x03\x63sr\x18\x02 \x01(\x0c\x12\x13\n\x0b\x64\x65vice_name\x18\x03 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x04 \x01(\t\x12\x14\n\x0crestrictions\x18\x05 \x01(\t\"m\n\x12PairDeviceResponse\x12\x11\n\tdevice_id\x18\x01 \x01(\t\x12\x13\n\x0b\x64\x65vice_cert\x18\x02 \x01(\t\x12\x12\n\ndevice_key\x18\x03 \x01(\t\x12\x0c\n\x04rune\x18\x04 \x01(\t\x12\r\n\x05\x63reds\x18\x05 \x01(\x0c\"*\n\x15GetPairingDataRequest\x12\x11\n\tdevice_id\x18\x01 \x01(\t\"x\n\x16GetPairingDataResponse\x12\x11\n\tdevice_id\x18\x01 \x01(\t\x12\x0b\n\x03\x63sr\x18\x02 \x01(\x0c\x12\x13\n\x0b\x64\x65vice_name\x18\x03 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x04 \x01(\t\x12\x14\n\x0crestrictions\x18\x05 \x01(\t\"\x93\x01\n\x15\x41pprovePairingRequest\x12\x11\n\tdevice_id\x18\x01 \x01(\t\x12\x11\n\ttimestamp\x18\x02 \x01(\x04\x12\x13\n\x0b\x64\x65vice_name\x18\x03 \x01(\t\x12\x14\n\x0crestrictions\x18\x04 \x01(\t\x12\x0b\n\x03sig\x18\x05 \x01(\x0c\x12\x0e\n\x06pubkey\x18\x06 \x01(\x0c\x12\x0c\n\x04rune\x18\x07 \x01(\t\"J\n\x16\x41pprovePairingResponse\x12\x11\n\tdevice_id\x18\x01 \x01(\t\x12\x0f\n\x07node_id\x18\x02 \x01(\x0c\x12\x0c\n\x04rune\x18\x03 \x01(\t\"k\n\rSignerRequest\x12\x12\n\nrequest_id\x18\x01 \x01(\r\x12;\n\x0f\x61pprove_pairing\x18\x02 \x01(\x0b\x32 .scheduler.ApprovePairingRequestH\x00\x42\t\n\x07request\"\x92\x01\n\x0eSignerResponse\x12\x12\n\nrequest_id\x18\x01 \x01(\r\x12\"\n\x05\x65mpty\x18\x02 \x01(\x0b\x32\x11.greenlight.EmptyH\x00\x12<\n\x0f\x61pprove_pairing\x18\x03 \x01(\x0b\x32!.scheduler.ApprovePairingResponseH\x00\x42\n\n\x08response*+\n\x0e\x43hallengeScope\x12\x0c\n\x08REGISTER\x10\x00\x12\x0b\n\x07RECOVER\x10\x01\x32\xd6\x08\n\tScheduler\x12M\n\x08Register\x12\x1e.scheduler.RegistrationRequest\x1a\x1f.scheduler.RegistrationResponse\"\x00\x12\x44\n\x07Recover\x12\x1a.scheduler.RecoveryRequest\x1a\x1b.scheduler.RecoveryResponse\"\x00\x12K\n\x0cGetChallenge\x12\x1b.scheduler.ChallengeRequest\x1a\x1c.scheduler.ChallengeResponse\"\x00\x12\x45\n\x08Schedule\x12\x1a.scheduler.ScheduleRequest\x1a\x1b.scheduler.NodeInfoResponse\"\x00\x12H\n\x0bGetNodeInfo\x12\x1a.scheduler.NodeInfoRequest\x1a\x1b.scheduler.NodeInfoResponse\"\x00\x12G\n\x0cMaybeUpgrade\x12\x19.scheduler.UpgradeRequest\x1a\x1a.scheduler.UpgradeResponse\"\x00\x12Z\n\x0fListInviteCodes\x12!.scheduler.ListInviteCodesRequest\x1a\".scheduler.ListInviteCodesResponse\"\x00\x12K\n\nExportNode\x12\x1c.scheduler.ExportNodeRequest\x1a\x1d.scheduler.ExportNodeResponse\"\x00\x12\x63\n\x12\x41\x64\x64OutgoingWebhook\x12$.scheduler.AddOutgoingWebhookRequest\x1a%.scheduler.AddOutgoingWebhookResponse\"\x00\x12i\n\x14ListOutgoingWebhooks\x12&.scheduler.ListOutgoingWebhooksRequest\x1a\'.scheduler.ListOutgoingWebhooksResponse\"\x00\x12O\n\x0e\x44\x65leteWebhooks\x12(.scheduler.DeleteOutgoingWebhooksRequest\x1a\x11.greenlight.Empty\"\x00\x12p\n\x1bRotateOutgoingWebhookSecret\x12-.scheduler.RotateOutgoingWebhookSecretRequest\x1a .scheduler.WebhookSecretResponse\"\x00\x12Q\n\x14SignerRequestsStream\x12\x19.scheduler.SignerResponse\x1a\x18.scheduler.SignerRequest\"\x00(\x01\x30\x01\x32Q\n\x05\x44\x65\x62ug\x12H\n\x15ReportSignerRejection\x12\x1a.scheduler.SignerRejection\x1a\x11.greenlight.Empty\"\x00\x32\xf8\x01\n\x07Pairing\x12K\n\nPairDevice\x12\x1c.scheduler.PairDeviceRequest\x1a\x1d.scheduler.PairDeviceResponse\"\x00\x12W\n\x0eGetPairingData\x12 .scheduler.GetPairingDataRequest\x1a!.scheduler.GetPairingDataResponse\"\x00\x12G\n\x0e\x41pprovePairing\x12 .scheduler.ApprovePairingRequest\x1a\x11.greenlight.Empty\"\x00\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x18glclient/scheduler.proto\x12\tscheduler\x1a\x19glclient/greenlight.proto\"9\n\x19\x41\x64\x64OutgoingWebhookRequest\x12\x0f\n\x07node_id\x18\x01 \x01(\x0c\x12\x0b\n\x03uri\x18\x02 \x01(\t\"8\n\x1a\x41\x64\x64OutgoingWebhookResponse\x12\n\n\x02id\x18\x01 \x01(\x03\x12\x0e\n\x06secret\x18\x02 \x01(\t\".\n\x1bListOutgoingWebhooksRequest\x12\x0f\n\x07node_id\x18\x01 \x01(\x0c\"\"\n\x07Webhook\x12\n\n\x02id\x18\x01 \x01(\x03\x12\x0b\n\x03uri\x18\x02 \x01(\t\"M\n\x1cListOutgoingWebhooksResponse\x12-\n\x11outgoing_webhooks\x18\x01 \x03(\x0b\x32\x12.scheduler.Webhook\"=\n\x1d\x44\x65leteOutgoingWebhooksRequest\x12\x0f\n\x07node_id\x18\x01 \x01(\x0c\x12\x0b\n\x03ids\x18\x02 \x03(\x03\"I\n\"RotateOutgoingWebhookSecretRequest\x12\x0f\n\x07node_id\x18\x01 \x01(\x0c\x12\x12\n\nwebhook_id\x18\x02 \x01(\x03\"\'\n\x15WebhookSecretResponse\x12\x0e\n\x06secret\x18\x01 \x01(\t\"M\n\x10\x43hallengeRequest\x12(\n\x05scope\x18\x01 \x01(\x0e\x32\x19.scheduler.ChallengeScope\x12\x0f\n\x07node_id\x18\x02 \x01(\x0c\"&\n\x11\x43hallengeResponse\x12\x11\n\tchallenge\x18\x01 \x01(\x0c\"4\n!CheckLightningAvailabilityRequest\x12\x0f\n\x07node_id\x18\x01 \x01(\x0c\"7\n\"CheckLightningAvailabilityResponse\x12\x11\n\tavailable\x18\x01 \x01(\x08\"\xea\x01\n\x13RegistrationRequest\x12\x0f\n\x07node_id\x18\x01 \x01(\x0c\x12\x11\n\tbip32_key\x18\x02 \x01(\x0c\x12\x0f\n\x07network\x18\x04 \x01(\t\x12\x11\n\tchallenge\x18\x05 \x01(\x0c\x12\x11\n\tsignature\x18\x06 \x01(\x0c\x12\x14\n\x0csigner_proto\x18\x07 \x01(\t\x12\x10\n\x08init_msg\x18\x08 \x01(\x0c\x12\x0b\n\x03\x63sr\x18\t \x01(\x0c\x12\x13\n\x0binvite_code\x18\n \x01(\t\x12.\n\x0bstartupmsgs\x18\x03 \x03(\x0b\x32\x19.scheduler.StartupMessage\"\\\n\x14RegistrationResponse\x12\x13\n\x0b\x64\x65vice_cert\x18\x01 \x01(\t\x12\x12\n\ndevice_key\x18\x02 \x01(\t\x12\x0c\n\x04rune\x18\x03 \x01(\t\x12\r\n\x05\x63reds\x18\x04 \x01(\x0c\"\"\n\x0fScheduleRequest\x12\x0f\n\x07node_id\x18\x01 \x01(\x0c\"0\n\x0fNodeInfoRequest\x12\x0f\n\x07node_id\x18\x01 \x01(\x0c\x12\x0c\n\x04wait\x18\x02 \x01(\x08\"I\n\x10NodeInfoResponse\x12\x0f\n\x07node_id\x18\x01 \x01(\x0c\x12\x10\n\x08grpc_uri\x18\x02 \x01(\t\x12\x12\n\nsession_id\x18\x03 \x01(\x04\"U\n\x0fRecoveryRequest\x12\x11\n\tchallenge\x18\x01 \x01(\x0c\x12\x11\n\tsignature\x18\x02 \x01(\x0c\x12\x0f\n\x07node_id\x18\x03 \x01(\x0c\x12\x0b\n\x03\x63sr\x18\t \x01(\x0c\"X\n\x10RecoveryResponse\x12\x13\n\x0b\x64\x65vice_cert\x18\x01 \x01(\t\x12\x12\n\ndevice_key\x18\x02 \x01(\t\x12\x0c\n\x04rune\x18\x03 \x01(\t\x12\r\n\x05\x63reds\x18\x04 \x01(\x0c\"m\n\x0eUpgradeRequest\x12\x16\n\x0esigner_version\x18\x01 \x01(\t\x12\x13\n\x07initmsg\x18\x02 \x01(\x0c\x42\x02\x18\x01\x12.\n\x0bstartupmsgs\x18\x03 \x03(\x0b\x32\x19.scheduler.StartupMessage\"&\n\x0fUpgradeResponse\x12\x13\n\x0bold_version\x18\x01 \x01(\t\"3\n\x0eStartupMessage\x12\x0f\n\x07request\x18\x01 \x01(\x0c\x12\x10\n\x08response\x18\x02 \x01(\x0c\"\x18\n\x16ListInviteCodesRequest\"J\n\x17ListInviteCodesResponse\x12/\n\x10invite_code_list\x18\x01 \x03(\x0b\x32\x15.scheduler.InviteCode\"/\n\nInviteCode\x12\x0c\n\x04\x63ode\x18\x01 \x01(\t\x12\x13\n\x0bis_redeemed\x18\x02 \x01(\x08\"\x13\n\x11\x45xportNodeRequest\"!\n\x12\x45xportNodeResponse\x12\x0b\n\x03url\x18\x01 \x01(\t\"m\n\x0fSignerRejection\x12\x0b\n\x03msg\x18\x01 \x01(\t\x12\'\n\x07request\x18\x02 \x01(\x0b\x32\x16.greenlight.HsmRequest\x12\x13\n\x0bgit_version\x18\x03 \x01(\t\x12\x0f\n\x07node_id\x18\x04 \x01(\x0c\"s\n\x11PairDeviceRequest\x12\x11\n\tdevice_id\x18\x01 \x01(\t\x12\x0b\n\x03\x63sr\x18\x02 \x01(\x0c\x12\x13\n\x0b\x64\x65vice_name\x18\x03 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x04 \x01(\t\x12\x14\n\x0crestrictions\x18\x05 \x01(\t\"m\n\x12PairDeviceResponse\x12\x11\n\tdevice_id\x18\x01 \x01(\t\x12\x13\n\x0b\x64\x65vice_cert\x18\x02 \x01(\t\x12\x12\n\ndevice_key\x18\x03 \x01(\t\x12\x0c\n\x04rune\x18\x04 \x01(\t\x12\r\n\x05\x63reds\x18\x05 \x01(\x0c\"*\n\x15GetPairingDataRequest\x12\x11\n\tdevice_id\x18\x01 \x01(\t\"x\n\x16GetPairingDataResponse\x12\x11\n\tdevice_id\x18\x01 \x01(\t\x12\x0b\n\x03\x63sr\x18\x02 \x01(\x0c\x12\x13\n\x0b\x64\x65vice_name\x18\x03 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x04 \x01(\t\x12\x14\n\x0crestrictions\x18\x05 \x01(\t\"\x93\x01\n\x15\x41pprovePairingRequest\x12\x11\n\tdevice_id\x18\x01 \x01(\t\x12\x11\n\ttimestamp\x18\x02 \x01(\x04\x12\x13\n\x0b\x64\x65vice_name\x18\x03 \x01(\t\x12\x14\n\x0crestrictions\x18\x04 \x01(\t\x12\x0b\n\x03sig\x18\x05 \x01(\x0c\x12\x0e\n\x06pubkey\x18\x06 \x01(\x0c\x12\x0c\n\x04rune\x18\x07 \x01(\t\"J\n\x16\x41pprovePairingResponse\x12\x11\n\tdevice_id\x18\x01 \x01(\t\x12\x0f\n\x07node_id\x18\x02 \x01(\x0c\x12\x0c\n\x04rune\x18\x03 \x01(\t\"k\n\rSignerRequest\x12\x12\n\nrequest_id\x18\x01 \x01(\r\x12;\n\x0f\x61pprove_pairing\x18\x02 \x01(\x0b\x32 .scheduler.ApprovePairingRequestH\x00\x42\t\n\x07request\"\x92\x01\n\x0eSignerResponse\x12\x12\n\nrequest_id\x18\x01 \x01(\r\x12\"\n\x05\x65mpty\x18\x02 \x01(\x0b\x32\x11.greenlight.EmptyH\x00\x12<\n\x0f\x61pprove_pairing\x18\x03 \x01(\x0b\x32!.scheduler.ApprovePairingResponseH\x00\x42\n\n\x08response*+\n\x0e\x43hallengeScope\x12\x0c\n\x08REGISTER\x10\x00\x12\x0b\n\x07RECOVER\x10\x01\x32\xd3\t\n\tScheduler\x12M\n\x08Register\x12\x1e.scheduler.RegistrationRequest\x1a\x1f.scheduler.RegistrationResponse\"\x00\x12\x44\n\x07Recover\x12\x1a.scheduler.RecoveryRequest\x1a\x1b.scheduler.RecoveryResponse\"\x00\x12K\n\x0cGetChallenge\x12\x1b.scheduler.ChallengeRequest\x1a\x1c.scheduler.ChallengeResponse\"\x00\x12{\n\x1a\x43heckLightningAvailability\x12,.scheduler.CheckLightningAvailabilityRequest\x1a-.scheduler.CheckLightningAvailabilityResponse\"\x00\x12\x45\n\x08Schedule\x12\x1a.scheduler.ScheduleRequest\x1a\x1b.scheduler.NodeInfoResponse\"\x00\x12H\n\x0bGetNodeInfo\x12\x1a.scheduler.NodeInfoRequest\x1a\x1b.scheduler.NodeInfoResponse\"\x00\x12G\n\x0cMaybeUpgrade\x12\x19.scheduler.UpgradeRequest\x1a\x1a.scheduler.UpgradeResponse\"\x00\x12Z\n\x0fListInviteCodes\x12!.scheduler.ListInviteCodesRequest\x1a\".scheduler.ListInviteCodesResponse\"\x00\x12K\n\nExportNode\x12\x1c.scheduler.ExportNodeRequest\x1a\x1d.scheduler.ExportNodeResponse\"\x00\x12\x63\n\x12\x41\x64\x64OutgoingWebhook\x12$.scheduler.AddOutgoingWebhookRequest\x1a%.scheduler.AddOutgoingWebhookResponse\"\x00\x12i\n\x14ListOutgoingWebhooks\x12&.scheduler.ListOutgoingWebhooksRequest\x1a\'.scheduler.ListOutgoingWebhooksResponse\"\x00\x12O\n\x0e\x44\x65leteWebhooks\x12(.scheduler.DeleteOutgoingWebhooksRequest\x1a\x11.greenlight.Empty\"\x00\x12p\n\x1bRotateOutgoingWebhookSecret\x12-.scheduler.RotateOutgoingWebhookSecretRequest\x1a .scheduler.WebhookSecretResponse\"\x00\x12Q\n\x14SignerRequestsStream\x12\x19.scheduler.SignerResponse\x1a\x18.scheduler.SignerRequest\"\x00(\x01\x30\x01\x32Q\n\x05\x44\x65\x62ug\x12H\n\x15ReportSignerRejection\x12\x1a.scheduler.SignerRejection\x1a\x11.greenlight.Empty\"\x00\x32\xf8\x01\n\x07Pairing\x12K\n\nPairDevice\x12\x1c.scheduler.PairDeviceRequest\x1a\x1d.scheduler.PairDeviceResponse\"\x00\x12W\n\x0eGetPairingData\x12 .scheduler.GetPairingDataRequest\x1a!.scheduler.GetPairingDataResponse\"\x00\x12G\n\x0e\x41pprovePairing\x12 .scheduler.ApprovePairingRequest\x1a\x11.greenlight.Empty\"\x00\x62\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) @@ -34,8 +34,8 @@ DESCRIPTOR._loaded_options = None _globals['_UPGRADEREQUEST'].fields_by_name['initmsg']._loaded_options = None _globals['_UPGRADEREQUEST'].fields_by_name['initmsg']._serialized_options = b'\030\001' - _globals['_CHALLENGESCOPE']._serialized_start=2713 - _globals['_CHALLENGESCOPE']._serialized_end=2756 + _globals['_CHALLENGESCOPE']._serialized_start=2824 + _globals['_CHALLENGESCOPE']._serialized_end=2867 _globals['_ADDOUTGOINGWEBHOOKREQUEST']._serialized_start=66 _globals['_ADDOUTGOINGWEBHOOKREQUEST']._serialized_end=123 _globals['_ADDOUTGOINGWEBHOOKRESPONSE']._serialized_start=125 @@ -56,58 +56,62 @@ _globals['_CHALLENGEREQUEST']._serialized_end=602 _globals['_CHALLENGERESPONSE']._serialized_start=604 _globals['_CHALLENGERESPONSE']._serialized_end=642 - _globals['_REGISTRATIONREQUEST']._serialized_start=645 - _globals['_REGISTRATIONREQUEST']._serialized_end=879 - _globals['_REGISTRATIONRESPONSE']._serialized_start=881 - _globals['_REGISTRATIONRESPONSE']._serialized_end=973 - _globals['_SCHEDULEREQUEST']._serialized_start=975 - _globals['_SCHEDULEREQUEST']._serialized_end=1009 - _globals['_NODEINFOREQUEST']._serialized_start=1011 - _globals['_NODEINFOREQUEST']._serialized_end=1059 - _globals['_NODEINFORESPONSE']._serialized_start=1061 - _globals['_NODEINFORESPONSE']._serialized_end=1134 - _globals['_RECOVERYREQUEST']._serialized_start=1136 - _globals['_RECOVERYREQUEST']._serialized_end=1221 - _globals['_RECOVERYRESPONSE']._serialized_start=1223 - _globals['_RECOVERYRESPONSE']._serialized_end=1311 - _globals['_UPGRADEREQUEST']._serialized_start=1313 - _globals['_UPGRADEREQUEST']._serialized_end=1422 - _globals['_UPGRADERESPONSE']._serialized_start=1424 - _globals['_UPGRADERESPONSE']._serialized_end=1462 - _globals['_STARTUPMESSAGE']._serialized_start=1464 - _globals['_STARTUPMESSAGE']._serialized_end=1515 - _globals['_LISTINVITECODESREQUEST']._serialized_start=1517 - _globals['_LISTINVITECODESREQUEST']._serialized_end=1541 - _globals['_LISTINVITECODESRESPONSE']._serialized_start=1543 - _globals['_LISTINVITECODESRESPONSE']._serialized_end=1617 - _globals['_INVITECODE']._serialized_start=1619 - _globals['_INVITECODE']._serialized_end=1666 - _globals['_EXPORTNODEREQUEST']._serialized_start=1668 - _globals['_EXPORTNODEREQUEST']._serialized_end=1687 - _globals['_EXPORTNODERESPONSE']._serialized_start=1689 - _globals['_EXPORTNODERESPONSE']._serialized_end=1722 - _globals['_SIGNERREJECTION']._serialized_start=1724 - _globals['_SIGNERREJECTION']._serialized_end=1833 - _globals['_PAIRDEVICEREQUEST']._serialized_start=1835 - _globals['_PAIRDEVICEREQUEST']._serialized_end=1950 - _globals['_PAIRDEVICERESPONSE']._serialized_start=1952 - _globals['_PAIRDEVICERESPONSE']._serialized_end=2061 - _globals['_GETPAIRINGDATAREQUEST']._serialized_start=2063 - _globals['_GETPAIRINGDATAREQUEST']._serialized_end=2105 - _globals['_GETPAIRINGDATARESPONSE']._serialized_start=2107 - _globals['_GETPAIRINGDATARESPONSE']._serialized_end=2227 - _globals['_APPROVEPAIRINGREQUEST']._serialized_start=2230 - _globals['_APPROVEPAIRINGREQUEST']._serialized_end=2377 - _globals['_APPROVEPAIRINGRESPONSE']._serialized_start=2379 - _globals['_APPROVEPAIRINGRESPONSE']._serialized_end=2453 - _globals['_SIGNERREQUEST']._serialized_start=2455 - _globals['_SIGNERREQUEST']._serialized_end=2562 - _globals['_SIGNERRESPONSE']._serialized_start=2565 - _globals['_SIGNERRESPONSE']._serialized_end=2711 - _globals['_SCHEDULER']._serialized_start=2759 - _globals['_SCHEDULER']._serialized_end=3869 - _globals['_DEBUG']._serialized_start=3871 - _globals['_DEBUG']._serialized_end=3952 - _globals['_PAIRING']._serialized_start=3955 - _globals['_PAIRING']._serialized_end=4203 + _globals['_CHECKLIGHTNINGAVAILABILITYREQUEST']._serialized_start=644 + _globals['_CHECKLIGHTNINGAVAILABILITYREQUEST']._serialized_end=696 + _globals['_CHECKLIGHTNINGAVAILABILITYRESPONSE']._serialized_start=698 + _globals['_CHECKLIGHTNINGAVAILABILITYRESPONSE']._serialized_end=753 + _globals['_REGISTRATIONREQUEST']._serialized_start=756 + _globals['_REGISTRATIONREQUEST']._serialized_end=990 + _globals['_REGISTRATIONRESPONSE']._serialized_start=992 + _globals['_REGISTRATIONRESPONSE']._serialized_end=1084 + _globals['_SCHEDULEREQUEST']._serialized_start=1086 + _globals['_SCHEDULEREQUEST']._serialized_end=1120 + _globals['_NODEINFOREQUEST']._serialized_start=1122 + _globals['_NODEINFOREQUEST']._serialized_end=1170 + _globals['_NODEINFORESPONSE']._serialized_start=1172 + _globals['_NODEINFORESPONSE']._serialized_end=1245 + _globals['_RECOVERYREQUEST']._serialized_start=1247 + _globals['_RECOVERYREQUEST']._serialized_end=1332 + _globals['_RECOVERYRESPONSE']._serialized_start=1334 + _globals['_RECOVERYRESPONSE']._serialized_end=1422 + _globals['_UPGRADEREQUEST']._serialized_start=1424 + _globals['_UPGRADEREQUEST']._serialized_end=1533 + _globals['_UPGRADERESPONSE']._serialized_start=1535 + _globals['_UPGRADERESPONSE']._serialized_end=1573 + _globals['_STARTUPMESSAGE']._serialized_start=1575 + _globals['_STARTUPMESSAGE']._serialized_end=1626 + _globals['_LISTINVITECODESREQUEST']._serialized_start=1628 + _globals['_LISTINVITECODESREQUEST']._serialized_end=1652 + _globals['_LISTINVITECODESRESPONSE']._serialized_start=1654 + _globals['_LISTINVITECODESRESPONSE']._serialized_end=1728 + _globals['_INVITECODE']._serialized_start=1730 + _globals['_INVITECODE']._serialized_end=1777 + _globals['_EXPORTNODEREQUEST']._serialized_start=1779 + _globals['_EXPORTNODEREQUEST']._serialized_end=1798 + _globals['_EXPORTNODERESPONSE']._serialized_start=1800 + _globals['_EXPORTNODERESPONSE']._serialized_end=1833 + _globals['_SIGNERREJECTION']._serialized_start=1835 + _globals['_SIGNERREJECTION']._serialized_end=1944 + _globals['_PAIRDEVICEREQUEST']._serialized_start=1946 + _globals['_PAIRDEVICEREQUEST']._serialized_end=2061 + _globals['_PAIRDEVICERESPONSE']._serialized_start=2063 + _globals['_PAIRDEVICERESPONSE']._serialized_end=2172 + _globals['_GETPAIRINGDATAREQUEST']._serialized_start=2174 + _globals['_GETPAIRINGDATAREQUEST']._serialized_end=2216 + _globals['_GETPAIRINGDATARESPONSE']._serialized_start=2218 + _globals['_GETPAIRINGDATARESPONSE']._serialized_end=2338 + _globals['_APPROVEPAIRINGREQUEST']._serialized_start=2341 + _globals['_APPROVEPAIRINGREQUEST']._serialized_end=2488 + _globals['_APPROVEPAIRINGRESPONSE']._serialized_start=2490 + _globals['_APPROVEPAIRINGRESPONSE']._serialized_end=2564 + _globals['_SIGNERREQUEST']._serialized_start=2566 + _globals['_SIGNERREQUEST']._serialized_end=2673 + _globals['_SIGNERRESPONSE']._serialized_start=2676 + _globals['_SIGNERRESPONSE']._serialized_end=2822 + _globals['_SCHEDULER']._serialized_start=2870 + _globals['_SCHEDULER']._serialized_end=4105 + _globals['_DEBUG']._serialized_start=4107 + _globals['_DEBUG']._serialized_end=4188 + _globals['_PAIRING']._serialized_start=4191 + _globals['_PAIRING']._serialized_end=4439 # @@protoc_insertion_point(module_scope) diff --git a/libs/gl-client-py/glclient/scheduler_pb2.pyi b/libs/gl-client-py/glclient/scheduler_pb2.pyi index 507b0ec95..0e3c81e33 100644 --- a/libs/gl-client-py/glclient/scheduler_pb2.pyi +++ b/libs/gl-client-py/glclient/scheduler_pb2.pyi @@ -221,6 +221,44 @@ class ChallengeResponse(_message.Message): Global___ChallengeResponse: _TypeAlias = ChallengeResponse # noqa: Y015 +@_typing.final +class CheckLightningAvailabilityRequest(_message.Message): + DESCRIPTOR: _descriptor.Descriptor + + NODE_ID_FIELD_NUMBER: _builtins.int + node_id: _builtins.bytes + """33 bytes node public key. The node need not be registered + with greenlight yet. + """ + def __init__( + self, + *, + node_id: _builtins.bytes = ..., + ) -> None: ... + _ClearFieldArgType: _TypeAlias = _typing.Literal["node_id", b"node_id"] # noqa: Y015 + def ClearField(self, field_name: _ClearFieldArgType) -> None: ... + +Global___CheckLightningAvailabilityRequest: _TypeAlias = CheckLightningAvailabilityRequest # noqa: Y015 + +@_typing.final +class CheckLightningAvailabilityResponse(_message.Message): + DESCRIPTOR: _descriptor.Descriptor + + AVAILABLE_FIELD_NUMBER: _builtins.int + available: _builtins.bool + """Whether the Lightning account backed by this node may be + surfaced to the user. + """ + def __init__( + self, + *, + available: _builtins.bool = ..., + ) -> None: ... + _ClearFieldArgType: _TypeAlias = _typing.Literal["available", b"available"] # noqa: Y015 + def ClearField(self, field_name: _ClearFieldArgType) -> None: ... + +Global___CheckLightningAvailabilityResponse: _TypeAlias = CheckLightningAvailabilityResponse # noqa: Y015 + @_typing.final class RegistrationRequest(_message.Message): DESCRIPTOR: _descriptor.Descriptor diff --git a/libs/gl-client-py/glclient/scheduler_pb2_grpc.py b/libs/gl-client-py/glclient/scheduler_pb2_grpc.py index 97a4bd5bd..2d2f5bb84 100644 --- a/libs/gl-client-py/glclient/scheduler_pb2_grpc.py +++ b/libs/gl-client-py/glclient/scheduler_pb2_grpc.py @@ -50,8 +50,10 @@ class SchedulerStub(object): Users are authenticated using mTLS authentication. Applications are provisioned with an anonymous keypair that is not bound to a node, allowing access only to the unauthenticated endpoints - `Scheduler.GetChallenge`, `Scheduler.Register` and - `Scheduler.Recover`. This allows them to register or recover a + `Scheduler.GetChallenge`, `Scheduler.Register`, + `Scheduler.Recover` and + `Scheduler.CheckLightningAvailability`. This allows them to + register or recover a node, but doesn't give access to the node itself. Upon registering or recovering an account the user receives a keypair that is bound to the specific node. Once the user receives their personal mTLS @@ -83,6 +85,11 @@ def __init__(self, channel): request_serializer=glclient_dot_scheduler__pb2.ChallengeRequest.SerializeToString, response_deserializer=glclient_dot_scheduler__pb2.ChallengeResponse.FromString, _registered_method=True) + self.CheckLightningAvailability = channel.unary_unary( + '/scheduler.Scheduler/CheckLightningAvailability', + request_serializer=glclient_dot_scheduler__pb2.CheckLightningAvailabilityRequest.SerializeToString, + response_deserializer=glclient_dot_scheduler__pb2.CheckLightningAvailabilityResponse.FromString, + _registered_method=True) self.Schedule = channel.unary_unary( '/scheduler.Scheduler/Schedule', request_serializer=glclient_dot_scheduler__pb2.ScheduleRequest.SerializeToString, @@ -159,8 +166,10 @@ class SchedulerServicer(object): Users are authenticated using mTLS authentication. Applications are provisioned with an anonymous keypair that is not bound to a node, allowing access only to the unauthenticated endpoints - `Scheduler.GetChallenge`, `Scheduler.Register` and - `Scheduler.Recover`. This allows them to register or recover a + `Scheduler.GetChallenge`, `Scheduler.Register`, + `Scheduler.Recover` and + `Scheduler.CheckLightningAvailability`. This allows them to + register or recover a node, but doesn't give access to the node itself. Upon registering or recovering an account the user receives a keypair that is bound to the specific node. Once the user receives their personal mTLS @@ -228,6 +237,29 @@ def GetChallenge(self, request, context): context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') + def CheckLightningAvailability(self, request, context): + """Reports whether the Lightning account backed by `node_id` may + be surfaced to the user. This is a feature gate for downstream + applications: greenlight relays the question to its Lightning + Service Provider, which answers based on whether it has + previously granted this node a slot (grants are sticky) or has + the capacity to grant one now. + + Unlike the other node-scoped calls this one is deliberately + available *before* registration, since an application has to + decide whether to offer Lightning at all before it creates a + node. There is therefore no mTLS identity to derive the node + from, and the caller names the `node_id` it is asking about. + + The answer is advisory and may change: a node that is not + available today may become available once the LSP has capacity + again. Applications should treat an error as "unknown" rather + than as a negative answer. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + def Schedule(self, request, context): """Scheduling takes a previously registered node, locates a free slot in greenlight's infrastructure and allocates it @@ -369,6 +401,11 @@ def add_SchedulerServicer_to_server(servicer, server): request_deserializer=glclient_dot_scheduler__pb2.ChallengeRequest.FromString, response_serializer=glclient_dot_scheduler__pb2.ChallengeResponse.SerializeToString, ), + 'CheckLightningAvailability': grpc.unary_unary_rpc_method_handler( + servicer.CheckLightningAvailability, + request_deserializer=glclient_dot_scheduler__pb2.CheckLightningAvailabilityRequest.FromString, + response_serializer=glclient_dot_scheduler__pb2.CheckLightningAvailabilityResponse.SerializeToString, + ), 'Schedule': grpc.unary_unary_rpc_method_handler( servicer.Schedule, request_deserializer=glclient_dot_scheduler__pb2.ScheduleRequest.FromString, @@ -451,8 +488,10 @@ class Scheduler(object): Users are authenticated using mTLS authentication. Applications are provisioned with an anonymous keypair that is not bound to a node, allowing access only to the unauthenticated endpoints - `Scheduler.GetChallenge`, `Scheduler.Register` and - `Scheduler.Recover`. This allows them to register or recover a + `Scheduler.GetChallenge`, `Scheduler.Register`, + `Scheduler.Recover` and + `Scheduler.CheckLightningAvailability`. This allows them to + register or recover a node, but doesn't give access to the node itself. Upon registering or recovering an account the user receives a keypair that is bound to the specific node. Once the user receives their personal mTLS @@ -544,6 +583,33 @@ def GetChallenge(request, metadata, _registered_method=True) + @staticmethod + def CheckLightningAvailability(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary( + request, + target, + '/scheduler.Scheduler/CheckLightningAvailability', + glclient_dot_scheduler__pb2.CheckLightningAvailabilityRequest.SerializeToString, + glclient_dot_scheduler__pb2.CheckLightningAvailabilityResponse.FromString, + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + _registered_method=True) + @staticmethod def Schedule(request, target, diff --git a/libs/gl-client-py/glclient/scheduler_pb2_grpc.pyi b/libs/gl-client-py/glclient/scheduler_pb2_grpc.pyi index d2c12cfd6..fe39fd725 100644 --- a/libs/gl-client-py/glclient/scheduler_pb2_grpc.pyi +++ b/libs/gl-client-py/glclient/scheduler_pb2_grpc.pyi @@ -51,8 +51,10 @@ class SchedulerStub: Users are authenticated using mTLS authentication. Applications are provisioned with an anonymous keypair that is not bound to a node, allowing access only to the unauthenticated endpoints - `Scheduler.GetChallenge`, `Scheduler.Register` and - `Scheduler.Recover`. This allows them to register or recover a + `Scheduler.GetChallenge`, `Scheduler.Register`, + `Scheduler.Recover` and + `Scheduler.CheckLightningAvailability`. This allows them to + register or recover a node, but doesn't give access to the node itself. Upon registering or recovering an account the user receives a keypair that is bound to the specific node. Once the user receives their personal mTLS @@ -111,6 +113,25 @@ class SchedulerStub: or use a challenge with a different scope will result in an error being returned. """ + CheckLightningAvailability: _grpc.UnaryUnaryMultiCallable[_scheduler_pb2.CheckLightningAvailabilityRequest, _scheduler_pb2.CheckLightningAvailabilityResponse] + """Reports whether the Lightning account backed by `node_id` may + be surfaced to the user. This is a feature gate for downstream + applications: greenlight relays the question to its Lightning + Service Provider, which answers based on whether it has + previously granted this node a slot (grants are sticky) or has + the capacity to grant one now. + + Unlike the other node-scoped calls this one is deliberately + available *before* registration, since an application has to + decide whether to offer Lightning at all before it creates a + node. There is therefore no mTLS identity to derive the node + from, and the caller names the `node_id` it is asking about. + + The answer is advisory and may change: a node that is not + available today may become available once the LSP has capacity + again. Applications should treat an error as "unknown" rather + than as a negative answer. + """ Schedule: _grpc.UnaryUnaryMultiCallable[_scheduler_pb2.ScheduleRequest, _scheduler_pb2.NodeInfoResponse] """Scheduling takes a previously registered node, locates a free slot in greenlight's infrastructure and allocates it @@ -216,8 +237,10 @@ class SchedulerAsyncStub(SchedulerStub): Users are authenticated using mTLS authentication. Applications are provisioned with an anonymous keypair that is not bound to a node, allowing access only to the unauthenticated endpoints - `Scheduler.GetChallenge`, `Scheduler.Register` and - `Scheduler.Recover`. This allows them to register or recover a + `Scheduler.GetChallenge`, `Scheduler.Register`, + `Scheduler.Recover` and + `Scheduler.CheckLightningAvailability`. This allows them to + register or recover a node, but doesn't give access to the node itself. Upon registering or recovering an account the user receives a keypair that is bound to the specific node. Once the user receives their personal mTLS @@ -273,6 +296,25 @@ class SchedulerAsyncStub(SchedulerStub): or use a challenge with a different scope will result in an error being returned. """ + CheckLightningAvailability: _aio.UnaryUnaryMultiCallable[_scheduler_pb2.CheckLightningAvailabilityRequest, _scheduler_pb2.CheckLightningAvailabilityResponse] # type: ignore[assignment] + """Reports whether the Lightning account backed by `node_id` may + be surfaced to the user. This is a feature gate for downstream + applications: greenlight relays the question to its Lightning + Service Provider, which answers based on whether it has + previously granted this node a slot (grants are sticky) or has + the capacity to grant one now. + + Unlike the other node-scoped calls this one is deliberately + available *before* registration, since an application has to + decide whether to offer Lightning at all before it creates a + node. There is therefore no mTLS identity to derive the node + from, and the caller names the `node_id` it is asking about. + + The answer is advisory and may change: a node that is not + available today may become available once the LSP has capacity + again. Applications should treat an error as "unknown" rather + than as a negative answer. + """ Schedule: _aio.UnaryUnaryMultiCallable[_scheduler_pb2.ScheduleRequest, _scheduler_pb2.NodeInfoResponse] # type: ignore[assignment] """Scheduling takes a previously registered node, locates a free slot in greenlight's infrastructure and allocates it @@ -377,8 +419,10 @@ class SchedulerServicer(metaclass=_abc_1.ABCMeta): Users are authenticated using mTLS authentication. Applications are provisioned with an anonymous keypair that is not bound to a node, allowing access only to the unauthenticated endpoints - `Scheduler.GetChallenge`, `Scheduler.Register` and - `Scheduler.Recover`. This allows them to register or recover a + `Scheduler.GetChallenge`, `Scheduler.Register`, + `Scheduler.Recover` and + `Scheduler.CheckLightningAvailability`. This allows them to + register or recover a node, but doesn't give access to the node itself. Upon registering or recovering an account the user receives a keypair that is bound to the specific node. Once the user receives their personal mTLS @@ -451,6 +495,31 @@ class SchedulerServicer(metaclass=_abc_1.ABCMeta): error being returned. """ + @_abc_1.abstractmethod + def CheckLightningAvailability( + self, + request: _scheduler_pb2.CheckLightningAvailabilityRequest, + context: _ServicerContext, + ) -> _typing.Union[_scheduler_pb2.CheckLightningAvailabilityResponse, _abc.Awaitable[_scheduler_pb2.CheckLightningAvailabilityResponse]]: + """Reports whether the Lightning account backed by `node_id` may + be surfaced to the user. This is a feature gate for downstream + applications: greenlight relays the question to its Lightning + Service Provider, which answers based on whether it has + previously granted this node a slot (grants are sticky) or has + the capacity to grant one now. + + Unlike the other node-scoped calls this one is deliberately + available *before* registration, since an application has to + decide whether to offer Lightning at all before it creates a + node. There is therefore no mTLS identity to derive the node + from, and the caller names the `node_id` it is asking about. + + The answer is advisory and may change: a node that is not + available today may become available once the LSP has capacity + again. Applications should treat an error as "unknown" rather + than as a negative answer. + """ + @_abc_1.abstractmethod def Schedule( self, diff --git a/libs/gl-client-py/pyproject.toml b/libs/gl-client-py/pyproject.toml index 38211de61..ac67a08f3 100644 --- a/libs/gl-client-py/pyproject.toml +++ b/libs/gl-client-py/pyproject.toml @@ -5,7 +5,7 @@ description = "" readme = "README.md" requires-python = ">=3.8,<4" dependencies = [ - "protobuf>=6", + "protobuf>=6,<7", "pyln-grpc-proto>=0.1", ] authors = [ @@ -27,7 +27,7 @@ dev = [ "mypy>=1.14.1", "mypy-protobuf>=3.6.0", "patchelf>=0.17.2.2", - "protobuf>=6", + "protobuf>=6,<7", "pyln-grpc-proto>=0.1.2", "python-kacl>=0.6.7", "types-protobuf>=5.29.1.20241207", diff --git a/libs/gl-client/.resources/proto/glclient/scheduler.proto b/libs/gl-client/.resources/proto/glclient/scheduler.proto index 3bb15f32e..73880cd8c 100644 --- a/libs/gl-client/.resources/proto/glclient/scheduler.proto +++ b/libs/gl-client/.resources/proto/glclient/scheduler.proto @@ -26,8 +26,10 @@ import "glclient/greenlight.proto"; // Users are authenticated using mTLS authentication. Applications are // provisioned with an anonymous keypair that is not bound to a node, // allowing access only to the unauthenticated endpoints -// `Scheduler.GetChallenge`, `Scheduler.Register` and -// `Scheduler.Recover`. This allows them to register or recover a +// `Scheduler.GetChallenge`, `Scheduler.Register`, +// `Scheduler.Recover` and +// `Scheduler.CheckLightningAvailability`. This allows them to +// register or recover a // node, but doesn't give access to the node itself. Upon registering // or recovering an account the user receives a keypair that is bound // to the specific node. Once the user receives their personal mTLS @@ -82,6 +84,25 @@ service Scheduler { // error being returned. rpc GetChallenge(ChallengeRequest) returns (ChallengeResponse) {} + // Reports whether the Lightning account backed by `node_id` may + // be surfaced to the user. This is a feature gate for downstream + // applications: greenlight relays the question to its Lightning + // Service Provider, which answers based on whether it has + // previously granted this node a slot (grants are sticky) or has + // the capacity to grant one now. + // + // Unlike the other node-scoped calls this one is deliberately + // available *before* registration, since an application has to + // decide whether to offer Lightning at all before it creates a + // node. There is therefore no mTLS identity to derive the node + // from, and the caller names the `node_id` it is asking about. + // + // The answer is advisory and may change: a node that is not + // available today may become available once the LSP has capacity + // again. Applications should treat an error as "unknown" rather + // than as a negative answer. + rpc CheckLightningAvailability(CheckLightningAvailabilityRequest) returns (CheckLightningAvailabilityResponse) {} + // Scheduling takes a previously registered node, locates a // free slot in greenlight's infrastructure and allocates it // to run the node. The node then goes through the startup @@ -248,6 +269,18 @@ enum ChallengeScope { RECOVER = 1; } +message CheckLightningAvailabilityRequest { + // 33 bytes node public key. The node need not be registered + // with greenlight yet. + bytes node_id = 1; +}; + +message CheckLightningAvailabilityResponse { + // Whether the Lightning account backed by this node may be + // surfaced to the user. + bool available = 1; +}; + message RegistrationRequest { // 33 bytes node public key. bytes node_id = 1; diff --git a/libs/gl-client/CHANGELOG.md b/libs/gl-client/CHANGELOG.md index 098d31659..301ac9440 100644 --- a/libs/gl-client/CHANGELOG.md +++ b/libs/gl-client/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Unreleased +### Added + +- `Scheduler::check_lightning_availability(node_id)` and the corresponding `Scheduler.CheckLightningAvailability` RPC — reports whether the Lightning account backed by `node_id` may be surfaced to the user. Unauthenticated and callable before the node is registered, so the `node_id` is passed explicitly rather than taken from the credentials. + ### Changed - Signer version updated from `v25.12` to `v26.06` (VLS 0.14.0 / CLN v26.06.1) diff --git a/libs/gl-client/src/scheduler.rs b/libs/gl-client/src/scheduler.rs index 8a5f68724..41d45d1d9 100644 --- a/libs/gl-client/src/scheduler.rs +++ b/libs/gl-client/src/scheduler.rs @@ -97,6 +97,38 @@ where } impl Scheduler { + /// Asks whether the Lightning account backed by `node_id` may be + /// surfaced to the user. + /// + /// This is a feature gate for applications that offer Lightning + /// alongside other account types: greenlight relays the question + /// to its Lightning Service Provider, which answers based on + /// whether it has previously granted this node a slot, or has the + /// capacity to grant one now. + /// + /// Unlike the other node-scoped calls this one does not require + /// the node to be registered, and does not require authenticated + /// credentials, since an application has to decide whether to + /// offer Lightning before it creates a node. The `node_id` is + /// therefore passed explicitly rather than taken from the + /// credentials. + /// + /// The answer is advisory and may change over time. Treat an + /// error as "unknown" rather than as a negative answer. + pub async fn check_lightning_availability( + &self, + node_id: Vec, + ) -> Result { + let res = self + .client + .clone() + .check_lightning_availability(pb::scheduler::CheckLightningAvailabilityRequest { + node_id, + }) + .await?; + Ok(res.into_inner()) + } + /// Registers a new node with the scheduler service. /// /// # Arguments diff --git a/libs/gl-sdk/CHANGELOG.md b/libs/gl-sdk/CHANGELOG.md index 2a3830326..d60373474 100644 --- a/libs/gl-sdk/CHANGELOG.md +++ b/libs/gl-sdk/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Unreleased +### Added + +- `Scheduler.lightning_available(node_id)` — asks whether the Lightning account backed by `node_id` may be surfaced to the user. Intended as a feature gate for applications that offer Lightning alongside other account types. Callable before `register()` and without credentials, since the decision has to be made before a node exists. The answer is advisory; treat an error as "unknown" rather than as a negative answer. Greenlight currently reports every account as unavailable while the backing Lightning Service Provider integration is being built. + ## [0.4.0] - 2026-05-21 ### Added diff --git a/libs/gl-sdk/bindings/glsdk.swift b/libs/gl-sdk/bindings/glsdk.swift index bf1f5d475..b10a33f9c 100644 --- a/libs/gl-sdk/bindings/glsdk.swift +++ b/libs/gl-sdk/bindings/glsdk.swift @@ -2320,6 +2320,26 @@ public func FfiConverterTypeNodeEventStream_lower(_ value: NodeEventStream) -> U public protocol SchedulerProtocol: AnyObject, Sendable { + /** + * Asks whether the Lightning account backed by `node_id` may be + * surfaced to the user. + * + * This is a feature gate for applications that offer Lightning + * alongside other account types. Greenlight relays the question + * to its Lightning Service Provider, which answers based on + * whether it has previously granted this node a slot, or has the + * capacity to grant one now. + * + * Deliberately callable before `register()`, since an + * application has to decide whether to offer Lightning at all + * before it creates a node. It needs no credentials, and the + * `node_id` is passed explicitly. + * + * The answer is advisory and may change over time. Treat an + * error as "unknown" rather than as a negative answer. + */ + func lightningAvailable(nodeId: Data) throws -> Bool + func recover(signer: Signer) throws -> Credentials func register(signer: Signer, code: String?) throws -> Credentials @@ -2399,6 +2419,32 @@ public convenience init(network: Network)throws { + /** + * Asks whether the Lightning account backed by `node_id` may be + * surfaced to the user. + * + * This is a feature gate for applications that offer Lightning + * alongside other account types. Greenlight relays the question + * to its Lightning Service Provider, which answers based on + * whether it has previously granted this node a slot, or has the + * capacity to grant one now. + * + * Deliberately callable before `register()`, since an + * application has to decide whether to offer Lightning at all + * before it creates a node. It needs no credentials, and the + * `node_id` is passed explicitly. + * + * The answer is advisory and may change over time. Treat an + * error as "unknown" rather than as a negative answer. + */ +open func lightningAvailable(nodeId: Data)throws -> Bool { + return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeError_lift) { + uniffi_glsdk_fn_method_scheduler_lightning_available(self.uniffiClonePointer(), + FfiConverterData.lower(nodeId),$0 + ) +}) +} + open func recover(signer: Signer)throws -> Credentials { return try FfiConverterTypeCredentials_lift(try rustCallWithError(FfiConverterTypeError_lift) { uniffi_glsdk_fn_method_scheduler_recover(self.uniffiClonePointer(), @@ -9674,6 +9720,9 @@ private let initializationResult: InitializationResult = { if (uniffi_glsdk_checksum_method_nodeeventstream_next() != 12635) { return InitializationResult.apiChecksumMismatch } + if (uniffi_glsdk_checksum_method_scheduler_lightning_available() != 7327) { + return InitializationResult.apiChecksumMismatch + } if (uniffi_glsdk_checksum_method_scheduler_recover() != 55514) { return InitializationResult.apiChecksumMismatch } diff --git a/libs/gl-sdk/bindings/glsdkFFI.h b/libs/gl-sdk/bindings/glsdkFFI.h index 17533ab28..327e93234 100644 --- a/libs/gl-sdk/bindings/glsdkFFI.h +++ b/libs/gl-sdk/bindings/glsdkFFI.h @@ -552,6 +552,11 @@ void uniffi_glsdk_fn_free_scheduler(void*_Nonnull ptr, RustCallStatus *_Nonnull void*_Nonnull uniffi_glsdk_fn_constructor_scheduler_new(RustBuffer network, RustCallStatus *_Nonnull out_status ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_GLSDK_FN_METHOD_SCHEDULER_LIGHTNING_AVAILABLE +#define UNIFFI_FFIDEF_UNIFFI_GLSDK_FN_METHOD_SCHEDULER_LIGHTNING_AVAILABLE +int8_t uniffi_glsdk_fn_method_scheduler_lightning_available(void*_Nonnull ptr, RustBuffer node_id, RustCallStatus *_Nonnull out_status +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_GLSDK_FN_METHOD_SCHEDULER_RECOVER #define UNIFFI_FFIDEF_UNIFFI_GLSDK_FN_METHOD_SCHEDULER_RECOVER void*_Nonnull uniffi_glsdk_fn_method_scheduler_recover(void*_Nonnull ptr, void*_Nonnull signer, RustCallStatus *_Nonnull out_status @@ -1132,6 +1137,12 @@ uint16_t uniffi_glsdk_checksum_method_nodebuilder_with_event_listener(void #define UNIFFI_FFIDEF_UNIFFI_GLSDK_CHECKSUM_METHOD_NODEEVENTSTREAM_NEXT uint16_t uniffi_glsdk_checksum_method_nodeeventstream_next(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_GLSDK_CHECKSUM_METHOD_SCHEDULER_LIGHTNING_AVAILABLE +#define UNIFFI_FFIDEF_UNIFFI_GLSDK_CHECKSUM_METHOD_SCHEDULER_LIGHTNING_AVAILABLE +uint16_t uniffi_glsdk_checksum_method_scheduler_lightning_available(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_GLSDK_CHECKSUM_METHOD_SCHEDULER_RECOVER diff --git a/libs/gl-sdk/bindings/uniffi/glsdk/glsdk.kt b/libs/gl-sdk/bindings/uniffi/glsdk/glsdk.kt index dd17f6af0..f09b505e9 100644 --- a/libs/gl-sdk/bindings/uniffi/glsdk/glsdk.kt +++ b/libs/gl-sdk/bindings/uniffi/glsdk/glsdk.kt @@ -869,6 +869,8 @@ internal open class UniffiVTableCallbackInterfaceNodeEventListener( + + @@ -961,6 +963,8 @@ fun uniffi_glsdk_checksum_method_nodebuilder_with_event_listener( ): Short fun uniffi_glsdk_checksum_method_nodeeventstream_next( ): Short +fun uniffi_glsdk_checksum_method_scheduler_lightning_available( +): Short fun uniffi_glsdk_checksum_method_scheduler_recover( ): Short fun uniffi_glsdk_checksum_method_scheduler_register( @@ -1150,6 +1154,8 @@ fun uniffi_glsdk_fn_free_scheduler(`ptr`: Pointer,uniffi_out_err: UniffiRustCall ): Unit fun uniffi_glsdk_fn_constructor_scheduler_new(`network`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, ): Pointer +fun uniffi_glsdk_fn_method_scheduler_lightning_available(`ptr`: Pointer,`nodeId`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, +): Byte fun uniffi_glsdk_fn_method_scheduler_recover(`ptr`: Pointer,`signer`: Pointer,uniffi_out_err: UniffiRustCallStatus, ): Pointer fun uniffi_glsdk_fn_method_scheduler_register(`ptr`: Pointer,`signer`: Pointer,`code`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus, @@ -1419,6 +1425,9 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) { if (lib.uniffi_glsdk_checksum_method_nodeeventstream_next() != 12635.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_glsdk_checksum_method_scheduler_lightning_available() != 7327.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_glsdk_checksum_method_scheduler_recover() != 55514.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -4608,6 +4617,26 @@ public object FfiConverterTypeNodeEventStream: FfiConverter + UniffiLib.INSTANCE.uniffi_glsdk_fn_method_scheduler_lightning_available( + it, FfiConverterByteArray.lower(`nodeId`),_status) +} + } + ) + } + + + @Throws(Exception::class)override fun `recover`(`signer`: Signer): Credentials { return FfiConverterTypeCredentials.lift( callWithPointer { diff --git a/libs/gl-sdk/glsdk/glsdk.py b/libs/gl-sdk/glsdk/glsdk.py index 2be7cebb5..86b90b14e 100644 --- a/libs/gl-sdk/glsdk/glsdk.py +++ b/libs/gl-sdk/glsdk/glsdk.py @@ -534,6 +534,8 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_glsdk_checksum_method_nodeeventstream_next() != 12635: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_glsdk_checksum_method_scheduler_lightning_available() != 7327: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_glsdk_checksum_method_scheduler_recover() != 55514: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_glsdk_checksum_method_scheduler_register() != 20821: @@ -994,6 +996,12 @@ class _UniffiVTableCallbackInterfaceNodeEventListener(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_glsdk_fn_constructor_scheduler_new.restype = ctypes.c_void_p +_UniffiLib.uniffi_glsdk_fn_method_scheduler_lightning_available.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_glsdk_fn_method_scheduler_lightning_available.restype = ctypes.c_int8 _UniffiLib.uniffi_glsdk_fn_method_scheduler_recover.argtypes = ( ctypes.c_void_p, ctypes.c_void_p, @@ -1457,6 +1465,9 @@ class _UniffiVTableCallbackInterfaceNodeEventListener(ctypes.Structure): _UniffiLib.uniffi_glsdk_checksum_method_nodeeventstream_next.argtypes = ( ) _UniffiLib.uniffi_glsdk_checksum_method_nodeeventstream_next.restype = ctypes.c_uint16 +_UniffiLib.uniffi_glsdk_checksum_method_scheduler_lightning_available.argtypes = ( +) +_UniffiLib.uniffi_glsdk_checksum_method_scheduler_lightning_available.restype = ctypes.c_uint16 _UniffiLib.uniffi_glsdk_checksum_method_scheduler_recover.argtypes = ( ) _UniffiLib.uniffi_glsdk_checksum_method_scheduler_recover.restype = ctypes.c_uint16 @@ -8589,6 +8600,27 @@ def read(cls, buf: _UniffiRustBuffer): def write(cls, value: NodeEventStreamProtocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) class SchedulerProtocol(typing.Protocol): + def lightning_available(self, node_id: "bytes"): + """ + Asks whether the Lightning account backed by `node_id` may be + surfaced to the user. + + This is a feature gate for applications that offer Lightning + alongside other account types. Greenlight relays the question + to its Lightning Service Provider, which answers based on + whether it has previously granted this node a slot, or has the + capacity to grant one now. + + Deliberately callable before `register()`, since an + application has to decide whether to offer Lightning at all + before it creates a node. It needs no credentials, and the + `node_id` is passed explicitly. + + The answer is advisory and may change over time. Treat an + error as "unknown" rather than as a negative answer. + """ + + raise NotImplementedError def recover(self, signer: "Signer"): raise NotImplementedError def register(self, signer: "Signer",code: "typing.Optional[str]"): @@ -8637,6 +8669,37 @@ def _make_instance_(cls, pointer): return inst + def lightning_available(self, node_id: "bytes") -> "bool": + """ + Asks whether the Lightning account backed by `node_id` may be + surfaced to the user. + + This is a feature gate for applications that offer Lightning + alongside other account types. Greenlight relays the question + to its Lightning Service Provider, which answers based on + whether it has previously granted this node a slot, or has the + capacity to grant one now. + + Deliberately callable before `register()`, since an + application has to decide whether to offer Lightning at all + before it creates a node. It needs no credentials, and the + `node_id` is passed explicitly. + + The answer is advisory and may change over time. Treat an + error as "unknown" rather than as a negative answer. + """ + + _UniffiConverterBytes.check_lower(node_id) + + return _UniffiConverterBool.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypeError,_UniffiLib.uniffi_glsdk_fn_method_scheduler_lightning_available,self._uniffi_clone_pointer(), + _UniffiConverterBytes.lower(node_id)) + ) + + + + + def recover(self, signer: "Signer") -> "Credentials": _UniffiConverterTypeSigner.check_lower(signer) diff --git a/libs/gl-sdk/src/scheduler.rs b/libs/gl-sdk/src/scheduler.rs index c31a70256..a2090f5d4 100644 --- a/libs/gl-sdk/src/scheduler.rs +++ b/libs/gl-sdk/src/scheduler.rs @@ -52,6 +52,38 @@ impl Scheduler { } } + /// Asks whether the Lightning account backed by `node_id` may be + /// surfaced to the user. + /// + /// This is a feature gate for applications that offer Lightning + /// alongside other account types. Greenlight relays the question + /// to its Lightning Service Provider, which answers based on + /// whether it has previously granted this node a slot, or has the + /// capacity to grant one now. + /// + /// Deliberately callable before `register()`, since an + /// application has to decide whether to offer Lightning at all + /// before it creates a node. It needs no credentials, and the + /// `node_id` is passed explicitly. + /// + /// The answer is advisory and may change over time. Treat an + /// error as "unknown" rather than as a negative answer. + pub fn lightning_available(&self, node_id: Vec) -> Result { + let nobody = self.nobody(); + exec(async move { + let inner = gl_client::scheduler::Scheduler::new(self.network, nobody) + .await + .map_err(|e| Error::other(e.to_string()))?; + + let res = inner + .check_lightning_availability(node_id) + .await + .map_err(|e| Error::rpc(e.to_string()))?; + + Ok(res.available) + }) + } + pub fn register(&self, signer: &Signer, code: Option) -> Result { let nobody = self.nobody(); exec(async move { diff --git a/libs/gl-testing/Makefile b/libs/gl-testing/Makefile index 1f6b6d5d5..4b51d3739 100644 --- a/libs/gl-testing/Makefile +++ b/libs/gl-testing/Makefile @@ -22,8 +22,17 @@ check-testing-py: #cd ${TESTINGDIR}; mypy gltesting cd ${TESTINGDIR}; poetry install --with=dev; poetry run pytest tests -n 4 -vvv +# Pinned and isolated for the same reason as gl-client-py's PROTOC_TOOLCHAIN: +# the generated stubs must not depend on whose venv produced them. Keep the +# grpcio-tools version in step with that one. +TESTPROTOC_TOOLCHAIN = \ + uv run --no-project \ + --with grpcio-tools==1.78.0 \ + --with purerpc \ + python -m grpc_tools.protoc + testgrpc: ${REPO_ROOT}/libs/proto/glclient/scheduler.proto - python -m grpc_tools.protoc ${TESTPROTOC_OPTS} glclient/scheduler.proto + ${TESTPROTOC_TOOLCHAIN} ${TESTPROTOC_OPTS} glclient/scheduler.proto mv ${TESTINGDIR}/gltesting/glclient/scheduler_grpc.py ${TESTINGDIR}/gltesting/scheduler_grpc.py rm -rf ${TESTINGDIR}/gltesting/glclient diff --git a/libs/gl-testing/gltesting/scheduler.py b/libs/gl-testing/gltesting/scheduler.py index 97b43c67d..36ebd858d 100644 --- a/libs/gl-testing/gltesting/scheduler.py +++ b/libs/gl-testing/gltesting/scheduler.py @@ -87,6 +87,9 @@ def __init__( self.versions = enumerate_cln_versions() self.bitcoind = bitcoind self.invite_codes: List[str] = [] + # Answer given to CheckLightningAvailability. Defaults to the + # production behaviour while no LSP is wired up: unavailable. + self.lightning_available: bool = False self.next_webhook_id: int = 1 self.received_invite_code = None self.debugger = DebugServicer() @@ -365,6 +368,16 @@ async def ListInviteCodes(self, req) -> schedpb.ListInviteCodesResponse: codes = [schedpb.InviteCode(**c) for c in self.invite_codes] return schedpb.ListInviteCodesResponse(invite_code_list=codes) + async def CheckLightningAvailability( + self, req + ) -> schedpb.CheckLightningAvailabilityResponse: + # Mirrors the real scheduler, which relays this to an LSP and + # reports unavailable while none is configured. Tests that care + # flip `lightning_available` on the fixture. + return schedpb.CheckLightningAvailabilityResponse( + available=self.lightning_available + ) + async def add_outgoing_webhook(self, req) -> schedpb.AddOutgoingWebhookResponse: n = self.get_node(req.node_id) secret = generate_secret() diff --git a/libs/gl-testing/gltesting/scheduler_grpc.py b/libs/gl-testing/gltesting/scheduler_grpc.py index d3220e865..39fa9ed80 100644 --- a/libs/gl-testing/gltesting/scheduler_grpc.py +++ b/libs/gl-testing/gltesting/scheduler_grpc.py @@ -13,6 +13,9 @@ async def Recover(self, input_message): async def GetChallenge(self, input_message): raise NotImplementedError() + async def CheckLightningAvailability(self, input_message): + raise NotImplementedError() + async def Schedule(self, input_message): raise NotImplementedError() @@ -75,6 +78,15 @@ def service(self) -> purerpc.Service: glclient_dot_scheduler__pb2.ChallengeResponse, ) ) + service_obj.add_method( + "CheckLightningAvailability", + self.CheckLightningAvailability, + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.CheckLightningAvailabilityRequest, + glclient_dot_scheduler__pb2.CheckLightningAvailabilityResponse, + ) + ) service_obj.add_method( "Schedule", self.Schedule, @@ -198,6 +210,14 @@ def __init__(self, channel): glclient_dot_scheduler__pb2.ChallengeResponse, ) ) + self.CheckLightningAvailability = self._client.get_method_stub( + "CheckLightningAvailability", + purerpc.RPCSignature( + purerpc.Cardinality.UNARY_UNARY, + glclient_dot_scheduler__pb2.CheckLightningAvailabilityRequest, + glclient_dot_scheduler__pb2.CheckLightningAvailabilityResponse, + ) + ) self.Schedule = self._client.get_method_stub( "Schedule", purerpc.RPCSignature( diff --git a/libs/proto/glclient/scheduler.proto b/libs/proto/glclient/scheduler.proto index 3bb15f32e..73880cd8c 100644 --- a/libs/proto/glclient/scheduler.proto +++ b/libs/proto/glclient/scheduler.proto @@ -26,8 +26,10 @@ import "glclient/greenlight.proto"; // Users are authenticated using mTLS authentication. Applications are // provisioned with an anonymous keypair that is not bound to a node, // allowing access only to the unauthenticated endpoints -// `Scheduler.GetChallenge`, `Scheduler.Register` and -// `Scheduler.Recover`. This allows them to register or recover a +// `Scheduler.GetChallenge`, `Scheduler.Register`, +// `Scheduler.Recover` and +// `Scheduler.CheckLightningAvailability`. This allows them to +// register or recover a // node, but doesn't give access to the node itself. Upon registering // or recovering an account the user receives a keypair that is bound // to the specific node. Once the user receives their personal mTLS @@ -82,6 +84,25 @@ service Scheduler { // error being returned. rpc GetChallenge(ChallengeRequest) returns (ChallengeResponse) {} + // Reports whether the Lightning account backed by `node_id` may + // be surfaced to the user. This is a feature gate for downstream + // applications: greenlight relays the question to its Lightning + // Service Provider, which answers based on whether it has + // previously granted this node a slot (grants are sticky) or has + // the capacity to grant one now. + // + // Unlike the other node-scoped calls this one is deliberately + // available *before* registration, since an application has to + // decide whether to offer Lightning at all before it creates a + // node. There is therefore no mTLS identity to derive the node + // from, and the caller names the `node_id` it is asking about. + // + // The answer is advisory and may change: a node that is not + // available today may become available once the LSP has capacity + // again. Applications should treat an error as "unknown" rather + // than as a negative answer. + rpc CheckLightningAvailability(CheckLightningAvailabilityRequest) returns (CheckLightningAvailabilityResponse) {} + // Scheduling takes a previously registered node, locates a // free slot in greenlight's infrastructure and allocates it // to run the node. The node then goes through the startup @@ -248,6 +269,18 @@ enum ChallengeScope { RECOVER = 1; } +message CheckLightningAvailabilityRequest { + // 33 bytes node public key. The node need not be registered + // with greenlight yet. + bytes node_id = 1; +}; + +message CheckLightningAvailabilityResponse { + // Whether the Lightning account backed by this node may be + // surfaced to the user. + bool available = 1; +}; + message RegistrationRequest { // 33 bytes node public key. bytes node_id = 1;