mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
API: Add description hash to CreateLightningInvoiceRequest (#3559)
Co-authored-by: Andrew Camilleri <evilkukka@gmail.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using BTCPayServer.Lightning;
|
||||
using BTCPayServer.Lightning.JsonConverters;
|
||||
using NBitcoin;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BTCPayServer.Client.Models
|
||||
@@ -11,15 +11,19 @@ namespace BTCPayServer.Client.Models
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public CreateLightningInvoiceRequest(LightMoney amount, string description, TimeSpan expiry)
|
||||
{
|
||||
Amount = amount;
|
||||
Description = description;
|
||||
Expiry = expiry;
|
||||
}
|
||||
[JsonConverter(typeof(BTCPayServer.Client.JsonConverters.LightMoneyJsonConverter))]
|
||||
|
||||
[JsonConverter(typeof(JsonConverters.LightMoneyJsonConverter))]
|
||||
public LightMoney Amount { get; set; }
|
||||
public string Description { get; set; }
|
||||
[JsonConverter(typeof(NBitcoin.JsonConverters.UInt256JsonConverter))]
|
||||
public uint256 DescriptionHash { get; set; }
|
||||
[JsonConverter(typeof(JsonConverters.TimeSpanJsonConverter.Seconds))]
|
||||
public TimeSpan Expiry { get; set; }
|
||||
public bool PrivateRouteHints { get; set; }
|
||||
|
||||
@@ -225,12 +225,16 @@ namespace BTCPayServer.Controllers.Greenfield
|
||||
|
||||
try
|
||||
{
|
||||
var invoice = await lightningClient.CreateInvoice(
|
||||
new CreateInvoiceParams(request.Amount, request.Description, request.Expiry)
|
||||
var param = request.DescriptionHash != null
|
||||
? new CreateInvoiceParams(request.Amount, request.DescriptionHash, request.Expiry)
|
||||
{
|
||||
PrivateRouteHints = request.PrivateRouteHints
|
||||
},
|
||||
CancellationToken.None);
|
||||
PrivateRouteHints = request.PrivateRouteHints, Description = request.Description
|
||||
}
|
||||
: new CreateInvoiceParams(request.Amount, request.Description, request.Expiry)
|
||||
{
|
||||
PrivateRouteHints = request.PrivateRouteHints, DescriptionHash = request.DescriptionHash
|
||||
};
|
||||
var invoice = await lightningClient.CreateInvoice(param, CancellationToken.None);
|
||||
return Ok(ToModel(invoice));
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -25,6 +25,12 @@
|
||||
"nullable": true,
|
||||
"description": "Description of the invoice in the BOLT11"
|
||||
},
|
||||
"descriptionHash": {
|
||||
"type": "string",
|
||||
"format": "hex",
|
||||
"nullable": true,
|
||||
"description": "Description hash of the invoice in the BOLT11"
|
||||
},
|
||||
"expiry": {
|
||||
"description": "Expiration time in seconds",
|
||||
"allOf": [ {"$ref": "#/components/schemas/TimeSpanSeconds"}]
|
||||
|
||||
Reference in New Issue
Block a user