mirror of
https://github.com/aljazceru/BTCPayServerPlugins.git
synced 2025-12-17 07:34:24 +01:00
upd
This commit is contained in:
@@ -104,7 +104,9 @@ public class BTCPayCoinjoinCoinSelector : IRoundCoinSelector
|
||||
utxoSelectionParameters);
|
||||
var fullyPrivate = remainingCoins.All(coin => coin.CoinColor(_wallet.AnonScoreTarget) == AnonsetType.Green);
|
||||
var coinjoiningOnlyForPayments = fullyPrivate && remainingPendingPayments.Any();
|
||||
if (fullyPrivate && !coinjoiningOnlyForPayments)
|
||||
var isMixingToOther = !_wallet.WabisabiStoreSettings.PlebMode &&
|
||||
!string.IsNullOrEmpty(_wallet.WabisabiStoreSettings.MixToOtherWallet);
|
||||
if (fullyPrivate && !coinjoiningOnlyForPayments && !isMixingToOther)
|
||||
{
|
||||
var rand = Random.Shared.Next(1, 1001);
|
||||
if (rand > _wallet.WabisabiStoreSettings.ExtraJoinProbability)
|
||||
|
||||
@@ -378,7 +378,8 @@ public class BTCPayWallet : IWallet, IDestinationProvider
|
||||
continue;
|
||||
}
|
||||
|
||||
scriptInfos.Add((txout, ExplorerClient.GetKeyInformationAsync(BlockchainAnalyzer.StdDenoms.Contains(txout.TxOut.Value)?utxoDerivationScheme:DerivationScheme, script.ScriptPubKey)));
|
||||
var privateEnough = result.Coins.All(c => c.AnonymitySet >= WabisabiStoreSettings.AnonymitySetTarget );
|
||||
scriptInfos.Add((txout, ExplorerClient.GetKeyInformationAsync(BlockchainAnalyzer.StdDenoms.Contains(txout.TxOut.Value)&& privateEnough?utxoDerivationScheme:DerivationScheme, script.ScriptPubKey)));
|
||||
}
|
||||
|
||||
await Task.WhenAll(scriptInfos.Select(t => t.Item2));
|
||||
@@ -441,6 +442,10 @@ public class BTCPayWallet : IWallet, IDestinationProvider
|
||||
Outpoint = new OutPoint(result.UnsignedCoinJoin, pair.Key.N).ToString()
|
||||
})).ToArray()
|
||||
};
|
||||
foreach (var smartTxWalletOutput in smartTx.WalletOutputs)
|
||||
{
|
||||
Smartifier.SetIsSufficientlyDistancedFromExternalKeys(smartTxWalletOutput, cjData);
|
||||
}
|
||||
|
||||
var attachments = new List<Attachment>()
|
||||
{
|
||||
@@ -585,9 +590,9 @@ public class BTCPayWallet : IWallet, IDestinationProvider
|
||||
// Logger.LogTrace($"unlocked utxos: {string.Join(',', unlocked)}");
|
||||
// }
|
||||
|
||||
public async Task<IEnumerable<IDestination>> GetNextDestinationsAsync(int count, bool mixedOutputs)
|
||||
public async Task<IEnumerable<IDestination>> GetNextDestinationsAsync(int count, bool mixedOutputs, bool privateEnough)
|
||||
{
|
||||
if (!WabisabiStoreSettings.PlebMode && !string.IsNullOrEmpty(WabisabiStoreSettings.MixToOtherWallet) && mixedOutputs)
|
||||
if (!WabisabiStoreSettings.PlebMode && !string.IsNullOrEmpty(WabisabiStoreSettings.MixToOtherWallet) && mixedOutputs && privateEnough)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@ using NBitcoin;
|
||||
using NBXplorer;
|
||||
using NBXplorer.DerivationStrategy;
|
||||
using NBXplorer.Models;
|
||||
using WalletWasabi.Blockchain.Analysis;
|
||||
using WalletWasabi.Blockchain.Analysis.Clustering;
|
||||
using WalletWasabi.Blockchain.Keys;
|
||||
using WalletWasabi.Blockchain.TransactionOutputs;
|
||||
@@ -85,6 +86,7 @@ public class Smartifier
|
||||
|
||||
public async Task<TransactionInformation?> GetTransactionInfo(uint256 hash)
|
||||
{
|
||||
|
||||
return await GetOrCreate(TransactionInformations , hash, () => _explorerClient.GetTransactionAsync(DerivationScheme, hash), _logger);
|
||||
}
|
||||
|
||||
@@ -199,20 +201,32 @@ public class Smartifier
|
||||
|
||||
hdPubKey.SetAnonymitySet(labels.anonset);
|
||||
var c = new SmartCoin(tx, coin.OutPoint.N, hdPubKey);
|
||||
c.IsSufficientlyDistancedFromExternalKeys = labels.coinjoinData is not null;
|
||||
if (labels.coinjoinData is not null)
|
||||
{
|
||||
|
||||
SetIsSufficientlyDistancedFromExternalKeys(c, labels.coinjoinData);
|
||||
}
|
||||
c.PropertyChanged += CoinPropertyChanged;
|
||||
return c;
|
||||
});
|
||||
|
||||
utxoLabels.TryGetValue(coin.OutPoint, out var labels);
|
||||
smartCoin.HdPubKey.SetLabel(new LabelsArray(labels.labels ?? new HashSet<string>()));
|
||||
smartCoin.HdPubKey.SetKeyState(current == 1 ? KeyState.Clean : KeyState.Used);
|
||||
smartCoin.HdPubKey.SetAnonymitySet(labels.anonset);
|
||||
if (labels.coinjoinData is not null)
|
||||
{
|
||||
SetIsSufficientlyDistancedFromExternalKeys(smartCoin, labels.coinjoinData);
|
||||
}
|
||||
tx.TryAddWalletOutput(smartCoin);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetIsSufficientlyDistancedFromExternalKeys(SmartCoin c, BTCPayWallet.CoinjoinData coinjoinData)
|
||||
{
|
||||
c.IsSufficientlyDistancedFromExternalKeys = coinjoinData.CoinsIn.All(dataCoin => dataCoin.AnonymitySet >1);
|
||||
}
|
||||
|
||||
private void CoinPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender is SmartCoin smartCoin && e.PropertyName == nameof(SmartCoin.CoinJoinInProgress))
|
||||
|
||||
@@ -158,7 +158,8 @@ const config = {
|
||||
`${coin.score.toFixed(2)} anonset`,
|
||||
`${coin.confirmed ? "confirmed" : "unconfirmed"}`,
|
||||
coin.isPrivate ? "private" : "not private",
|
||||
...(coin.coinjoinInProgress ? ["mixing"] : [])
|
||||
...(coin.coinjoinInProgress ? ["mixing"] : []),
|
||||
...(!coin.isPrivate && coin.score >= data.targetScore? ["Coin too close to entry to deem private just yet"] : [])
|
||||
];
|
||||
},
|
||||
title: function (context) {
|
||||
@@ -215,8 +216,8 @@ const config = {
|
||||
const totalPrivateValueSum = data.coins.filter(coin => coin.isPrivate).reduce((sum, coin) => sum + coin.value, 0);
|
||||
if (totalPrivateSum > 0)
|
||||
lineTexts.push(`${totalPrivateSum} coins(${totalPrivateValueSum.toFixed(8)}BTC) private`);
|
||||
const totalNonPrivateSum = data.coins.filter(coin => !coin.isPrivate && !coin.coinjoinInProgress).length;
|
||||
const totalNonPrivateValueSum = data.coins.filter(coin => !coin.isPrivate && !coin.coinjoinInProgress).reduce((sum, coin) => sum + coin.value, 0);
|
||||
const totalNonPrivateSum = data.coins.filter(coin => !coin.isPrivate).length;
|
||||
const totalNonPrivateValueSum = data.coins.filter(coin => !coin.isPrivate).reduce((sum, coin) => sum + coin.value, 0);
|
||||
if (totalNonPrivateSum > 0)
|
||||
lineTexts.push(`${totalNonPrivateSum} coins(${totalNonPrivateValueSum.toFixed(8)}BTC) semi/not private`);
|
||||
const totalInProgressSum = data.coins.filter(coin => coin.coinjoinInProgress).length;
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
@using BTCPayServer.Security
|
||||
|
||||
@using NBitcoin
|
||||
@using BTCPayServer.Abstractions.Contracts
|
||||
@using BTCPayServer.Plugins.Wabisabi
|
||||
@using WalletWasabi.Blockchain.Analysis
|
||||
@model BTCPayServer.Models.WalletViewModels.WalletSendModel
|
||||
|
||||
@inject ContentSecurityPolicies contentSecurityPolicies
|
||||
@inject WalletProvider _walletProvider
|
||||
@inject IScopeProvider ScopeProvider
|
||||
@{
|
||||
var nonce = RandomUtils.GetUInt256().ToString().Substring(0, 32);
|
||||
contentSecurityPolicies.Add("script-src", $"'nonce-{nonce}'");
|
||||
contentSecurityPolicies.AllowUnsafeHashes();
|
||||
var storeId = ScopeProvider.GetCurrentStoreId();
|
||||
var w = await _walletProvider.GetWalletAsync(storeId);
|
||||
}
|
||||
@@ -40,7 +36,7 @@
|
||||
</datalist>
|
||||
|
||||
|
||||
<script type="text/javascript" nonce="@nonce">
|
||||
<script type="text/javascript">
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
const amountElements = document.querySelectorAll("[name^='Outputs'][name$='Amount']");
|
||||
|
||||
Submodule submodules/walletwasabi updated: 3ae7642211...2ffaba5965
Reference in New Issue
Block a user