diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/buf.lock b/buf.lock new file mode 100644 index 0000000..100dafc --- /dev/null +++ b/buf.lock @@ -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 diff --git a/buf.yaml b/buf.yaml new file mode 100644 index 0000000..5731f1a --- /dev/null +++ b/buf.yaml @@ -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 \ No newline at end of file diff --git a/cashu.proto b/cashu.proto new file mode 100644 index 0000000..031f5a1 --- /dev/null +++ b/cashu.proto @@ -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" + }; + }; +} diff --git a/info.proto b/info.proto new file mode 100644 index 0000000..6e55fff --- /dev/null +++ b/info.proto @@ -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 nuts = 8; +} + + + diff --git a/keys.proto b/keys.proto new file mode 100644 index 0000000..50253bd --- /dev/null +++ b/keys.proto @@ -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 keys = 5; +} diff --git a/melt.proto b/melt.proto new file mode 100644 index 0000000..a33bff7 --- /dev/null +++ b/melt.proto @@ -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. +} \ No newline at end of file diff --git a/message.proto b/message.proto new file mode 100644 index 0000000..f992d1d --- /dev/null +++ b/message.proto @@ -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; +} \ No newline at end of file diff --git a/mint.proto b/mint.proto new file mode 100644 index 0000000..1632e8f --- /dev/null +++ b/mint.proto @@ -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; +} \ No newline at end of file diff --git a/proofs.proto b/proofs.proto new file mode 100644 index 0000000..edb19ed --- /dev/null +++ b/proofs.proto @@ -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; +} diff --git a/signature.proto b/signature.proto new file mode 100644 index 0000000..ce0c300 --- /dev/null +++ b/signature.proto @@ -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; +} diff --git a/state.proto b/state.proto new file mode 100644 index 0000000..02ffa39 --- /dev/null +++ b/state.proto @@ -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; +} \ No newline at end of file diff --git a/swap.proto b/swap.proto new file mode 100644 index 0000000..30dd60f --- /dev/null +++ b/swap.proto @@ -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; +} \ No newline at end of file diff --git a/token.proto b/token.proto new file mode 100644 index 0000000..07cda22 --- /dev/null +++ b/token.proto @@ -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; +} \ No newline at end of file