mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-23 22:46:49 +01:00
Merge pull request #1410 from Kukks/coin-selection-fix
fix coin selection
This commit is contained in:
commit
c633402fe2
2 changed files with 22 additions and 1 deletions
|
@ -12,6 +12,8 @@ using System.Text.RegularExpressions;
|
||||||
using BTCPayServer.Models;
|
using BTCPayServer.Models;
|
||||||
using NBitcoin.Payment;
|
using NBitcoin.Payment;
|
||||||
using BTCPayServer.Controllers;
|
using BTCPayServer.Controllers;
|
||||||
|
using BTCPayServer.Data;
|
||||||
|
using BTCPayServer.Services.Wallets;
|
||||||
|
|
||||||
namespace BTCPayServer.Tests
|
namespace BTCPayServer.Tests
|
||||||
{
|
{
|
||||||
|
@ -442,13 +444,28 @@ namespace BTCPayServer.Tests
|
||||||
var targetTx = await s.Server.ExplorerNode.SendToAddressAsync(address, Money.Coins(1.2m));
|
var targetTx = await s.Server.ExplorerNode.SendToAddressAsync(address, Money.Coins(1.2m));
|
||||||
var tx = await s.Server.ExplorerNode.GetRawTransactionAsync(targetTx);
|
var tx = await s.Server.ExplorerNode.GetRawTransactionAsync(targetTx);
|
||||||
var spentOutpoint = new OutPoint(targetTx, tx.Outputs.FindIndex(txout => txout.Value == Money.Coins(1.2m)));
|
var spentOutpoint = new OutPoint(targetTx, tx.Outputs.FindIndex(txout => txout.Value == Money.Coins(1.2m)));
|
||||||
|
await TestUtils.EventuallyAsync(async () =>
|
||||||
|
{
|
||||||
|
var store = await s.Server.PayTester.StoreRepository.FindStore(storeId);
|
||||||
|
var x = store.GetSupportedPaymentMethods(s.Server.NetworkProvider)
|
||||||
|
.OfType<DerivationSchemeSettings>()
|
||||||
|
.Single(settings => settings.PaymentId.CryptoCode == walletId.CryptoCode);
|
||||||
|
Assert.Contains(
|
||||||
|
await s.Server.PayTester.GetService<BTCPayWalletProvider>().GetWallet(walletId.CryptoCode)
|
||||||
|
.GetUnspentCoins(x.AccountDerivation),
|
||||||
|
coin => coin.OutPoint == spentOutpoint);
|
||||||
|
});
|
||||||
await s.Server.ExplorerNode.GenerateAsync(1);
|
await s.Server.ExplorerNode.GenerateAsync(1);
|
||||||
s.GoToWalletSend(walletId);
|
s.GoToWalletSend(walletId);
|
||||||
s.Driver.FindElement(By.Id("advancedSettings")).Click();
|
s.Driver.FindElement(By.Id("advancedSettings")).Click();
|
||||||
s.Driver.FindElement(By.Id("toggleInputSelection")).Click();
|
s.Driver.FindElement(By.Id("toggleInputSelection")).Click();
|
||||||
s.Driver.WaitForElement(By.Id(spentOutpoint.ToString()));
|
s.Driver.WaitForElement(By.Id(spentOutpoint.ToString()));
|
||||||
|
Assert.Equal("true", s.Driver.FindElement(By.Name("InputSelection")).GetAttribute("value").ToLowerInvariant());
|
||||||
var el = s.Driver.FindElement(By.Id(spentOutpoint.ToString()));
|
var el = s.Driver.FindElement(By.Id(spentOutpoint.ToString()));
|
||||||
s.Driver.FindElement(By.Id(spentOutpoint.ToString())).Click();
|
s.Driver.FindElement(By.Id(spentOutpoint.ToString())).Click();
|
||||||
|
var inputSelectionSelect = s.Driver.FindElement(By.Name("SelectedInputs"));
|
||||||
|
Assert.Single(inputSelectionSelect.FindElements(By.CssSelector("[selected]")));
|
||||||
|
|
||||||
var bob = new Key().PubKey.Hash.GetAddress(Network.RegTest);
|
var bob = new Key().PubKey.Hash.GetAddress(Network.RegTest);
|
||||||
SetTransactionOutput(s, 0, bob, 0.3m);
|
SetTransactionOutput(s, 0, bob, 0.3m);
|
||||||
s.Driver.FindElement(By.Id("SendMenu")).Click();
|
s.Driver.FindElement(By.Id("SendMenu")).Click();
|
||||||
|
|
|
@ -179,7 +179,11 @@ $(function () {
|
||||||
res.splice(this.selectedInputs.indexOf(item.outpoint),1);
|
res.splice(this.selectedInputs.indexOf(item.outpoint),1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#SelectedInputs").val(res);
|
$("select option").each(function(){
|
||||||
|
var selected = res.indexOf($(this).attr("value")) !== -1;
|
||||||
|
$(this).attr("selected",selected? "selected": null);
|
||||||
|
});
|
||||||
|
|
||||||
this.selectedInputs = res;
|
this.selectedInputs = res;
|
||||||
$(".crypto-balance-link").text(this.selectedAmount);
|
$(".crypto-balance-link").text(this.selectedAmount);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue