Skip to content

Commit

Permalink
rpcserver+poolrpc: add ListSidecars and CancelSidecar RPCs
Browse files Browse the repository at this point in the history
With this commit we add two new RPCs for handling sidecar tickets.
ListSidecars will show all sidecar tickets known to the local database,
including those where our node is on the receiving end of a sidecar
channel.
CancelSidecar will cancel a specific sidecar ticket. If an order was
created for it, that bid order will be canceled. Doing so will make sure
the ticket isn't executed any further.
  • Loading branch information
guggero committed Sep 29, 2021
1 parent 7b2d457 commit e111fac
Show file tree
Hide file tree
Showing 7 changed files with 835 additions and 254 deletions.
8 changes: 8 additions & 0 deletions macaroons.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ var (
Entity: "order",
Action: "read",
}},
"/poolrpc.Trader/ListSidecars": {{
Entity: "order",
Action: "read",
}},
"/poolrpc.Trader/CancelSidecar": {{
Entity: "order",
Action: "write",
}},
}

// allPermissions is the list of all existing permissions that exist
Expand Down
773 changes: 522 additions & 251 deletions poolrpc/trader.pb.go

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions poolrpc/trader.pb.json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 43 additions & 1 deletion poolrpc/trader.proto
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,25 @@ service Trader {
rpc ExpectSidecarChannel (ExpectSidecarChannelRequest)
returns (ExpectSidecarChannelResponse);

/* pool: `sidecar decodeticket`
/* pool: `sidecar printticket`
Decodes the base58 encoded sidecar ticket into its individual data fields
for a more human-readable representation.
*/
rpc DecodeSidecarTicket (SidecarTicket) returns (DecodedSidecarTicket);

/* pool: `sidecar list`
ListSidecars lists all sidecar tickets currently in the local database. This
includes tickets offered by our node as well as tickets that our node is the
recipient of. Optionally a ticket ID can be provided to filter the tickets.
*/
rpc ListSidecars (ListSidecarsRequest) returns (ListSidecarsResponse);

/* pool: `sidecar cancel`
CancelSidecar cancels the execution of a specific sidecar ticket. Depending
on the state of the sidecar ticket its associated bid order might be
canceled as well (if this ticket was offered by our node).
*/
rpc CancelSidecar (CancelSidecarRequest) returns (CancelSidecarResponse);
}

message InitAccountRequest {
Expand Down Expand Up @@ -1232,3 +1246,31 @@ message ExpectSidecarChannelRequest {

message ExpectSidecarChannelResponse {
}

message ListSidecarsRequest {
/*
The optional sidecar ID to filter for. If set, the result should either be
a single ticket or no ticket in most cases. But because the ID is just 8
bytes and is randomly generated, there could be collisions, especially since
tickets can also be crafted by a malicious party and given to any node.
That's why the offer's public key is also used as an identifying element
since that cannot easily be forged without also producing a valid signature.
So an attacker cannot overwrite a ticket a node offered by themselves
offering a ticket with the same ID and tricking the victim into registering
that. Long story sort, there could be multiple tickets with the same ID but
different offer public keys, which is why those keys should be checked as
well.
*/
bytes sidecar_id = 1;
}

message ListSidecarsResponse {
repeated DecodedSidecarTicket tickets = 1;
}

message CancelSidecarRequest {
bytes sidecar_id = 1;
}

message CancelSidecarResponse {
}
14 changes: 14 additions & 0 deletions poolrpc/trader.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,9 @@
"poolrpcCancelOrderResponse": {
"type": "object"
},
"poolrpcCancelSidecarResponse": {
"type": "object"
},
"poolrpcCloseAccountResponse": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1663,6 +1666,17 @@
}
}
},
"poolrpcListSidecarsResponse": {
"type": "object",
"properties": {
"tickets": {
"type": "array",
"items": {
"$ref": "#/definitions/poolrpcDecodedSidecarTicket"
}
}
}
},
"poolrpcLsatToken": {
"type": "object",
"properties": {
Expand Down
92 changes: 90 additions & 2 deletions poolrpc/trader_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e111fac

Please sign in to comment.