OutPoint magic
MODIFY
WalletWasabi.Tests/UnitTests/Transactions/TransactionProcessorTests.cs
WalletWasabi.Tests/UnitTests/Transactions/TransactionProcessorTests.cs
@@ -1026,7 +1026,7 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
{
cjtx.Outputs.Add(Money.Coins(0.1m), Script.Empty);
}
- cjtx.Inputs.Add(receivedCoin.GetOutPoint(), Script.Empty, WitScript.Empty);
+ cjtx.Inputs.Add(receivedCoin.OutPoint, Script.Empty, WitScript.Empty);
cjtx.Outputs.Add(Money.Coins(0.1m), transactionProcessor.NewKey("").P2wpkhScript);
cjtx.Outputs.Add(Money.Coins(0.9m), transactionProcessor.NewKey("").P2wpkhScript);
var tx1 = new SmartTransaction(cjtx, Height.Mempool);

MODIFY
WalletWasabi/Blockchain/TransactionOutputs/CoinsRegistry.cs
WalletWasabi/Blockchain/TransactionOutputs/CoinsRegistry.cs
@@ -141,7 +141,7 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
SpentCoins.Remove(toRemove);
}
- var removedCoinOutPoint = toRemove.GetOutPoint();
+ var removedCoinOutPoint = toRemove.OutPoint;
// If we can find it in our outpoint to coins cache.
if (TryGetSpenderSmartCoinsByOutPointNoLock(removedCoinOutPoint, out var coinsByOutPoint))
@@ -270,6 +270,8 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
public ICoinsView OutPoints(IEnumerable<TxoRef> outPoints) => AsCoinsView().OutPoints(outPoints);
+ public ICoinsView OutPoints(TxInList txIns) => AsCoinsView().OutPoints(txIns);
+
public ICoinsView CreatedBy(uint256 txid) => AsCoinsView().CreatedBy(txid);
private ICoinsView CreatedByNoLock(uint256 txid) => AsCoinsViewNoLock().CreatedBy(txid);

MODIFY
WalletWasabi/Blockchain/TransactionOutputs/CoinsView.cs
WalletWasabi/Blockchain/TransactionOutputs/CoinsView.cs
@@ -59,7 +59,14 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
public ICoinsView OutPoints(IEnumerable<TxoRef> outPoints) => new CoinsView(Coins.Where(x => outPoints.Any(y => y == x.GetTxoRef())));
- public SmartCoin GetByOutPoint(OutPoint outpoint) => Coins.FirstOrDefault(x => x.GetOutPoint() == outpoint);
+ public ICoinsView OutPoints(TxInList txIns)
+ {
+ var outPointSet = txIns.Select(x => x.PrevOut).ToHashSet();
+ var smartCoins = Coins.Where(x => outPointSet.Contains(x.OutPoint));
+ return new CoinsView(smartCoins);
+ }
+
+ public SmartCoin GetByOutPoint(OutPoint outpoint) => Coins.FirstOrDefault(x => x.OutPoint == outpoint);
public Money TotalAmount() => Coins.Sum(x => x.Amount);

MODIFY
WalletWasabi/Blockchain/TransactionOutputs/SmartCoin.cs
WalletWasabi/Blockchain/TransactionOutputs/SmartCoin.cs
@@ -18,8 +18,6 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
{
#region Fields
- private uint256 _transactionId;
- private uint _index;
private Script _scriptPubKey;
private Money _amount;
private Height _height;
@@ -46,17 +44,11 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
#region Properties
- public uint256 TransactionId
- {
- get => _transactionId;
- private set => RaiseAndSetIfChanged(ref _transactionId, value);
- }
+ public uint256 TransactionId { get; private set; }
- public uint Index
- {
- get => _index;
- private set => RaiseAndSetIfChanged(ref _index, value);
- }
+ public uint Index { get; private set; }
+
+ public OutPoint OutPoint { get; private set; }
public Script ScriptPubKey
{
@@ -270,6 +262,7 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
{
TransactionId = Guard.NotNull(nameof(transactionId), transactionId);
Index = Guard.NotNull(nameof(index), index);
+ OutPoint = new OutPoint(TransactionId, Index);
ScriptPubKey = Guard.NotNull(nameof(scriptPubKey), scriptPubKey);
Amount = Guard.NotNull(nameof(amount), amount);
Height = height;
@@ -305,11 +298,6 @@ namespace WalletWasabi.Blockchain.TransactionOutputs
return new Coin(TransactionId, Index, Amount, ScriptPubKey);
}
- public OutPoint GetOutPoint()
- {
- return new OutPoint(TransactionId, Index);
- }
-
public TxoRef GetTxoRef()
{
return new TxoRef(TransactionId, Index);

MODIFY
WalletWasabi/Blockchain/TransactionProcessing/TransactionProcessor.cs
WalletWasabi/Blockchain/TransactionProcessing/TransactionProcessor.cs
@@ -179,7 +179,7 @@ namespace WalletWasabi.Blockchain.TransactionProcessing
}
foundKey.SetKeyState(KeyState.Used, KeyManager);
- spentOwnCoins ??= Coins.OutPoints(tx.Transaction.Inputs.ToTxoRefs()).ToList();
+ spentOwnCoins ??= Coins.OutPoints(tx.Transaction.Inputs).ToList();
var anonset = tx.Transaction.GetAnonymitySet(i);
if (spentOwnCoins.Count != 0)
{
@@ -229,7 +229,7 @@ namespace WalletWasabi.Blockchain.TransactionProcessing
foreach (var coin in Coins.AsAllCoinsView())
{
// If spends any of our coin
- if (prevOutSet.TryGetValue(coin.GetOutPoint(), out OutPoint input))
+ if (prevOutSet.TryGetValue(coin.OutPoint, out OutPoint input))
{
var alreadyKnown = coin.SpenderTransactionId == txId;
coin.SpenderTransactionId = txId;

MODIFY
WalletWasabi/Blockchain/Transactions/TransactionFactory.cs
WalletWasabi/Blockchain/Transactions/TransactionFactory.cs
@@ -150,7 +150,7 @@ namespace WalletWasabi.Blockchain.Transactions
var psbt = builder.BuildPSBT(false);
- var spentCoins = psbt.Inputs.Select(txin => allowedSmartCoinInputs.First(y => y.GetOutPoint() == txin.PrevOut)).ToArray();
+ var spentCoins = psbt.Inputs.Select(txin => allowedSmartCoinInputs.First(y => y.OutPoint == txin.PrevOut)).ToArray();
var realToSend = payments.Requests
.Select(t =>

MODIFY
WalletWasabi/CoinJoin/Client/Clients/CoinJoinClient.cs
WalletWasabi/CoinJoin/Client/Clients/CoinJoinClient.cs
@@ -388,7 +388,7 @@ namespace WalletWasabi.CoinJoin.Client.Clients
for (int i = 0; i < signedCoinJoin.Inputs.Count; i++)
{
var input = signedCoinJoin.Inputs[i];
- if (ongoingRound.CoinsRegistered.Select(x => x.GetOutPoint()).Contains(input.PrevOut))
+ if (ongoingRound.CoinsRegistered.Select(x => x.OutPoint).Contains(input.PrevOut))
{
myDic.Add(i, signedCoinJoin.Inputs[i].WitScript);
}

OutPoint magic