Skip to content

Commit 639d2e7

Browse files
authored
Merge pull request #3 from d4rp4t/master
Mint/Melt Api models, KeysetId error fix
2 parents 18df054 + b6938e1 commit 639d2e7

10 files changed

+122
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace DotNut.ApiModels;
4+
5+
public class PostMeltBolt11Request
6+
{
7+
8+
[JsonPropertyName("quote")]
9+
public string Quote { get; set; }
10+
11+
[JsonPropertyName("inputs")]
12+
public Proof[] Inputs { get; set; }
13+
14+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
15+
[JsonPropertyName("outputs")]
16+
public BlindedMessage[]? Outputs { get; set; }
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace DotNut.ApiModels;
4+
5+
public class PostMeltQuoteBolt11Request
6+
{
7+
8+
[JsonPropertyName("request")]
9+
public string Request { get; set; }
10+
11+
[JsonPropertyName("unit")]
12+
public string Unit { get; set; }
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace DotNut.ApiModels;
4+
5+
public class PostMeltQuoteBolt11Response
6+
{
7+
[JsonPropertyName("quote")]
8+
public string Quote { get; set; }
9+
10+
[JsonPropertyName("amount")]
11+
public int Amount { get; set; }
12+
13+
[JsonPropertyName("fee_reserve")]
14+
public int FeeReserve { get; set; }
15+
16+
[JsonPropertyName("state")]
17+
public string State {get; set;}
18+
19+
[JsonPropertyName("expiry")]
20+
public int Expiry {get; set;}
21+
22+
[JsonPropertyName("payment_preimage")]
23+
public string? PaymentPreimage {get; set;}
24+
25+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
26+
[JsonPropertyName("change")]
27+
public BlindSignature[]? Change { get; set; }
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace DotNut.ApiModels;
4+
5+
public class PostMintBolt11Request
6+
{
7+
[JsonPropertyName("quote")]
8+
public string Quote { get; set; }
9+
10+
[JsonPropertyName("outputs")]
11+
public BlindedMessage[] Outputs { get; set; }
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace DotNut.ApiModels;
4+
5+
public class PostMintBolt11Response
6+
{
7+
[JsonPropertyName("signatures")]
8+
public BlindSignature[] Signatures { get; set; }
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Diagnostics;
2+
using System.Text.Json.Serialization;
3+
4+
namespace DotNut.ApiModels;
5+
6+
public class PostMintQuoteBolt11Request
7+
{
8+
9+
[JsonPropertyName("amount")]
10+
public int Amount {get; set;}
11+
12+
[JsonPropertyName("unit")]
13+
public string Unit {get; set;}
14+
15+
[JsonPropertyName("description")]
16+
public string? Description {get; set;}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace DotNut.ApiModels;
4+
5+
public class PostMintQuoteBolt11Response
6+
{
7+
[JsonPropertyName("quote")]
8+
public string Quote { get; set; }
9+
10+
[JsonPropertyName("request")]
11+
public string Request { get; set; }
12+
13+
[JsonPropertyName("state")]
14+
public string State { get; set; }
15+
16+
[JsonPropertyName("expiry")]
17+
public int Expiry { get; set; }
18+
}

DotNut/KeysetId.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ public override int GetHashCode()
5151

5252
public KeysetId(string Id)
5353
{
54-
if (Id.Length != 16)
55-
throw new ArgumentException("KeysetId must be 16 characters long");
54+
// Legacy support for old keyset format
55+
if (Id.Length != 16 && Id.Length != 12)
56+
{
57+
throw new ArgumentException("KeysetId must be 16 or 12 characters long");
58+
}
5659
_id = Id;
5760
}
5861

DotNut/MeltMethodSetting.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace DotNut;
55
public class MeltMethodSetting
66
{
77
[JsonPropertyName("method")] public string Method { get; set; }
8-
[JsonPropertyName("unit")] public List<Proof> Unit { get; set; }
8+
[JsonPropertyName("unit")] public string Unit { get; set; }
99
[JsonPropertyName("min_amount")] public int? Min { get; set; }
1010
[JsonPropertyName("max_amount")] public int? Max { get; set; }
1111
}

DotNut/MintMethodSetting.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ namespace DotNut;
55
public class MintMethodSetting
66
{
77
[JsonPropertyName("method")] public string Method { get; set; }
8-
[JsonPropertyName("unit")] public List<Proof> Unit { get; set; }
8+
[JsonPropertyName("unit")] public string Unit { get; set; }
99
[JsonPropertyName("min_amount")] public int? Min { get; set; }
1010
[JsonPropertyName("max_amount")] public int? Max { get; set; }
11+
[JsonPropertyName("description")] public bool? Description { get; set; }
1112
}
1213

0 commit comments

Comments
 (0)