diff --git a/BTCPayServer.Tests/PayJoinTests.cs b/BTCPayServer.Tests/PayJoinTests.cs index 137257d28..dc477c71c 100644 --- a/BTCPayServer.Tests/PayJoinTests.cs +++ b/BTCPayServer.Tests/PayJoinTests.cs @@ -404,10 +404,10 @@ namespace BTCPayServer.Tests Assert.False(paymentValueRowColumn.Text.Contains("payjoin", StringComparison.InvariantCultureIgnoreCase)); - s.GoToWallet(receiverWalletId, WalletsNavPages.Transactions); - s.Driver.WaitForElement(By.CssSelector("#WalletTransactionsList tr")); TestUtils.Eventually(() => { + s.GoToWallet(receiverWalletId, WalletsNavPages.Transactions); + s.Driver.WaitForElement(By.CssSelector("#WalletTransactionsList tr")); Assert.Contains("payjoin", s.Driver.PageSource); // Either the invoice id or the payjoin-exposed label, depending on the input having been used Assert.Matches(new Regex($"({invoiceId}|payjoin-exposed)"), s.Driver.PageSource); diff --git a/BTCPayServer/Services/DelayedTransactionBroadcaster.cs b/BTCPayServer/Services/DelayedTransactionBroadcaster.cs index be72f9c46..94ad23c24 100644 --- a/BTCPayServer/Services/DelayedTransactionBroadcaster.cs +++ b/BTCPayServer/Services/DelayedTransactionBroadcaster.cs @@ -5,6 +5,7 @@ using System.Threading; using System.Threading.Tasks; using BTCPayServer.Data; using BTCPayServer.Logging; +using Dapper; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using NBitcoin; @@ -45,19 +46,18 @@ namespace BTCPayServer.Services ArgumentNullException.ThrowIfNull(transaction); ArgumentNullException.ThrowIfNull(network); using var db = _dbContextFactory.CreateContext(); - db.PlannedTransactions.Add(new PlannedTransaction() - { - Id = $"{network.CryptoCode}-{transaction.GetHash()}", - BroadcastAt = broadcastTime, - Blob = transaction.ToBytes() - }); - try - { - await db.SaveChangesAsync(); - } - catch (DbUpdateException) - { - } + var conn = db.Database.GetDbConnection(); + await conn.ExecuteAsync( + """ + INSERT INTO "PlannedTransactions"("Id", "BroadcastAt", "Blob") VALUES(@Id, @BroadcastAt, @Blob) + ON CONFLICT DO NOTHING + """, + new + { + Id = $"{network.CryptoCode}-{transaction.GetHash()}", + BroadcastAt = broadcastTime, + Blob = transaction.ToBytes() + }); } public async Task ProcessAll(CancellationToken cancellationToken = default)