mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-19 05:33:31 +01:00
Allow specifing fee block target for onchain payout processor (#4065)
Co-authored-by: d11n <mail@dennisreimann.de>
This commit is contained in:
parent
01ab21e4c0
commit
7c8f4c0405
@ -10,4 +10,6 @@ public class OnChainAutomatedPayoutSettings
|
||||
|
||||
[JsonConverter(typeof(TimeSpanJsonConverter.Seconds))]
|
||||
public TimeSpan IntervalSeconds { get; set; }
|
||||
|
||||
public int? FeeBlockTarget { get; set; }
|
||||
}
|
||||
|
@ -52,16 +52,22 @@ namespace BTCPayServer.Controllers.Greenfield
|
||||
|
||||
private static OnChainAutomatedPayoutSettings ToModel(PayoutProcessorData data)
|
||||
{
|
||||
var blob = BaseAutomatedPayoutProcessor<OnChainAutomatedPayoutBlob>.GetBlob(data);
|
||||
return new OnChainAutomatedPayoutSettings()
|
||||
{
|
||||
FeeBlockTarget = blob.FeeTargetBlock,
|
||||
PaymentMethod = data.PaymentMethod,
|
||||
IntervalSeconds = InvoiceRepository.FromBytes<AutomatedPayoutBlob>(data.Blob).Interval
|
||||
IntervalSeconds = blob.Interval
|
||||
};
|
||||
}
|
||||
|
||||
private static AutomatedPayoutBlob FromModel(OnChainAutomatedPayoutSettings data)
|
||||
private static OnChainAutomatedPayoutBlob FromModel(OnChainAutomatedPayoutSettings data)
|
||||
{
|
||||
return new AutomatedPayoutBlob() {Interval = data.IntervalSeconds};
|
||||
return new OnChainAutomatedPayoutBlob()
|
||||
{
|
||||
FeeTargetBlock = data.FeeBlockTarget ?? 1,
|
||||
Interval = data.IntervalSeconds
|
||||
};
|
||||
}
|
||||
|
||||
[Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
||||
|
@ -0,0 +1,8 @@
|
||||
using BTCPayServer.PayoutProcessors.Settings;
|
||||
|
||||
namespace BTCPayServer.PayoutProcessors.OnChain;
|
||||
|
||||
public class OnChainAutomatedPayoutBlob : AutomatedPayoutBlob
|
||||
{
|
||||
public int FeeTargetBlock { get; set; } = 1;
|
||||
}
|
@ -23,7 +23,7 @@ using PayoutProcessorData = BTCPayServer.Data.Data.PayoutProcessorData;
|
||||
|
||||
namespace BTCPayServer.PayoutProcessors.OnChain
|
||||
{
|
||||
public class OnChainAutomatedPayoutProcessor : BaseAutomatedPayoutProcessor<AutomatedPayoutBlob>
|
||||
public class OnChainAutomatedPayoutProcessor : BaseAutomatedPayoutProcessor<OnChainAutomatedPayoutBlob>
|
||||
{
|
||||
private readonly ExplorerClientProvider _explorerClientProvider;
|
||||
private readonly BTCPayWalletProvider _btcPayWalletProvider;
|
||||
@ -90,7 +90,8 @@ namespace BTCPayServer.PayoutProcessors.OnChain
|
||||
var changeAddress = await explorerClient.GetUnusedAsync(
|
||||
storePaymentMethod.AccountDerivation, DerivationFeature.Change, 0, true);
|
||||
|
||||
var feeRate = await explorerClient.GetFeeRateAsync(1, new FeeRate(1m));
|
||||
var processorBlob = GetBlob(_PayoutProcesserSettings);
|
||||
var feeRate = await explorerClient.GetFeeRateAsync(processorBlob.FeeTargetBlock,new FeeRate(1m));
|
||||
|
||||
var transfersProcessing = new List<PayoutData>();
|
||||
foreach (var transferRequest in payouts)
|
||||
|
@ -22,7 +22,8 @@ public class OnChainAutomatedPayoutSenderFactory : EventHostedServiceBase, IPayo
|
||||
public string FriendlyName { get; } = "Automated Bitcoin Sender";
|
||||
public OnChainAutomatedPayoutSenderFactory(EventAggregator eventAggregator,
|
||||
ILogger<OnChainAutomatedPayoutSenderFactory> logger,
|
||||
BTCPayNetworkProvider btcPayNetworkProvider, IServiceProvider serviceProvider, LinkGenerator linkGenerator) : base(eventAggregator, logger)
|
||||
BTCPayNetworkProvider btcPayNetworkProvider,
|
||||
IServiceProvider serviceProvider, LinkGenerator linkGenerator) : base(eventAggregator, logger)
|
||||
{
|
||||
_btcPayNetworkProvider = btcPayNetworkProvider;
|
||||
_serviceProvider = serviceProvider;
|
||||
|
@ -72,7 +72,7 @@ public class UIOnChainAutomatedPayoutProcessorsController : Controller
|
||||
}))
|
||||
.FirstOrDefault();
|
||||
|
||||
return View (new OnChainTransferViewModel(activeProcessor is null? new AutomatedPayoutBlob() : OnChainAutomatedPayoutProcessor.GetBlob(activeProcessor)));
|
||||
return View (new OnChainTransferViewModel(activeProcessor is null? new OnChainAutomatedPayoutBlob() : OnChainAutomatedPayoutProcessor.GetBlob(activeProcessor)));
|
||||
}
|
||||
|
||||
[HttpPost("~/stores/{storeId}/payout-processors/onchain-automated/{cryptocode}")]
|
||||
@ -130,15 +130,23 @@ public class UIOnChainAutomatedPayoutProcessorsController : Controller
|
||||
|
||||
}
|
||||
|
||||
public OnChainTransferViewModel(AutomatedPayoutBlob blob)
|
||||
public OnChainTransferViewModel(OnChainAutomatedPayoutBlob blob)
|
||||
{
|
||||
IntervalMinutes = blob.Interval.TotalMinutes;
|
||||
FeeTargetBlock = blob.FeeTargetBlock;
|
||||
}
|
||||
|
||||
public int FeeTargetBlock { get; set; }
|
||||
|
||||
public double IntervalMinutes { get; set; }
|
||||
|
||||
public AutomatedPayoutBlob ToBlob()
|
||||
public OnChainAutomatedPayoutBlob ToBlob()
|
||||
{
|
||||
return new AutomatedPayoutBlob { Interval = TimeSpan.FromMinutes(IntervalMinutes) };
|
||||
return new OnChainAutomatedPayoutBlob
|
||||
{
|
||||
FeeTargetBlock = FeeTargetBlock,
|
||||
Interval = TimeSpan.FromMinutes(IntervalMinutes)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,13 @@
|
||||
<span class="input-group-text">minutes</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="FeeTargetBlock" class="form-label" data-required>Fee block target</label>
|
||||
<div class="input-group">
|
||||
<input asp-for="FeeTargetBlock" class="form-control" min="1" inputmode="numeric" style="max-width:10ch;">
|
||||
<span class="input-group-text">blocks</span>
|
||||
</div>
|
||||
</div>
|
||||
<button name="command" type="submit" class="btn btn-primary mt-2" value="Save" id="Save">Save</button>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -607,6 +607,11 @@
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"feeTargetBlock": {
|
||||
"type": "number",
|
||||
"description": "How many blocks should the fee rate calculation target to confirm in. Set to 1 if not provided",
|
||||
"nullable": true
|
||||
},
|
||||
"intervalSeconds": {
|
||||
"description": "How often should the processor run",
|
||||
"allOf": [
|
||||
@ -625,6 +630,10 @@
|
||||
"description": "payment method of the payout processor",
|
||||
"type": "string"
|
||||
},
|
||||
"feeTargetBlock": {
|
||||
"type": "number",
|
||||
"description": "How many blocks should the fee rate calculation target to confirm in."
|
||||
},
|
||||
"intervalSeconds": {
|
||||
"description": "How often should the processor run",
|
||||
"allOf": [
|
||||
|
Loading…
Reference in New Issue
Block a user