Do not reuse outpoint used in ongoing pending transactions (#6699)

This commit is contained in:
Nicolas Dorier
2025-04-28 16:17:23 +09:00
committed by GitHub
parent ee83769a7b
commit 41e1eb1be2
5 changed files with 13 additions and 4 deletions

View File

@@ -4,6 +4,8 @@ early_access: false
enable_free_tier: true
auto_resolve_threads: true
reviews:
summaries:
include_walkthrough: false
profile: chill
request_changes_workflow: false
high_level_summary: false

View File

@@ -207,7 +207,7 @@ namespace BTCPayServer.Tests
Assert.Equal("paid", invoice.Status);
});
var wallet = tester.PayTester.GetController<UIWalletsController>();
var psbt = await wallet.CreatePSBT(btcNetwork, onchainBTC,
var psbt = await wallet.CreatePSBT(storeId, btcNetwork, onchainBTC,
new WalletSendModel()
{
Outputs = new List<WalletSendModel.TransactionOutput>

View File

@@ -535,7 +535,7 @@ namespace BTCPayServer.Controllers.Greenfield
CreatePSBTResponse psbt;
try
{
psbt = await _walletsController.CreatePSBT(network, derivationScheme,
psbt = await _walletsController.CreatePSBT(storeId, network, derivationScheme,
new WalletSendModel()
{
SelectedInputs = request.SelectedInputs?.Select(point => point.ToString()),

View File

@@ -24,7 +24,12 @@ namespace BTCPayServer.Controllers
public partial class UIWalletsController
{
[NonAction]
public async Task<CreatePSBTResponse> CreatePSBT(BTCPayNetwork network, DerivationSchemeSettings derivationSettings, WalletSendModel sendModel, CancellationToken cancellationToken)
[Obsolete("Use CreatePSBT(string storeId, BTCPayNetwork network, DerivationSchemeSettings derivationSettings, WalletSendModel sendModel, CancellationToken cancellationToken) instead")]
public Task<CreatePSBTResponse> CreatePSBT(BTCPayNetwork network, DerivationSchemeSettings derivationSettings, WalletSendModel sendModel,
CancellationToken cancellationToken)
=> CreatePSBT(null, network, derivationSettings, sendModel, cancellationToken);
[NonAction]
public async Task<CreatePSBTResponse> CreatePSBT(string storeId, BTCPayNetwork network, DerivationSchemeSettings derivationSettings, WalletSendModel sendModel, CancellationToken cancellationToken)
{
var nbx = ExplorerClientProvider.GetExplorerClient(network);
var psbtRequest = new CreatePSBTRequest()
@@ -46,6 +51,8 @@ namespace BTCPayServer.Controllers
psbtDestination.SubstractFees = transactionOutput.SubtractFeesFromOutput;
}
var pending = await _pendingTransactionService.GetPendingTransactions(network.CryptoCode, storeId ?? "");
psbtRequest.ExcludeOutpoints = pending.SelectMany(p => p.OutpointsUsed).Select(OutPoint.Parse).ToList();
psbtRequest.FeePreference = new FeePreference();
if (sendModel.FeeSatoshiPerByte is decimal v and > decimal.Zero)
{

View File

@@ -1202,7 +1202,7 @@ namespace BTCPayServer.Controllers
try
{
psbtResponse = await CreatePSBT(network, derivationScheme, vm, cancellation);
psbtResponse = await CreatePSBT(walletId.StoreId, network, derivationScheme, vm, cancellation);
}
catch (NBXplorerException ex)
{