Minor syntax changes

This commit is contained in:
Dennis Reimann
2021-09-01 17:31:42 +02:00
committed by Andrew Camilleri
parent 3343738bb3
commit 0d08bd3ad1
2 changed files with 15 additions and 12 deletions

View File

@@ -258,7 +258,7 @@ namespace BTCPayServer.Controllers
if (psbtObject.TryGetFee(out var fee)) if (psbtObject.TryGetFee(out var fee))
{ {
vm.Destinations.Add(new WalletPSBTReadyViewModel.DestinationViewModel() vm.Destinations.Add(new WalletPSBTReadyViewModel.DestinationViewModel
{ {
Positive = false, Positive = false,
Balance = ValueToString(-fee, network), Balance = ValueToString(-fee, network),
@@ -288,15 +288,17 @@ namespace BTCPayServer.Controllers
{ {
if (command == null) if (command == null)
return await WalletPSBT(walletId, vm); return await WalletPSBT(walletId, vm);
PSBT psbt; PSBT psbt;
var network = NetworkProvider.GetNetwork<BTCPayNetwork>(walletId.CryptoCode); var network = NetworkProvider.GetNetwork<BTCPayNetwork>(walletId.CryptoCode);
DerivationSchemeSettings derivationSchemeSettings = null; DerivationSchemeSettings derivationSchemeSettings;
try try
{ {
psbt = PSBT.Parse(vm.SigningContext.PSBT, network.NBitcoinNetwork); psbt = PSBT.Parse(vm.SigningContext.PSBT, network.NBitcoinNetwork);
derivationSchemeSettings = GetDerivationSchemeSettings(walletId); derivationSchemeSettings = GetDerivationSchemeSettings(walletId);
if (derivationSchemeSettings == null) if (derivationSchemeSettings == null)
return NotFound(); return NotFound();
await FetchTransactionDetails(derivationSchemeSettings, vm, network); await FetchTransactionDetails(derivationSchemeSettings, vm, network);
} }
catch catch
@@ -308,14 +310,14 @@ namespace BTCPayServer.Controllers
switch (command) switch (command)
{ {
case "payjoin": case "payjoin":
string error = null; string error;
try try
{ {
var proposedPayjoin = await GetPayjoinProposedTX(new BitcoinUrlBuilder(vm.SigningContext.PayJoinBIP21, network.NBitcoinNetwork), psbt, var proposedPayjoin = await GetPayjoinProposedTX(new BitcoinUrlBuilder(vm.SigningContext.PayJoinBIP21, network.NBitcoinNetwork), psbt,
derivationSchemeSettings, network, cancellationToken); derivationSchemeSettings, network, cancellationToken);
try try
{ {
proposedPayjoin.Settings.SigningOptions = new SigningOptions() proposedPayjoin.Settings.SigningOptions = new SigningOptions
{ {
EnforceLowR = !(vm.SigningContext?.EnforceLowR is false) EnforceLowR = !(vm.SigningContext?.EnforceLowR is false)
}; };
@@ -328,7 +330,7 @@ namespace BTCPayServer.Controllers
proposedPayjoin.Finalize(); proposedPayjoin.Finalize();
var hash = proposedPayjoin.ExtractTransaction().GetHash(); var hash = proposedPayjoin.ExtractTransaction().GetHash();
_EventAggregator.Publish(new UpdateTransactionLabel(walletId, hash, UpdateTransactionLabel.PayjoinLabelTemplate())); _EventAggregator.Publish(new UpdateTransactionLabel(walletId, hash, UpdateTransactionLabel.PayjoinLabelTemplate()));
TempData.SetStatusMessageModel(new StatusMessageModel() TempData.SetStatusMessageModel(new StatusMessageModel
{ {
Severity = StatusMessageModel.StatusSeverity.Success, Severity = StatusMessageModel.StatusSeverity.Success,
AllowDismiss = false, AllowDismiss = false,
@@ -343,9 +345,9 @@ namespace BTCPayServer.Controllers
Severity = StatusMessageModel.StatusSeverity.Warning, Severity = StatusMessageModel.StatusSeverity.Warning,
AllowDismiss = false, AllowDismiss = false,
Html = Html =
$"This transaction has been coordinated between the receiver and you to create a <a href='https://en.bitcoin.it/wiki/PayJoin' target='_blank'>payjoin transaction</a> by adding inputs from the receiver.<br/>" + "This transaction has been coordinated between the receiver and you to create a <a href='https://en.bitcoin.it/wiki/PayJoin' target='_blank'>payjoin transaction</a> by adding inputs from the receiver.<br/>" +
$"The amount being sent may appear higher but is in fact almost same.<br/><br/>" + "The amount being sent may appear higher but is in fact almost same.<br/><br/>" +
$"If you cancel or refuse to sign this transaction, the payment will proceed without payjoin" "If you cancel or refuse to sign this transaction, the payment will proceed without payjoin"
}); });
vm.SigningContext.PSBT = proposedPayjoin.ToBase64(); vm.SigningContext.PSBT = proposedPayjoin.ToBase64();
vm.SigningContext.OriginalPSBT = psbt.ToBase64(); vm.SigningContext.OriginalPSBT = psbt.ToBase64();
@@ -367,7 +369,7 @@ namespace BTCPayServer.Controllers
//we possibly exposed the tx to the receiver, so we need to broadcast straight away //we possibly exposed the tx to the receiver, so we need to broadcast straight away
psbt.Finalize(); psbt.Finalize();
TempData.SetStatusMessageModel(new StatusMessageModel() TempData.SetStatusMessageModel(new StatusMessageModel
{ {
Severity = StatusMessageModel.StatusSeverity.Warning, Severity = StatusMessageModel.StatusSeverity.Warning,
AllowDismiss = false, AllowDismiss = false,
@@ -389,7 +391,7 @@ namespace BTCPayServer.Controllers
{ {
if (!string.IsNullOrEmpty(vm.SigningContext.OriginalPSBT)) if (!string.IsNullOrEmpty(vm.SigningContext.OriginalPSBT))
{ {
TempData.SetStatusMessageModel(new StatusMessageModel() TempData.SetStatusMessageModel(new StatusMessageModel
{ {
Severity = StatusMessageModel.StatusSeverity.Warning, Severity = StatusMessageModel.StatusSeverity.Warning,
AllowDismiss = false, AllowDismiss = false,

View File

@@ -817,9 +817,10 @@ namespace BTCPayServer.Controllers
SigningContext = model.SigningContext SigningContext = model.SigningContext
}); });
} }
private IActionResult RedirectToWalletPSBTReady(WalletPSBTReadyViewModel vm) private IActionResult RedirectToWalletPSBTReady(WalletPSBTReadyViewModel vm)
{ {
var redirectVm = new PostRedirectViewModel() var redirectVm = new PostRedirectViewModel
{ {
AspController = "Wallets", AspController = "Wallets",
AspAction = nameof(WalletPSBTReady), AspAction = nameof(WalletPSBTReady),
@@ -943,7 +944,7 @@ namespace BTCPayServer.Controllers
} }
ModelState.Remove(nameof(viewModel.SigningContext.PSBT)); ModelState.Remove(nameof(viewModel.SigningContext.PSBT));
viewModel.SigningContext.PSBT = psbt.ToBase64(); viewModel.SigningContext.PSBT = psbt.ToBase64();
return RedirectToWalletPSBTReady(new WalletPSBTReadyViewModel() return RedirectToWalletPSBTReady(new WalletPSBTReadyViewModel
{ {
SigningKey = signingKey.GetWif(network.NBitcoinNetwork).ToString(), SigningKey = signingKey.GetWif(network.NBitcoinNetwork).ToString(),
SigningKeyPath = rootedKeyPath?.ToString(), SigningKeyPath = rootedKeyPath?.ToString(),