Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Run unit tests
run: |
dotnet tool install --global JetBrains.dotCover.CommandLineTools --version 2025.1.8
dotCover cover-dotnet --TargetArguments="test BTCPayServer.Plugins.UnitTests -c Release --no-build" --output=coverage/dotCover.UnitTests.output.dcvr --filters="-:Assembly=BTCPayServer.Plugins.UnitTests;-:Assembly=testhost;-:Assembly=BTCPayServer;-:Class=AspNetCoreGeneratedDocument.*"
dotCover cover-dotnet --TargetArguments="test BTCPayServer.Plugins.UnitTests -c Release --no-build -v n" --output=coverage/dotCover.UnitTests.output.dcvr --filters="-:Assembly=BTCPayServer.Plugins.UnitTests;-:Assembly=testhost;-:Assembly=BTCPayServer;-:Class=AspNetCoreGeneratedDocument.*"

- name: Run integration tests
run: docker compose -f BTCPayServer.Plugins.IntegrationTests/docker-compose.yml run tests
Expand Down
Comment thread
napoly marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using BTCPayServer.Plugins.Monero.RPC.Models;
using BTCPayServer.Plugins.Monero.Services;
using BTCPayServer.Rating;
using BTCPayServer.Services.Rates;
using BTCPayServer.Tests.Mocks;

using Monero.Wallet.Rpc;

using Xunit;
using Xunit.Abstractions;

Expand Down
2 changes: 1 addition & 1 deletion BTCPayServer.Plugins.IntegrationTests/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

dotCover cover-dotnet \
--TargetArguments="test -c ${CONFIGURATION_NAME} $FILTERS . --no-build" \
--TargetArguments="test -c ${CONFIGURATION_NAME} $FILTERS . --no-build -v n" \
--Output=/coverage/dotCover.IntegrationTests.output.dcvr \
--filters="-:Assembly=BTCPayServer.Plugins.IntegrationTests;-:Assembly=testhost;-:Assembly=BTCPayServer;-:Assembly=ExchangeSharp;-:Assembly=BTCPayServer.Tests;-:Assembly=BTCPayServer.Client;-:Assembly=BTCPayServer.Abstractions;-:Assembly=BTCPayServer.Data;-:Assembly=BTCPayServer.Common;-:Assembly=BTCPayServer.Logging;-:Assembly=BTCPayServer.Rating;-:Assembly=Dapper;-:Assembly=Serilog.Extensions.Logging;-:Class=AspNetCoreGeneratedDocument.*"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void DefaultValues_ShouldBeCorrect()

Assert.Equal(0, paymentData.SubaddressIndex);
Assert.Equal(0, paymentData.SubaccountIndex);
Assert.Equal(0, paymentData.BlockHeight);
Assert.Equal(0UL, paymentData.BlockHeight);
Assert.Equal(0, paymentData.ConfirmationCount);
Assert.Null(paymentData.TransactionId);
Assert.Null(paymentData.InvoiceSettledConfirmationThreshold);
Expand All @@ -37,7 +37,7 @@ public void Properties_ShouldBeSettable()

Assert.Equal(1, paymentData.SubaddressIndex);
Assert.Equal(2, paymentData.SubaccountIndex);
Assert.Equal(100, paymentData.BlockHeight);
Assert.Equal(100UL, paymentData.BlockHeight);
Assert.Equal(5, paymentData.ConfirmationCount);
Assert.Equal("tx123", paymentData.TransactionId);
Assert.Equal(10, paymentData.InvoiceSettledConfirmationThreshold);
Expand Down

This file was deleted.

52 changes: 0 additions & 52 deletions BTCPayServer.Plugins.UnitTests/Monero/RPC/MoneroEventTests.cs

This file was deleted.

3 changes: 2 additions & 1 deletion Plugins/Monero/BTCPayServer.Plugins.Monero.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@

<!-- Deterministic build -->
<ItemGroup>
<PackageReference Include="DotNet.ReproducibleBuilds" Version="1.2.25" PrivateAssets="All"/>
<PackageReference Include="DotNet.ReproducibleBuilds" Version="1.2.25" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="MoneroNet" Version="1.0.3" />
</ItemGroup>

<!-- If you need Entity Framework, you can uncomment this. This will make it usable in your project without publishing assemblies
Expand Down
5 changes: 0 additions & 5 deletions Plugins/Monero/Controllers/GenerateFromKeysException.cs

This file was deleted.

4 changes: 2 additions & 2 deletions Plugins/Monero/Controllers/MoneroDaemonCallbackController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using BTCPayServer.Plugins.Monero.RPC;

using Microsoft.AspNetCore.Mvc;

using Monero.Common;

namespace BTCPayServer.Plugins.Monero.Controllers
{
[Route("[controller]")]
Expand Down
20 changes: 8 additions & 12 deletions Plugins/Monero/Controllers/MoneroLikeStoreController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;

Expand All @@ -13,7 +12,6 @@
using BTCPayServer.Payments;
using BTCPayServer.Plugins.Monero.Configuration;
using BTCPayServer.Plugins.Monero.Payments;
using BTCPayServer.Plugins.Monero.RPC.Models;
using BTCPayServer.Plugins.Monero.Services;
using BTCPayServer.Services.Invoices;
using BTCPayServer.Services.Stores;
Expand All @@ -23,6 +21,8 @@
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.Extensions.Localization;

using Monero.Wallet.Rpc;

namespace BTCPayServer.Plugins.Monero.Controllers
{
[Route("stores/{storeId}/monerolike")]
Expand Down Expand Up @@ -98,10 +98,10 @@ private MoneroLikePaymentMethodViewModel GetMoneroLikePaymentMethodViewModel(
_MoneroRpcProvider.Summaries.TryGetValue(cryptoCode, out var summary);
_MoneroLikeConfiguration.MoneroLikeConfigurationItems.TryGetValue(cryptoCode,
out var configurationItem);
var accounts = accountsResponse?.SubaddressAccounts?.Select(account =>
var accounts = accountsResponse?.Accounts.Select(account =>
new SelectListItem(
$"{account.AccountIndex} - {(string.IsNullOrEmpty(account.Label) ? "No label" : account.Label)}",
account.AccountIndex.ToString(CultureInfo.InvariantCulture)));
account.AccountIndex.ToString()));

var settlementThresholdChoice = MoneroLikeSettlementThresholdChoice.StoreSpeedPolicy;
if (settings != null && settings.InvoiceSettledConfirmationThreshold is { } confirmations)
Expand All @@ -122,7 +122,7 @@ private MoneroLikePaymentMethodViewModel GetMoneroLikePaymentMethodViewModel(
!excludeFilters.Match(PaymentTypes.CHAIN.GetPaymentMethodId(cryptoCode)),
Summary = summary,
CryptoCode = cryptoCode,
AccountIndex = settings?.AccountIndex ?? accountsResponse?.SubaddressAccounts?.FirstOrDefault()?.AccountIndex ?? 0,
AccountIndex = settings?.AccountIndex ?? accountsResponse?.Accounts?.FirstOrDefault()?.AccountIndex ?? 0,
Accounts = accounts == null ? null : new SelectList(accounts, nameof(SelectListItem.Value),
nameof(SelectListItem.Text)),
SettlementConfirmationThresholdChoice = settlementThresholdChoice,
Expand Down Expand Up @@ -210,17 +210,13 @@ public async Task<IActionResult> GetStoreMoneroLikePaymentMethod(MoneroLikePayme
}
try
{
var response = await _MoneroRpcProvider.WalletRpcClients[cryptoCode].SendCommandAsync<GenerateFromKeysRequest, GenerateFromKeysResponse>("generate_from_keys", new GenerateFromKeysRequest
await _MoneroRpcProvider.WalletRpcClients[cryptoCode].SendCommandAsync<GenerateFromKeysRequest, GenerateFromKeysResponse>("generate_from_keys", new GenerateFromKeysRequest
{
PrimaryAddress = viewModel.PrimaryAddress,
PrivateViewKey = viewModel.PrivateViewKey,
WalletFileName = "wallet",
RestoreHeight = viewModel.RestoreHeight
});
if (response?.Error != null)
{
throw new GenerateFromKeysException(response.Error.Message);
Comment thread
napoly marked this conversation as resolved.
}
}
catch (Exception ex)
{
Expand Down Expand Up @@ -292,11 +288,11 @@ public class MoneroLikePaymentMethodViewModel : IValidatableObject
[Display(Name = "Private View Key")]
public string PrivateViewKey { get; set; }
[Display(Name = "Restore Height")]
public int RestoreHeight { get; set; }
public uint RestoreHeight { get; set; }
[Display(Name = "Consider the invoice settled when the payment transaction …")]
public MoneroLikeSettlementThresholdChoice SettlementConfirmationThresholdChoice { get; set; }
[Display(Name = "Required Confirmations"), Range(0, 100)]
public long? CustomSettlementConfirmationThreshold { get; set; }
public int? CustomSettlementConfirmationThreshold { get; set; }

public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
Expand Down
2 changes: 1 addition & 1 deletion Plugins/Monero/Payments/MoneroCheckoutModelExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void ModifyCheckoutModel(CheckoutModelContext context)
if (details is not null)
{
context.Model.ReceivedConfirmations = details.ConfirmationCount;
context.Model.RequiredConfirmations = (int)MoneroListener.ConfirmationsRequired(details, context.InvoiceEntity.SpeedPolicy);
context.Model.RequiredConfirmations = MoneroListener.ConfirmationsRequired(details, context.InvoiceEntity.SpeedPolicy);
}

context.Model.InvoiceBitcoinUrl = paymentLinkExtension.GetPaymentLink(context.Prompt, context.UrlHelper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace BTCPayServer.Plugins.Monero.Payments
public class MoneroLikeOnChainPaymentMethodDetails
{
public long AccountIndex { get; set; }
public long AddressIndex { get; set; }
public long? InvoiceSettledConfirmationThreshold { get; set; }
public uint AddressIndex { get; set; }
public int? InvoiceSettledConfirmationThreshold { get; set; }
}
}
9 changes: 4 additions & 5 deletions Plugins/Monero/Payments/MoneroLikePaymentData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ public class MoneroLikePaymentData
{
public long SubaddressIndex { get; set; }
public long SubaccountIndex { get; set; }
public long BlockHeight { get; set; }
public long ConfirmationCount { get; set; }
public ulong BlockHeight { get; set; }
public int ConfirmationCount { get; set; }
public string TransactionId { get; set; }
public long? InvoiceSettledConfirmationThreshold { get; set; }

public long LockTime { get; set; } = 0;
public int? InvoiceSettledConfirmationThreshold { get; set; }
public int LockTime { get; set; }
}
}
7 changes: 5 additions & 2 deletions Plugins/Monero/Payments/MoneroLikePaymentMethodHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@

using BTCPayServer.Data;
using BTCPayServer.Payments;
using BTCPayServer.Plugins.Monero.RPC.Models;
using BTCPayServer.Plugins.Monero.Services;
using BTCPayServer.Plugins.Monero.Utils;

using Monero.Daemon.Common;
using Monero.Daemon.Rpc;
using Monero.Wallet.Rpc;

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

Expand Down Expand Up @@ -76,7 +79,7 @@ public async Task ConfigurePrompt(PaymentMethodContext context)
var details = new MoneroLikeOnChainPaymentMethodDetails()
{
AccountIndex = moneroPrepare.AccountIndex,
AddressIndex = address.AddressIndex,
AddressIndex = address.Index,
InvoiceSettledConfirmationThreshold = ParsePaymentMethodConfig(context.PaymentMethodConfig).InvoiceSettledConfirmationThreshold
};
context.Prompt.Destination = address.Address;
Expand Down
2 changes: 1 addition & 1 deletion Plugins/Monero/Payments/MoneroPaymentPromptDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ namespace BTCPayServer.Plugins.Monero.Payments
public class MoneroPaymentPromptDetails
{
public long AccountIndex { get; set; }
public long? InvoiceSettledConfirmationThreshold { get; set; }
public int? InvoiceSettledConfirmationThreshold { get; set; }
}
}
Loading
Loading