[skip CI] Better naming
MODIFY
WalletWasabi.Backend/Controllers/ChaumianCoinJoinController.cs
WalletWasabi.Backend/Controllers/ChaumianCoinJoinController.cs
@@ -618,7 +618,7 @@ namespace WalletWasabi.Backend.Controllers
}
// Check duplicates.
- if (round.SignedCoinJoin.Inputs[index].HasWitness())
+ if (round.SignedCoinJoin.Inputs[index].HasWitScript())
{
return BadRequest($"Input is already signed.");
}

MODIFY
WalletWasabi/Extensions/NBitcoinExtensions.cs
WalletWasabi/Extensions/NBitcoinExtensions.cs
@@ -34,8 +34,14 @@ namespace NBitcoin
me.FromBytes(ByteHelpers.FromHex(hex));
}
- public static bool SpendsOrReceivesWitness(this Transaction me)
+ /// <summary>
+ /// Based on transaction data, it decides if it's possible that native segwit script played a par in this transaction.
+ /// </summary>
+ public static bool PossiblyNativeSegWitInvolved(this Transaction me)
{
+ // We omit Guard, because it's performance critical in Wasabi.
+ // We start with the inputs, because, this check is faster.
+ // Note: by testing performance the order doesn't seem to affect the speed of loading the wallet.
foreach (TxIn input in me.Inputs)
{
if (input.ScriptSig is null || input.ScriptSig == Script.Empty)
@@ -75,7 +81,7 @@ namespace NBitcoin
/// <summary>
/// Careful, if it's in a legacy block then this won't work.
/// </summary>
- public static bool HasWitness(this TxIn me)
+ public static bool HasWitScript(this TxIn me)
{
Guard.NotNull(nameof(me), me);

MODIFY
WalletWasabi/Models/ChaumianCoinJoin/CcjRound.cs
WalletWasabi/Models/ChaumianCoinJoin/CcjRound.cs
@@ -717,7 +717,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
using (await RoundSynchronizerLock.LockAsync())
{
// Check if fully signed.
- if (SignedCoinJoin.Inputs.All(x => x.HasWitness()))
+ if (SignedCoinJoin.Inputs.All(x => x.HasWitScript()))
{
Logger.LogInfo<CcjRound>($"Round ({RoundId}): Trying to broadcast coinjoin.");

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -385,7 +385,7 @@ namespace WalletWasabi.Services
if (tx.Height.Type == HeightType.Chain)
{
MemPool.TransactionHashes.TryRemove(txId); // If we have in mempool, remove.
- if (!tx.Transaction.SpendsOrReceivesWitness()) return; // We don't care about non-witness transactions for other than mempool cleanup.
+ if (!tx.Transaction.PossiblyNativeSegWitInvolved()) return; // We don't care about non-witness transactions for other than mempool cleanup.
bool isFoundTx = TransactionCache.Contains(tx); // If we have in cache, update height.
if (isFoundTx)
@@ -397,7 +397,7 @@ namespace WalletWasabi.Services
}
}
}
- else if (!tx.Transaction.SpendsOrReceivesWitness())
+ else if (!tx.Transaction.PossiblyNativeSegWitInvolved())
{
return; // We don't care about non-witness transactions for other than mempool cleanup.
}

[skip CI] Better naming