Commit 949e755 1 parent 89bda97 commit 949e755 Copy full SHA for 949e755
File tree 3 files changed +30
-0
lines changed
3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ const zul = @import("zul");
11
11
const RWMutex = helper .RWMutex ;
12
12
const MintInfo = core .nuts .MintInfo ;
13
13
const MintQuoteBolt11Response = core .nuts .nut04 .MintQuoteBolt11Response ;
14
+ const MeltQuoteBolt11Response = core .nuts .nut05 .MeltQuoteBolt11Response ;
14
15
const MintQuoteState = core .nuts .nut04 .QuoteState ;
15
16
const MintKeySet = core .nuts .MintKeySet ;
16
17
const CurrencyUnit = core .nuts .CurrencyUnit ;
@@ -937,6 +938,16 @@ pub const Mint = struct {
937
938
.signatures = promises .items ,
938
939
};
939
940
}
941
+
942
+ /// Check melt quote status
943
+ pub fn checkMeltQuote (self : * Mint , gpa : std.mem.Allocator , quote_id : [16 ]u8 ) ! MeltQuoteBolt11Response {
944
+ const quote = try self .localstore
945
+ .value
946
+ .getMeltQuote (gpa , quote_id ) orelse return error .UnknownQuote ;
947
+ errdefer quote .deinit ();
948
+
949
+ return MeltQuoteBolt11Response .fromMeltQuote (quote );
950
+ }
940
951
};
941
952
942
953
/// Generate new [`MintKeySetInfo`] from path
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ pub fn createMintServer(
50
50
router .get ("/v1/keysets" , router_handlers .getKeysets , .{});
51
51
router .get ("/v1/keys/:keyset_id" , router_handlers .getKeysetPubkeys , .{});
52
52
router .get ("/v1/mint/quote/bolt11/:quote_id" , router_handlers .getCheckMintBolt11Quote , .{});
53
+ router .get ("/v1/melt/quote/bolt11/:quote_id" , router_handlers .getCheckMeltBolt11Quote , .{});
53
54
router .post ("/v1/checkstate" , router_handlers .postCheck , .{});
54
55
router .get ("/v1/info" , router_handlers .getMintInfo , .{});
55
56
Original file line number Diff line number Diff line change @@ -48,6 +48,24 @@ pub fn getCheckMintBolt11Quote(
48
48
return try res .json (quote , .{});
49
49
}
50
50
51
+ pub fn getCheckMeltBolt11Quote (
52
+ state : MintState ,
53
+ req : * httpz.Request ,
54
+ res : * httpz.Response ,
55
+ ) ! void {
56
+ const quote_id_hex = req .param ("quote_id" ) orelse return error .ExpectQuoteId ;
57
+
58
+ const quote_id = try zul .UUID .parse (quote_id_hex );
59
+ const quote = state
60
+ .mint
61
+ .checkMeltQuote (res .arena , quote_id .bin ) catch | err | {
62
+ std .log .debug ("Could not check melt quote {any}: {any}" , .{ quote_id , err });
63
+ return error .CheckMintQuoteFailed ;
64
+ };
65
+
66
+ return try res .json (quote , .{});
67
+ }
68
+
51
69
pub fn postCheck (
52
70
state : MintState ,
53
71
req : * httpz.Request ,
You can’t perform that action at this time.
0 commit comments