Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gohumble committed May 3, 2024
0 parents commit 8e5a31d
Show file tree
Hide file tree
Showing 14 changed files with 337 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
13 changes: 13 additions & 0 deletions buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: a51f4a87c68c47f9901f3892e1ac4a0b
digest: shake256:7149cf5e9955c692d381e557830555d4e93f205a0f1b8e2dfdae46d029369aa3fc1980e35df0d310f7cc3b622f93e19ad276769a283a967dd3065ddfd3a40e13
- remote: buf.build
owner: srikrsna
repository: protoc-gen-gotag
commit: 7a85d3ad2e7642c198480e92bf730c14
digest: shake256:059f136681cd47abe2d6e83d20b9594071c481572d16cebfafbc81ba3d3e7924aef6974f99da53d67a01d033e30b7bf57985a206b4e856fc82508545de84a70c
11 changes: 11 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: v1
name: buf.build/cashu/rpc
breaking:
use:
- FILE
lint:
use:
- DEFAULT
deps:
- buf.build/googleapis/googleapis
- buf.build/srikrsna/protoc-gen-gotag
85 changes: 85 additions & 0 deletions cashu.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
syntax = "proto3";

package cashu.v1;
option go_package = "github.com/cashu/rpc/cashu";

import "keys.proto";
import "swap.proto";
import "mint.proto";
import "melt.proto";
import "state.proto";
import "info.proto";
import "google/api/annotations.proto";




service Mint {
// Starting https://github.com/cashubtc/nuts/blob/main/01.md
rpc Keys(KeysRequest) returns (KeysResponse){
option (google.api.http) = {
get: "/v1/keys"
};
};
// Starting https://github.com/cashubtc/nuts/blob/main/02.md
rpc KeySets(KeysRequest) returns (KeysResponse){
option (google.api.http) = {
get: "/v1/keysets"
};
};
// Starting https://github.com/cashubtc/nuts/blob/main/03.md
rpc Swap(SwapRequest) returns (SwapResponse){
option (google.api.http) = {
post: "/v1/swap"
body: "*"
};
};
// Starting https://github.com/cashubtc/nuts/blob/main/05.md
rpc MintQuote(PostMintQuoteBolt11Request) returns (PostMintQuoteBolt11Response){
option (google.api.http) = {
post: "/v1/mint/quote/bolt11"
body: "*"
};
};
rpc MintQuoteState(GetQuoteBolt11StateRequest) returns (PostMintQuoteBolt11Response){
option (google.api.http) = {
get: "/v1/mint/quote/bolt11/{quote_id}"
};
};
rpc Mint(PostMintBolt11Request) returns (PostMintBolt11Response){
option (google.api.http) = {
post: "/v1/mint/bolt11"
body: "*"
};
};
// Starting https://github.com/cashubtc/nuts/blob/main/05.md
rpc MeltQuote(PostMeltQuoteBolt11Request) returns (PostMeltQuoteBolt11Response){
option (google.api.http) = {
post: "/v1/melt/quote/bolt11"
body: "*"
};
};
rpc MeltQuoteState(GetQuoteBolt11StateRequest) returns (PostMeltQuoteBolt11Response){
option (google.api.http) = {
get: "/v1/melt/quote/bolt11/{quote_id}"
};
};
rpc Melt(PostMeltBolt11Request) returns (PostMeltBolt11Response){
option (google.api.http) = {
post: "/v1/melt/bolt11"
body: "*"
};
};
// Starting https://github.com/cashubtc/nuts/blob/main/06.md
rpc Info(InfoRequest) returns (InfoResponse){
option (google.api.http) = {
get: "/v1/info"
};
};
// Starting https://github.com/cashubtc/nuts/blob/main/07.md
rpc CheckState(PostCheckStateRequest) returns (PostCheckStateResponse){
option (google.api.http) = {
post: "/v1/checkstate"
};
};
}
47 changes: 47 additions & 0 deletions info.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
syntax = "proto3";
package cashu.v1;
option go_package = "github.com/cashu/rpc/info";
enum MethodType {
BOLT11 = 0;
SAT = 1;
// add more if needed
}

enum ContactType {
EMAIL = 0;
TWITTER = 1;
NOSTR = 2;
}

message NutDetails {
repeated MethodType methods = 1;
bool disabled = 2;
bool supported = 3;
}

message Nut {
int32 id = 1;
NutDetails nutDetails = 2;
}

message Contact {
ContactType type = 1;
string info = 2;
}

message InfoRequest {

}
message InfoResponse {
string name = 1;
string pubkey = 2;
string version = 3;
string description = 4;
string description_long = 5;
repeated string contact = 6;
string motd = 7;
map<int32, NutDetails> nuts = 8;
}



20 changes: 20 additions & 0 deletions keys.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";
import "tagger/tagger.proto";
package cashu.v1;
option go_package = "github.com/cashu/rpc/keys";


message KeysResponse{
repeated Keyset keysets = 1 [(tagger.tags) = "json:\"keysets\""];
}
message KeysRequest{

}

message Keyset {
string id = 1;
string unit = 2;
string mint_url = 3;
bool active = 4;
map<uint64, string> keys = 5;
}
40 changes: 40 additions & 0 deletions melt.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
syntax = "proto3";

import "mint.proto";
import "proofs.proto";
package cashu.v1;
option go_package = "github.com/cashu/rpc/melt";

message GetQuoteBolt11StateRequest {
string quote_id = 1;

}

message PostMeltQuoteBolt11Request {
string request = 1;
string unit = 2;
}

message PostMeltQuoteStateResponse {

}

message PostMeltQuoteBolt11Response {
string quote = 1;
uint64 amount = 2;
uint64 fee_reserve = 3;
bool paid = 4;
int64 expiry = 5;
}


message PostMeltBolt11Request {
repeated Proof inputs = 1;
string quote = 2;
}


message PostMeltBolt11Response {
bool paid = 1;
string payment_preimage = 2; // This field is optional and can be null.
}
9 changes: 9 additions & 0 deletions message.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";
package cashu.v1;
option go_package = "github.com/cashu/rpc/message";

message BlindedMessage {
uint64 amount = 1;
string id = 2;
string B_ = 3;
}
37 changes: 37 additions & 0 deletions mint.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
syntax = "proto3";

import "message.proto";
import "signature.proto";
import "tagger/tagger.proto";
package cashu.v1;
option go_package = "github.com/cashu/rpc/mint";


enum UnitType {
unspecified = 0;
sat = 1;
}


message PostMintQuoteBolt11Request {
uint64 amount = 1;
string unit = 2;
}

message PostMintQuoteBolt11Response {
string quote = 1 [(tagger.tags) = "json:\"quote\""];
string request = 2 [(tagger.tags) = "json:\"request\""];
bool paid = 3 [(tagger.tags) = "json:\"paid\""];
int64 expiry = 4 [(tagger.tags) = "json:\"expiry\""];
}


message PostMintBolt11Request {
string quote = 1 [(tagger.tags) = "json:\"quote\""];
repeated BlindedMessage outputs = 3 [(tagger.tags) = "json:\"outputs\""];
}


message PostMintBolt11Response {
repeated BlindedSignature signatures = 1;
}
10 changes: 10 additions & 0 deletions proofs.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
syntax = "proto3";

package cashu.v1;
option go_package = "github.com/cashu/rpc/proofs";
message Proof {
uint64 amount = 1;
string id = 2;
string secret = 3;
string C = 4;
}
9 changes: 9 additions & 0 deletions signature.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";
package cashu.v1;
option go_package = "github.com/cashu/rpc/signature";

message BlindedSignature {
string id = 1;
uint64 amount = 2;
string C_ = 3;
}
20 changes: 20 additions & 0 deletions state.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";

import "message.proto";
import "signature.proto";

package cashu.v1;
option go_package = "github.com/cashu/rpc/state";

message PostCheckStateRequest {
repeated string secrets = 1;
}

message PostCheckStateResponse {
repeated States states = 1;
}
message States {
string secret = 1;
string state = 2;
string witness = 3;
}
16 changes: 16 additions & 0 deletions swap.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";

import "proofs.proto";
import "message.proto";
import "signature.proto";
package cashu.v1;
option go_package = "github.com/cashu/rpc/swap";

message SwapResponse {
repeated BlindedSignature signatures = 1;
}

message SwapRequest {
repeated Proof inputs = 1;
repeated BlindedMessage outputs = 2;
}
19 changes: 19 additions & 0 deletions token.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
syntax = "proto3";
import "tagger/tagger.proto";


import "proofs.proto";
package cashu.v1;
option go_package = "github.com/cashu/rpc/token";


message TokenV3 {
repeated BaseToken token = 1;
string unit = 2;
string memo = 3;
}

message BaseToken {
string mint = 1;
repeated Proof proofs = 2;
}

0 comments on commit 8e5a31d

Please sign in to comment.