mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 22:44:29 +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 System;
|
||||||
using BTCPayServer.Lightning;
|
using BTCPayServer.Lightning;
|
||||||
using BTCPayServer.Lightning.JsonConverters;
|
using NBitcoin;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace BTCPayServer.Client.Models
|
namespace BTCPayServer.Client.Models
|
||||||
@@ -11,15 +11,19 @@ namespace BTCPayServer.Client.Models
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreateLightningInvoiceRequest(LightMoney amount, string description, TimeSpan expiry)
|
public CreateLightningInvoiceRequest(LightMoney amount, string description, TimeSpan expiry)
|
||||||
{
|
{
|
||||||
Amount = amount;
|
Amount = amount;
|
||||||
Description = description;
|
Description = description;
|
||||||
Expiry = expiry;
|
Expiry = expiry;
|
||||||
}
|
}
|
||||||
[JsonConverter(typeof(BTCPayServer.Client.JsonConverters.LightMoneyJsonConverter))]
|
|
||||||
|
[JsonConverter(typeof(JsonConverters.LightMoneyJsonConverter))]
|
||||||
public LightMoney Amount { get; set; }
|
public LightMoney Amount { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
[JsonConverter(typeof(NBitcoin.JsonConverters.UInt256JsonConverter))]
|
||||||
|
public uint256 DescriptionHash { get; set; }
|
||||||
[JsonConverter(typeof(JsonConverters.TimeSpanJsonConverter.Seconds))]
|
[JsonConverter(typeof(JsonConverters.TimeSpanJsonConverter.Seconds))]
|
||||||
public TimeSpan Expiry { get; set; }
|
public TimeSpan Expiry { get; set; }
|
||||||
public bool PrivateRouteHints { get; set; }
|
public bool PrivateRouteHints { get; set; }
|
||||||
|
|||||||
@@ -225,12 +225,16 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var invoice = await lightningClient.CreateInvoice(
|
var param = request.DescriptionHash != null
|
||||||
new CreateInvoiceParams(request.Amount, request.Description, request.Expiry)
|
? new CreateInvoiceParams(request.Amount, request.DescriptionHash, request.Expiry)
|
||||||
{
|
{
|
||||||
PrivateRouteHints = request.PrivateRouteHints
|
PrivateRouteHints = request.PrivateRouteHints, Description = request.Description
|
||||||
},
|
}
|
||||||
CancellationToken.None);
|
: 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));
|
return Ok(ToModel(invoice));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -25,6 +25,12 @@
|
|||||||
"nullable": true,
|
"nullable": true,
|
||||||
"description": "Description of the invoice in the BOLT11"
|
"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": {
|
"expiry": {
|
||||||
"description": "Expiration time in seconds",
|
"description": "Expiration time in seconds",
|
||||||
"allOf": [ {"$ref": "#/components/schemas/TimeSpanSeconds"}]
|
"allOf": [ {"$ref": "#/components/schemas/TimeSpanSeconds"}]
|
||||||
|
|||||||
Reference in New Issue
Block a user