Allow excluding unconfirmed UTXOs when creating a new transaction with Greenfield API

See original request: https://github.com/btcpayserver/btcpayserver/discussions/3737
This commit is contained in:
Umar Bolatov
2022-06-09 20:58:51 -07:00
committed by Andrew Camilleri
parent fd3d389557
commit d0e01768ab
6 changed files with 37 additions and 4 deletions

View File

@@ -376,10 +376,20 @@ namespace BTCPayServer.Controllers.Greenfield
return this.CreateValidationError(ModelState);
}
if (request.SelectedInputs != null && request.ExcludeUnconfirmed == true)
{
ModelState.AddModelError(
nameof(request.ExcludeUnconfirmed),
"Can't automatically exclude unconfirmed UTXOs while selection custom inputs"
);
return this.CreateValidationError(ModelState);
}
var explorerClient = _explorerClientProvider.GetExplorerClient(cryptoCode);
var wallet = _btcPayWalletProvider.GetWallet(network);
var utxos = await wallet.GetUnspentCoins(derivationScheme.AccountDerivation);
var utxos = await wallet.GetUnspentCoins(derivationScheme.AccountDerivation, request.ExcludeUnconfirmed);
if (request.SelectedInputs != null || !utxos.Any())
{
utxos = utxos.Where(coin => request.SelectedInputs?.Contains(coin.OutPoint) ?? true)