Implements TxOutList.GetCoins() extension method
Given a scriptPubkey, it returns the transaction's coins
with that scriptPubkey.
MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -473,7 +473,7 @@ namespace WalletWasabi.Tests
var firstCoin = wallet.Coins.Single();
Assert.Equal(new Money(0.1m, MoneyUnit.BTC), firstCoin.Amount);
Assert.Equal(indexDownloader.GetBestFilter().BlockHeight, firstCoin.Height);
- Assert.InRange(firstCoin.Index, 0, 1);
+ Assert.InRange(firstCoin.Index, 0U, 1U);
Assert.False(firstCoin.SpentOrLocked);
Assert.Equal("foo label", firstCoin.Label);
Assert.Equal(key.GetP2wpkhScript(), firstCoin.ScriptPubKey);
@@ -592,7 +592,7 @@ namespace WalletWasabi.Tests
Interlocked.Exchange(ref _filtersProcessedByWalletCount, 0);
await rpc.GenerateAsync(1);
await WaitForFiltersToBeProcessedAsync(TimeSpan.FromSeconds(120), 1);
- var res = await rpc.GetTxOutAsync(mempoolCoin.TransactionId, mempoolCoin.Index, true);
+ var res = await rpc.GetTxOutAsync(mempoolCoin.TransactionId, (int)mempoolCoin.Index, true);
Assert.Equal(indexDownloader.GetBestFilter().BlockHeight, mempoolCoin.Height);
}
finally
@@ -1696,9 +1696,9 @@ namespace WalletWasabi.Tests
var addr = await rpc.GetNewAddressAsync();
var hash = await rpc.SendToAddressAsync(addr, new Money(0.01m, MoneyUnit.BTC));
var tx = await rpc.GetRawTransactionAsync(hash);
- var index = tx.Outputs.GetIndexes(addr.ScriptPubKey).Single();
+ var coin = tx.Outputs.GetCoins(addr.ScriptPubKey).Single();
- inputsRequest.Inputs = new List<InputProofModel> { new InputProofModel { Input = new OutPoint(hash, index), Proof = "b" } };
+ inputsRequest.Inputs = new List<InputProofModel> { new InputProofModel { Input = coin.Outpoint, Proof = "b" } };
httpRequestException = await Assert.ThrowsAsync<HttpRequestException>(async () => await AliceClient.CreateNewAsync(inputsRequest, baseUri));
Assert.Equal($"{HttpStatusCode.BadRequest.ToReasonString()}\nProvided input is neither confirmed, nor is from an unconfirmed coinjoin.", httpRequestException.Message);
@@ -1718,8 +1718,8 @@ namespace WalletWasabi.Tests
hash = await rpc.SendToAddressAsync(witnessAddress, new Money(0.01m, MoneyUnit.BTC));
await rpc.GenerateAsync(1);
tx = await rpc.GetRawTransactionAsync(hash);
- index = tx.Outputs.GetIndexes(witnessAddress.ScriptPubKey).Single();
- inputsRequest.Inputs = new List<InputProofModel> { new InputProofModel { Input = new OutPoint(hash, index), Proof = "b" } };
+ coin = tx.Outputs.GetCoins(witnessAddress.ScriptPubKey).Single();
+ inputsRequest.Inputs = new List<InputProofModel> { new InputProofModel { Input = coin.Outpoint, Proof = "b" } };
httpRequestException = await Assert.ThrowsAsync<HttpRequestException>(async () => await AliceClient.CreateNewAsync(inputsRequest, baseUri));
Assert.StartsWith($"{HttpStatusCode.BadRequest.ToReasonString()}", httpRequestException.Message);
@@ -1812,9 +1812,9 @@ namespace WalletWasabi.Tests
hash = await rpc.SendToAddressAsync(witnessAddress, new Money(0.01m, MoneyUnit.BTC));
await rpc.GenerateAsync(1);
tx = await rpc.GetRawTransactionAsync(hash);
- index = tx.Outputs.GetIndexes(witnessAddress.ScriptPubKey).Single();
+ coin = tx.Outputs.GetCoins(witnessAddress.ScriptPubKey).Single();
proof = key.SignMessage(inputsRequest.BlindedOutputScriptHex);
- inputProofs.Add(new InputProofModel { Input = new OutPoint(hash, index), Proof = proof });
+ inputProofs.Add(new InputProofModel { Input = coin.Outpoint, Proof = proof });
}
await rpc.GenerateAsync(1);
@@ -1886,11 +1886,11 @@ namespace WalletWasabi.Tests
hash = await rpc.SendToAddressAsync(witnessAddress, new Money(0.01m, MoneyUnit.BTC));
await rpc.GenerateAsync(1);
tx = await rpc.GetRawTransactionAsync(hash);
- index = tx.Outputs.GetIndexes(witnessAddress.ScriptPubKey).Single();
+ coin = tx.Outputs.GetCoins(witnessAddress.ScriptPubKey).Single();
scriptBytes = new Key().PubKey.GetSegwitAddress(network).ScriptPubKey.ToBytes();
(BlindingFactor, BlindedData) = blindingKey.PubKey.Blind(scriptBytes);
- using (var aliceClient = await AliceClient.CreateNewAsync(new Key().PubKey.GetAddress(network), BlindedData, new InputProofModel[] { new InputProofModel { Input = new OutPoint(hash, index), Proof = key.SignMessage(ByteHelpers.ToHex(BlindedData)) } }, baseUri))
+ using (var aliceClient = await AliceClient.CreateNewAsync(new Key().PubKey.GetAddress(network), BlindedData, new InputProofModel[] { new InputProofModel { Input = coin.Outpoint, Proof = key.SignMessage(ByteHelpers.ToHex(BlindedData)) } }, baseUri))
{
Assert.NotNull(aliceClient.BlindedOutputSignature);
Assert.NotEqual(Guid.Empty, aliceClient.UniqueId);
@@ -1934,7 +1934,7 @@ namespace WalletWasabi.Tests
Assert.Equal($"{HttpStatusCode.Gone.ToReasonString()}\nRound is not running.", httpRequestException.Message);
}
- using (var aliceClient = await AliceClient.CreateNewAsync(new Key().PubKey.GetAddress(network), BlindedData, new InputProofModel[] { new InputProofModel { Input = new OutPoint(hash, index), Proof = key.SignMessage(ByteHelpers.ToHex(BlindedData)) } }, baseUri))
+ using (var aliceClient = await AliceClient.CreateNewAsync(new Key().PubKey.GetAddress(network), BlindedData, new InputProofModel[] { new InputProofModel { Input = coin.Outpoint, Proof = key.SignMessage(ByteHelpers.ToHex(BlindedData)) } }, baseUri))
{
Assert.NotNull(aliceClient.BlindedOutputSignature);
Assert.NotEqual(Guid.Empty, aliceClient.UniqueId);
@@ -2138,9 +2138,9 @@ namespace WalletWasabi.Tests
Assert.NotNull(txHash);
Transaction transaction = await rpc.GetRawTransactionAsync(txHash);
- var outputIndex = transaction.Outputs.GetIndexes(inputAddress.ScriptPubKey).Single();
+ var coin = transaction.Outputs.GetCoins(inputAddress.ScriptPubKey).Single();
- OutPoint input = new OutPoint(txHash, outputIndex);
+ OutPoint input = coin.Outpoint;
var inputProof = new InputProofModel { Input = input, Proof = key.SignMessage(ByteHelpers.ToHex(blinded.BlindedData)) };
inputProofModels.Add(inputProof);
@@ -2335,9 +2335,13 @@ namespace WalletWasabi.Tests
var tx3 = await rpc.GetRawTransactionAsync(txid3);
await rpc.GenerateAsync(1);
var height = await rpc.GetBlockCountAsync();
- var smartCoin1 = new SmartCoin(txid1, tx1.Outputs.GetIndexes(bech1.ScriptPubKey).Single(), bech1.ScriptPubKey, amount1, tx1.Inputs.Select(x => new TxoRef(x.PrevOut)).ToArray(), height, rbf: false, mixin: tx1.GetMixin(tx1.Outputs.GetIndexes(bech1.ScriptPubKey).Single()));
- var smartCoin2 = new SmartCoin(txid2, tx2.Outputs.GetIndexes(bech2.ScriptPubKey).Single(), bech2.ScriptPubKey, amount2, tx2.Inputs.Select(x => new TxoRef(x.PrevOut)).ToArray(), height, rbf: false, mixin: tx2.GetMixin(tx2.Outputs.GetIndexes(bech2.ScriptPubKey).Single()));
- var smartCoin3 = new SmartCoin(txid3, tx3.Outputs.GetIndexes(bech3.ScriptPubKey).Single(), bech3.ScriptPubKey, amount3, tx3.Inputs.Select(x => new TxoRef(x.PrevOut)).ToArray(), height, rbf: false, mixin: tx3.GetMixin(tx3.Outputs.GetIndexes(bech3.ScriptPubKey).Single()));
+ var bech1Coin =tx1.Outputs.GetCoins(bech1.ScriptPubKey).Single();
+ var bech2Coin =tx2.Outputs.GetCoins(bech2.ScriptPubKey).Single();
+ var bech3Coin =tx3.Outputs.GetCoins(bech3.ScriptPubKey).Single();
+
+ var smartCoin1 = new SmartCoin(bech1Coin, tx1.Inputs.Select(x => new TxoRef(x.PrevOut)).ToArray(), height, rbf: false, mixin: tx1.GetMixin(bech1Coin.Outpoint.N));
+ var smartCoin2 = new SmartCoin(bech2Coin, tx2.Inputs.Select(x => new TxoRef(x.PrevOut)).ToArray(), height, rbf: false, mixin: tx2.GetMixin(bech2Coin.Outpoint.N));
+ var smartCoin3 = new SmartCoin(bech3Coin, tx3.Inputs.Select(x => new TxoRef(x.PrevOut)).ToArray(), height, rbf: false, mixin: tx3.GetMixin(bech3Coin.Outpoint.N));
var chaumianClient1 = new CcjClient(rpc.Network, coordinator.RsaKey.PubKey, keyManager, new Uri(RegTestFixture.BackendEndPoint));
var chaumianClient2 = new CcjClient(rpc.Network, coordinator.RsaKey.PubKey, keyManager, new Uri(RegTestFixture.BackendEndPoint));
@@ -2443,9 +2447,14 @@ namespace WalletWasabi.Tests
var tx3 = await rpc.GetRawTransactionAsync(txid3);
await rpc.GenerateAsync(1);
var height = await rpc.GetBlockCountAsync();
- var smartCoin1 = new SmartCoin(txid1, tx1.Outputs.GetIndexes(bech1.ScriptPubKey).Single(), bech1.ScriptPubKey, amount1, tx1.Inputs.Select(x => new TxoRef(x.PrevOut)).ToArray(), height, rbf: false, mixin: tx1.GetMixin(tx1.Outputs.GetIndexes(bech1.ScriptPubKey).Single()));
- var smartCoin2 = new SmartCoin(txid2, tx2.Outputs.GetIndexes(bech2.ScriptPubKey).Single(), bech2.ScriptPubKey, amount2, tx2.Inputs.Select(x => new TxoRef(x.PrevOut)).ToArray(), height, rbf: false, mixin: tx2.GetMixin(tx2.Outputs.GetIndexes(bech2.ScriptPubKey).Single()));
- var smartCoin3 = new SmartCoin(txid3, tx3.Outputs.GetIndexes(bech3.ScriptPubKey).Single(), bech3.ScriptPubKey, amount3, tx3.Inputs.Select(x => new TxoRef(x.PrevOut)).ToArray(), height, rbf: false, mixin: tx3.GetMixin(tx3.Outputs.GetIndexes(bech3.ScriptPubKey).Single()));
+
+ var bech1Coin =tx1.Outputs.GetCoins(bech1.ScriptPubKey).Single();
+ var bech2Coin =tx2.Outputs.GetCoins(bech2.ScriptPubKey).Single();
+ var bech3Coin =tx3.Outputs.GetCoins(bech3.ScriptPubKey).Single();
+
+ var smartCoin1 = new SmartCoin(bech1Coin, tx1.Inputs.Select(x => new TxoRef(x.PrevOut)).ToArray(), height, rbf: false, mixin: tx1.GetMixin(bech1Coin.Outpoint.N));
+ var smartCoin2 = new SmartCoin(bech2Coin, tx2.Inputs.Select(x => new TxoRef(x.PrevOut)).ToArray(), height, rbf: false, mixin: tx2.GetMixin(bech2Coin.Outpoint.N));
+ var smartCoin3 = new SmartCoin(bech3Coin, tx3.Inputs.Select(x => new TxoRef(x.PrevOut)).ToArray(), height, rbf: false, mixin: tx3.GetMixin(bech3Coin.Outpoint.N));
var chaumianClient1 = new CcjClient(rpc.Network, coordinator.RsaKey.PubKey, keyManager, new Uri(RegTestFixture.BackendEndPoint));
var chaumianClient2 = new CcjClient(rpc.Network, coordinator.RsaKey.PubKey, keyManager, new Uri(RegTestFixture.BackendEndPoint));

MODIFY
WalletWasabi.Tests/SmartModelTests.cs
WalletWasabi.Tests/SmartModelTests.cs
@@ -21,7 +21,7 @@ namespace WalletWasabi.Tests
{
var tx = new Transaction("0100000000010176f521a178a4b394b647169a89b29bb0d95b6bce192fd686d533eb4ea98464a20000000000ffffffff02ed212d020000000016001442da650f25abde0fef57badd745df7346e3e7d46fbda6400000000001976a914bd2e4029ce7d6eca7d2c3779e8eac36c952afee488ac02483045022100ea43ccf95e1ac4e8b305c53761da7139dbf6ff164e137a6ce9c09e15f316c22902203957818bc505bbafc181052943d7ab1f3ae82c094bf749813e8f59108c6c268a012102e59e61f20c7789aa73faf5a92dc8c0424e538c635c55d64326d95059f0f8284200000000");
var txId = tx.GetHash();
- var index = 0;
+ var index = 0U;
var output = tx.Outputs[0];
var scriptPubKey = output.ScriptPubKey;
var amount = output.Value;
@@ -50,7 +50,7 @@ namespace WalletWasabi.Tests
{
var tx = new Transaction("02000000040aa8d0af84518df6e3a60c5bb19d9c3fcc3dc6e26b2f2449e8d7bf8d3fe84b87010000006a473044022018dfe9216c1209dd6c2b6c1607dbac4e499c1fce4878bc7d5d83fccbf3e24c9402202cac351c9c6a2b5eef338cbf0ec000d8de1c05e96a904cbba2b9e6ffc2d4e19501210364cc39da1091b1a9c12ec905a14a9e8478f951f7a1accdabeb40180533f2eaa5feffffff112c07d0f5e0617d720534f0b2b84dc0d5b7314b358c3ab338823b9e5bfbddf5010000006b483045022100ec155e7141e74661ee511ae980150a6c89261f31070999858738369afc28f2b6022006230d2aa24fac110b74ef15b84371486cf76c539b335a253c14462447912a300121020c2f41390f031d471b22abdb856e6cdbe0f4d74e72c197469bfd54e5a08f7e67feffffff38e799b8f6cf04fd021a9b135cdcd347da7aac4fd8bb8d0da9316a9fb228bb6e000000006b483045022100fc1944544a3f96edd8c8a9795c691e2725612b5ab2e1c999be11a2a4e3f841f1022077b2e088877829edeada0c707a9bb577aa79f26dafacba3d1d2d047f52524296012102e6015963dff9826836400cf8f45597c0705757d5dcdc6bf734f661c7dab89e69feffffff64c3f0377e86625123f2f1ee229319ed238e8ca8b7dda5bc080a2c5ecb984629000000006a47304402204233a90d6296182914424fd2901e16e6f5b13b451b67b0eec25a5eaacc5033c902203d8a13ef0b494c12009663475458e51da6bd55cc67688264230ece81d3eeca24012102f806d7152da2b52c1d9ad928e4a6253ccba080a5b9ab9efdd80e37274ac67f9bfeffffff0290406900000000001976a91491ac4e49b66f845180d98d8f8be6121588be6e3b88ac52371600000000001976a9142f44ed6749e8c84fd476e4440741f7e6f55542fa88acadd30700");
var txId = tx.GetHash();
- var index = 0;
+ var index = 0U;
var output = tx.Outputs[0];
var scriptPubKey = output.ScriptPubKey;
var amount = output.Value;

MODIFY
WalletWasabi/Extensions/NBitcoinExtensions.cs
WalletWasabi/Extensions/NBitcoinExtensions.cs
@@ -18,23 +18,9 @@ namespace NBitcoin
}
}
- public static IEnumerable<int> GetIndexes(this TxOutList me, Script script)
+ public static IEnumerable<Coin> GetCoins(this TxOutList me, Script script)
{
- var indexes = new List<int>();
- for (int i = 0; i < me.Count; i++)
- {
- var output = me[i];
- if (output.ScriptPubKey == script)
- {
- indexes.Add(i);
- }
- }
-
- if (indexes.Count == 0)
- {
- throw new InvalidOperationException("Script not found.");
- }
- return indexes;
+ return me.AsCoins().Where(c=>c.ScriptPubKey == script);
}
public static string ToHex(this IBitcoinSerializable me)
@@ -65,7 +51,7 @@ namespace NBitcoin
return me.GetIndistinguishableOutputs().Single(x => x.value == output.Value).count;
}
- public static int GetMixin(this Transaction me, int outputIndex)
+ public static int GetMixin(this Transaction me, uint outputIndex)
{
var output = me.Outputs[outputIndex];
return me.GetIndistinguishableOutputs().Single(x => x.value == output.Value).count - 1;

MODIFY
WalletWasabi/Models/ChaumianCoinJoin/CcjClientState.cs
WalletWasabi/Models/ChaumianCoinJoin/CcjClientState.cs
@@ -36,7 +36,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
}
}
- public IEnumerable<(uint256 txid, int index)> GetSpentCoins()
+ public IEnumerable<(uint256 txid, uint index)> GetSpentCoins()
{
lock (StateLock)
{
@@ -72,7 +72,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
}
}
- public SmartCoin GetSingleOrDefaultCoin((uint256 txid, int index) coinReference)
+ public SmartCoin GetSingleOrDefaultCoin((uint256 txid, uint index) coinReference)
{
lock (StateLock)
{
@@ -88,7 +88,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
}
}
- public SmartCoin GetSingleOrDefaultFromWaitingList((uint256 txid, int index) coinReference)
+ public SmartCoin GetSingleOrDefaultFromWaitingList((uint256 txid, uint index) coinReference)
{
lock (StateLock)
{
@@ -96,7 +96,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
}
}
- public IEnumerable<(uint256 txid, int index)> GetAllCoins()
+ public IEnumerable<(uint256 txid, uint index)> GetAllCoins()
{
lock (StateLock)
{
@@ -104,7 +104,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
}
}
- public IEnumerable<(uint256 txid, int index)> GetRegistrableCoins(int maximumInputCountPerPeer, Money denomination, Money feePerInputs, Money feePerOutputs)
+ public IEnumerable<(uint256 txid, uint index)> GetRegistrableCoins(int maximumInputCountPerPeer, Money denomination, Money feePerInputs, Money feePerOutputs)
{
lock (StateLock)
{
@@ -120,7 +120,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
if (maximumInputCountPerPeer < coinsToRegister.Count)
{
- return Enumerable.Empty<(uint256 txid, int index)>(); // Inputs are too small, max input to be registered is reached.
+ return Enumerable.Empty<(uint256 txid, uint index)>(); // Inputs are too small, max input to be registered is reached.
}
amountSoFar += coin.Amount;
@@ -131,7 +131,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
}
}
- return Enumerable.Empty<(uint256 txid, int index)>(); // Amount is never reached.
+ return Enumerable.Empty<(uint256 txid, uint index)>(); // Amount is never reached.
}
}

MODIFY
WalletWasabi/Models/SmartCoin.cs
WalletWasabi/Models/SmartCoin.cs
@@ -21,7 +21,7 @@ namespace WalletWasabi.Models
public uint256 TransactionId { get; }
[JsonProperty(Order = 2)]
- public int Index { get; }
+ public uint Index { get; }
[JsonProperty(Order = 3)]
[JsonConverter(typeof(JsonConverters.ScriptJsonConverter))]
@@ -66,7 +66,7 @@ namespace WalletWasabi.Models
public ISecret Secret { get; set; }
[JsonConstructor]
- public SmartCoin(uint256 transactionId, int index, Script scriptPubKey, Money amount, TxoRef[] spentOutputs, Height height, bool rbf, int mixin, string label = "", uint256 spenderTransactionId = null, bool locked = false)
+ public SmartCoin(uint256 transactionId, uint index, Script scriptPubKey, Money amount, TxoRef[] spentOutputs, Height height, bool rbf, int mixin, string label = "", uint256 spenderTransactionId = null, bool locked = false)
{
TransactionId = Guard.NotNull(nameof(transactionId), transactionId);
Index = Guard.NotNull(nameof(index), index);
@@ -82,6 +82,23 @@ namespace WalletWasabi.Models
Secret = null;
}
+ public SmartCoin(Coin coin, TxoRef[] spentOutputs, Height height, bool rbf, int mixin, string label = "", uint256 spenderTransactionId = null, bool locked = false)
+ {
+ Guard.NotNull(nameof(coin), coin);
+ TransactionId = coin.Outpoint.Hash;
+ Index = coin.Outpoint.N;
+ ScriptPubKey = coin.ScriptPubKey;
+ Amount = coin.Amount;
+ SpentOutputs = Guard.NotNull(nameof(spentOutputs), spentOutputs);
+ Mixin = Guard.InRangeAndNotNull(nameof(mixin), mixin, 0, int.MaxValue);
+ Height = height;
+ Label = Guard.Correct(label);
+ SpenderTransactionId = spenderTransactionId;
+ RBF = rbf;
+ Locked = locked;
+ Secret = null;
+ }
+
public Coin GetCoin()
{
return new Coin(TransactionId, (uint)Index, Amount, ScriptPubKey);
@@ -98,7 +115,7 @@ namespace WalletWasabi.Models
public bool Equals(SmartCoin other) => this == other;
- public override int GetHashCode() => TransactionId.GetHashCode() ^ Index;
+ public override int GetHashCode() => TransactionId.GetHashCode() ^ (int)Index;
public static bool operator ==(SmartCoin x, SmartCoin y) => y?.TransactionId == x?.TransactionId && y?.Index == x?.Index;

MODIFY
WalletWasabi/Models/TxoRef.cs
WalletWasabi/Models/TxoRef.cs
@@ -19,10 +19,10 @@ namespace WalletWasabi.Models
public uint256 TransactionId { get; }
[JsonProperty(Order = 2)]
- public int Index { get; }
+ public uint Index { get; }
[JsonConstructor]
- public TxoRef(uint256 transactionId, int index)
+ public TxoRef(uint256 transactionId, uint index)
{
TransactionId = Guard.NotNull(nameof(transactionId), transactionId);
Index = Guard.NotNull(nameof(index), index);
@@ -32,7 +32,7 @@ namespace WalletWasabi.Models
{
Guard.NotNull(nameof(outPoint), outPoint);
TransactionId = outPoint.Hash;
- Index = (int)outPoint.N;
+ Index = outPoint.N;
}
public OutPoint ToOutPoint() => new OutPoint(TransactionId, Index);
@@ -43,7 +43,7 @@ namespace WalletWasabi.Models
public bool Equals(TxoRef other) => this == other;
- public override int GetHashCode() => TransactionId.GetHashCode() ^ Index;
+ public override int GetHashCode() => TransactionId.GetHashCode() ^ (int)Index;
public static bool operator ==(TxoRef x, TxoRef y) => y?.TransactionId == x?.TransactionId && y?.Index == x?.Index;

MODIFY
WalletWasabi/Services/CcjClient.cs
WalletWasabi/Services/CcjClient.cs
@@ -341,7 +341,7 @@ namespace WalletWasabi.Services
{
try
{
- IEnumerable<(uint256 txid, int index)> registrableCoins = State.GetRegistrableCoins(
+ IEnumerable<(uint256 txid, uint index)> registrableCoins = State.GetRegistrableCoins(
inputRegistrableRound.State.MaximumInputCountPerPeer,
inputRegistrableRound.State.Denomination,
inputRegistrableRound.State.FeePerInputs,
@@ -374,7 +374,7 @@ namespace WalletWasabi.Services
var blind = CoordinatorPubKey.Blind(activeAddress.ScriptPubKey.ToBytes());
var inputProofs = new List<InputProofModel>();
- foreach ((uint256 txid, int index) coinReference in registrableCoins)
+ foreach ((uint256 txid, uint index) coinReference in registrableCoins)
{
var coin = State.GetSingleOrDefaultFromWaitingList(coinReference);
if (coin == null) throw new NotSupportedException("This is impossible.");
@@ -403,7 +403,7 @@ namespace WalletWasabi.Services
State.AddOrReplaceRound(roundRegistered);
}
- foreach ((uint256 txid, int index) coinReference in registrableCoins)
+ foreach ((uint256 txid, uint index) coinReference in registrableCoins)
{
var coin = State.GetSingleOrDefaultFromWaitingList(coinReference);
if (coin == null) throw new NotSupportedException("This is impossible.");
@@ -565,7 +565,7 @@ namespace WalletWasabi.Services
}
}
- private async Task DequeueCoinsFromMixNoLockAsync(params (uint256 txid, int index)[] coins)
+ private async Task DequeueCoinsFromMixNoLockAsync(params (uint256 txid, uint index)[] coins)
{
List<Exception> exceptions = new List<Exception>();
@@ -667,7 +667,7 @@ namespace WalletWasabi.Services
SatoshiClient?.Dispose();
State.DisposeAllAliceClients();
- IEnumerable<(uint256 txid, int index)> allCoins = State.GetAllCoins();
+ IEnumerable<(uint256 txid, uint index)> allCoins = State.GetAllCoins();
foreach (var coinReference in allCoins)
{
try

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -328,7 +328,7 @@ namespace WalletWasabi.Services
}
}
- for (var i = 0; i < tx.Transaction.Outputs.Count; i++)
+ for (var i = 0U; i < tx.Transaction.Outputs.Count; i++)
{
// If transaction received to any of the wallet keys:
var output = tx.Transaction.Outputs[i];
@@ -337,7 +337,7 @@ namespace WalletWasabi.Services
{
foundKey.SetKeyState(KeyState.Used, KeyManager);
List<SmartCoin> spentOwnCoins = Coins.Where(x => tx.Transaction.Inputs.Any(y => y.PrevOut.Hash == x.TransactionId && y.PrevOut.N == x.Index)).ToList();
- var mixin = tx.Transaction.GetMixin(i);
+ var mixin = tx.Transaction.GetMixin((uint)i);
if (spentOwnCoins.Count != 0)
{
mixin += spentOwnCoins.Min(x => x.Mixin);
@@ -764,7 +764,7 @@ namespace WalletWasabi.Services
var outerWalletOutputs = new List<SmartCoin>();
var innerWalletOutputs = new List<SmartCoin>();
- for (var i = 0; i < tx.Outputs.Count; i++)
+ for (var i = 0U; i < tx.Outputs.Count; i++)
{
TxOut output = tx.Outputs[i];
var mixin = tx.GetMixin(i) + spentCoins.Min(x => x.Mixin);

Implements TxOutList.GetCoins() extension method

Given a scriptPubkey, it returns the transaction's coins
with that scriptPubkey.