Isolate payout RBF regression and preserve failure diagnostics
What changed, and why it matters
This commit is primarily a regression test and diagnostic improvement for a Bitcoin RBF (Replace-By-Fee) payout bug in BTCPay Server. It adds an automated browser test that verifies pull-payment payouts still complete correctly after a transaction is bumped via RBF. The code changes to the actual application are minimal—just adding CSS class names to form elements so the test can locate them. There is no direct evidence in the commit of an exploitable security vulnerability; it appears to be a fix for a functional regression where RBF-bumped transactions might not be properly tracked as completed payouts.
Treat this as a functional regression fix with minor security-adjacent reliability impact. Review the underlying payout matching logic that the new test exercises to ensure replacement transaction IDs are correctly associated with payouts after RBF. No immediate patching urgency is indicated by the diff alone, but operators relying on pull payments/RBF should verify behavior on the affected version and update to the fixed version once released.
Security signals we found
Regression test added for RBF-bumped payout completion
Production changes limited to testability hooks (CSS classes)
Failure diagnostics added to preserve debugging evidence
No direct security fix or input validation change visible in diff
Evidence from the diff
The commit adds a Playwright end-to-end test CanCompletePullPaymentsAfterRBF that exercises the full flow: create a pull payment, approve and pay out two outputs in one transaction, bump the transaction fee via RBF, broadcast the replacement, mine a block, and assert that both payouts are marked Completed with the replacement transaction ID as payment proof. It also improves test failure diagnostics by capturing page content, screenshots, traces, mempool state, and payout state on failure. The only production code changes are adding CSS classes signing-context__psbt, wallet-bump-fee__method, and wallet-psbt__broadcast to hidden inputs and buttons in Razor views so the test can interact with them. The title ‘Isolate payout RBF regression’ suggests the commit is reproducing/fixing a regression where RBF replacement transactions were not correctly linked to existing payouts, potentially leaving payouts stuck in an intermediate state.
Changed components
BTCPayServer/Plugins/Wallets/Views/UIWallets/SigningContext.cshtmlBTCPayServer/Plugins/Wallets/Views/UIWallets/WalletBumpFee.cshtmlBTCPayServer/Plugins/Wallets/Views/UIWallets/WalletPSBTDecoded.cshtmlBTCPayServer.Tests/PullPaymentsTests.csBTCPayServer.Tests/PlaywrightTester.csInspect captured patch +117 / −23
### BTCPayServer.Tests/PlaywrightTester.cs
@@ -212,9 +212,10 @@ public async Task<ILocator> FindAlertMessage(params StatusMessageModel.StatusSev
return locator.First;
}
- catch (TimeoutException)
+ catch (TimeoutException ex)
{
- throw new TimeoutException($"Unable to find {className}");
+ var messages = await Page.Locator(".alert, .validation-summary-errors").AllTextContentsAsync();
+ throw new TimeoutException($"Unable to find {className} at {Page.Url}\nPage messages: {string.Join("\n", messages)}", ex);
}
}
### BTCPayServer.Tests/PullPaymentsTests.cs
@@ -1,4 +1,5 @@
using System;
+using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
@@ -19,8 +20,10 @@
using LNURL;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
+using Microsoft.Playwright;
using NBitcoin;
using NBitcoin.DataEncoders;
+using Newtonsoft.Json;
using Xunit;
using static Microsoft.Playwright.Assertions;
using PayoutData = BTCPayServer.Data.PayoutData;
@@ -30,6 +33,113 @@ namespace BTCPayServer.Tests;
[Collection(nameof(NonParallelizableCollectionDefinition))]
public class PullPaymentsTests(ITestOutputHelper helper) : UnitTestBase(helper)
{
+ [Fact]
+ [Trait("Playwright", "Playwright-2")]
+ public async Task CanCompletePullPaymentsAfterRBF()
+ {
+ await using var s = CreatePlaywrightTester();
+ s.Server.PayTester.DisableSSRFProtection = true;
+ await s.StartAsync();
+ await s.RegisterNewUser(true);
+ await s.CreateNewStore();
+ await s.GenerateWallet("BTC", "", true);
+ var account = s.AsTestAccount();
+ await account.SetupWebhook();
+ var client = await account.CreateClient();
+ await s.Server.ExplorerNode.GenerateAsync(1);
+ await s.FundStoreWallet(denomination: 50.0m);
+
+ var pullPayment = await client.CreatePullPayment(s.StoreId, new()
+ {
+ Name = "RBF payouts",
+ Amount = 100m,
+ Currency = "USD",
+ PayoutMethods = ["BTC"]
+ });
+ foreach (var amount in new[] { 15m, 20m })
+ {
+ await client.CreatePayout(pullPayment.Id, new CreatePayoutRequest
+ {
+ Amount = amount,
+ Destination = (await s.Server.ExplorerNode.GetNewAddressAsync()).ToString(),
+ PayoutMethodId = "BTC"
+ });
+ }
+
+ uint256 originalTxId = null;
+ uint256 replacementTxId = null;
+ await s.Page.Context.Tracing.StartAsync(new() { Screenshots = true, Snapshots = true, Sources = true });
+ s.Page.PageError += (_, error) => TestLogs.LogInformation($"Browser error: {error}");
+ try
+ {
+ await s.GoToStore(s.StoreId, StoreNavPages.PullPayments);
+ await s.Page.Locator(".pp-payout").ClickAsync();
+ await Expect(s.Page.Locator(".payout")).ToHaveCountAsync(2);
+ await s.Page.CheckAsync(".mass-action-select-all");
+ await s.Page.ClickAsync($"#{PayoutState.AwaitingApproval}-approve-pay");
+ await s.Page.GetByRole(AriaRole.Button, new() { Name = "Sign transaction", Exact = true }).ClickAsync();
+ await s.Page.Locator(".wallet-psbt__broadcast").ClickAsync();
+ await s.FindAlertMessage(partialText: "Transaction broadcasted successfully");
+
+ originalTxId = Assert.Single(await client.ShowOnChainWalletTransactions(s.StoreId, "BTC"),
+ transaction => transaction.Confirmations == 0).TransactionHash;
+ TestLogs.LogInformation($"Original transaction: {originalTxId}");
+ var wallet = await s.GoToWalletTransactions();
+ await wallet.BumpFee(originalTxId);
+ await Expect(s.Page.Locator(".wallet-bump-fee__method option:checked")).ToHaveTextAsync("RBF");
+ TestLogs.LogInformation($"Suggested replacement fee rate: {await s.Page.GetByLabel("New effective fee rate").InputValueAsync()}");
+ await s.ClickPagePrimary();
+
+ var psbt = PSBT.Parse(await s.Page.Locator(".signing-context__psbt").InputValueAsync(), Network.RegTest);
+ var replacement = psbt.Finalize().ExtractTransaction();
+ replacementTxId = replacement.GetHash();
+ TestLogs.LogInformation($"Replacement transaction: {replacementTxId}\n{replacement.ToHex()}");
+ TestLogs.LogInformation($"Mempool acceptance: {JsonConvert.SerializeObject(await s.Server.ExplorerNode.TestMempoolAcceptAsync(replacement))}");
+ await s.Page.Locator(".wallet-psbt__broadcast").ClickAsync();
+ await s.FindAlertMessage(partialText: "Transaction broadcasted successfully");
+
+ var mempool = await s.Server.ExplorerNode.GetRawMempoolAsync();
+ Assert.Contains(replacementTxId, mempool);
+ Assert.DoesNotContain(originalTxId, mempool);
+ await s.Server.ExplorerNode.GenerateAsync(1);
+ var payouts = await client.GetPayouts(pullPayment.Id);
+ Assert.Equal(2, payouts.Length);
+ foreach (var payout in payouts)
+ {
+ await account.AssertHasWebhookEvent(WebhookEventType.PayoutUpdated, (WebhookPayoutEvent e) =>
+ {
+ Assert.Equal(payout.Id, e.PayoutId);
+ Assert.Equal(PayoutState.Completed, e.PayoutState);
+ });
+ var completed = await client.GetPullPaymentPayout(pullPayment.Id, payout.Id);
+ Assert.Equal(PayoutState.Completed, completed.State);
+ Assert.Equal(replacementTxId, completed.PaymentProof.ToObject<PayoutTransactionOnChainBlob>().TransactionId);
+ }
+ }
+ catch
+ {
+ // Diagnostics must not replace the original failure (or retry the broadcast).
+ try
+ {
+ TestLogs.LogInformation($"Failure URL: {s.Page.Url}\nOriginal: {originalTxId}\nReplacement: {replacementTxId}");
+ TestLogs.LogInformation(await s.Page.Locator("body").InnerTextAsync());
+ var directory = Path.Combine(Environment.GetEnvironmentVariable("TESTS_ARTIFACTS_DIR") ?? "Screenshots", s.Server.Scope);
+ Directory.CreateDirectory(directory);
+ await File.WriteAllTextAsync(Path.Combine(directory, "rbf-failure.html"), await s.Page.ContentAsync());
+ await s.TakeScreenshot("rbf-failure.png");
+ await s.Page.Context.Tracing.StopAsync(new() { Path = Path.Combine(directory, "rbf-trace.zip") });
+ TestLogs.LogInformation($"Mempool: {string.Join(", ", await s.Server.ExplorerNode.GetRawMempoolAsync())}");
+ TestLogs.LogInformation($"Payouts: {JsonConvert.SerializeObject(await client.GetPayouts(pullPayment.Id))}");
+ }
+ catch (Exception diagnosticsError)
+ {
+ TestLogs.LogInformation($"Unable to capture RBF diagnostics: {diagnosticsError}");
+ }
+ throw;
+ }
+ await s.Page.Context.Tracing.StopAsync();
+ }
+
[Fact]
[Trait("Playwright", "Playwright-2")]
[Trait("Lightning", "Lightning")]
@@ -51,8 +161,6 @@ async Task<PayoutData> ClickClaimAmount()
await s.RegisterNewUser(true);
await s.CreateNewStore();
await s.GenerateWallet("BTC", "", true);
- var webhookAccount = s.AsTestAccount();
- await webhookAccount.SetupWebhook();
await s.Server.ExplorerNode.GenerateAsync(1);
await s.FundStoreWallet(denomination: 50.0m);
@@ -78,7 +186,6 @@ async Task<PayoutData> ClickClaimAmount()
await s.ClickPagePrimary();
string viewPullPaymentUrl;
- PayoutData payoutForWebhook;
// This should select the first View, ie, the last one PP2
await using (await s.SwitchPage(async () =>
{
@@ -88,7 +195,7 @@ async Task<PayoutData> ClickClaimAmount()
var address = await s.Server.ExplorerNode.GetNewAddressAsync();
await s.Page.FillAsync("#Destination", address.ToString());
await s.Page.FillAsync("#ClaimedAmount", "15");
- payoutForWebhook = await ClickClaimAmount();
+ await ClickClaimAmount();
await s.FindAlertMessage();
// We should not be able to use an address already used
@@ -131,15 +238,6 @@ async Task<PayoutData> ClickClaimAmount()
await pmo.AssertHasLabels("payout");
await pmo.AssertHasLabels("pull-payment");
- var client = await webhookAccount.CreateClient();
- var payoutTransaction = Assert.Single(await client.ShowOnChainWalletTransactions(s.StoreId, "BTC"),
- transaction => transaction.Confirmations == 0);
- await pmo.BumpFee(payoutTransaction.TransactionHash);
- await Expect(s.Page.Locator("#BumpMethod option:checked")).ToHaveTextAsync("RBF");
- await s.ClickPagePrimary();
- await s.Page.ClickAsync("#BroadcastTransaction");
- await s.FindAlertMessage(partialText: "Transaction broadcasted successfully");
-
await s.GoToStore(s.StoreId, StoreNavPages.Payouts);
await s.Page.ClickAsync($"#{PayoutState.InProgress}-view");
@@ -150,11 +248,6 @@ async Task<PayoutData> ClickClaimAmount()
await Expect(s.Page.Locator("body")).ToContainTextAsync(PayoutState.InProgress.GetStateString());
await s.Server.ExplorerNode.GenerateAsync(1);
- await webhookAccount.AssertHasWebhookEvent(WebhookEventType.PayoutUpdated, (WebhookPayoutEvent payoutEvent) =>
- {
- Assert.Equal(payoutForWebhook.Id, payoutEvent.PayoutId);
- Assert.Equal(PayoutState.Completed, payoutEvent.PayoutState);
- });
await TestUtils.EventuallyAsync(async () =>
{
### BTCPayServer/Plugins/Wallets/Views/UIWallets/SigningContext.cshtml
@@ -2,7 +2,7 @@
@if (Model != null)
{
- <input type="hidden" asp-for="PSBT" value="@Model.PSBT"/>
+ <input type="hidden" asp-for="PSBT" value="@Model.PSBT" class="signing-context__psbt"/>
<input type="hidden" asp-for="OriginalPSBT" value="@Model.OriginalPSBT"/>
<input type="hidden" asp-for="PayJoinBIP21" value="@Model.PayJoinBIP21"/>
<input type="hidden" asp-for="EnforceLowR" value="@Model.EnforceLowR" />
### BTCPayServer/Plugins/Wallets/Views/UIWallets/WalletBumpFee.cshtml
@@ -125,7 +125,7 @@
<label asp-for="BumpMethod" class="form-label"></label>
<select asp-for="BumpMethod" asp-items="@Model.BumpFeeMethods"
disabled="@(Model.BumpFeeMethods.Count == 1)"
- class="form-select w-auto"></select>
+ class="wallet-bump-fee__method form-select w-auto"></select>
</div>
</div>
</div>
### BTCPayServer/Plugins/Wallets/Views/UIWallets/WalletPSBTDecoded.cshtml
@@ -132,7 +132,7 @@ else if (isReady)
}
else
{
- <button id="BroadcastTransaction" type="submit" class="btn btn-primary" name="command" value="broadcast" text-translate="true">Broadcast transaction</button>
+ <button id="BroadcastTransaction" type="submit" class="wallet-psbt__broadcast btn btn-primary" name="command" value="broadcast" text-translate="true">Broadcast transaction</button>
}
</div>
</form>Why this scored 22/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.