Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*.md text eol=lf
*.json text eol=lf
*.nix text eol=lf
*.sh text eol=lf


###############################################################################
Expand Down
60 changes: 60 additions & 0 deletions Contrib/update-nuget-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
set -euo pipefail

find_repo_root() {
local d="$PWD"
while [[ "$d" != "/" ]]; do
[[ -f "$d/flake.nix" ]] && { echo "$d"; return 0; }
d="$(dirname "$d")"
done
echo "ERROR: Could not find flake.nix in any parent directory." >&2
exit 1
}

nix_build_flags=(
--extra-experimental-features nix-command
--extra-experimental-features flakes
)

update_deps() {
local attr="$1" # .#packages.x86_64-linux.default
local target="$2" # deps.nix

echo "==> Updating ${target} from ${attr}.passthru.fetch-deps"

local helper
helper="$(nix build "${attr}.passthru.fetch-deps" \
--no-link --print-out-paths \
"${nix_build_flags[@]}")"

if [[ -z "$helper" || ! -e "$helper" ]]; then
echo "ERROR: nix did not return a valid output path for fetch-deps." >&2
exit 2
fi

local out gen_path
out="$("$helper" 2>&1 || true)"
gen_path="$(printf '%s\n' "$out" | sed -nE 's/^Succesfully wrote lockfile to (.*)$/\1/p' | tail -n 1)"

if [[ -z "$gen_path" ]]; then
echo "ERROR: Could not find generated lockfile path in fetch-deps output." >&2
echo "---- fetch-deps output (last 120 lines) ----" >&2
printf '%s\n' "$out" | tail -n 120 >&2
exit 3
fi

cp -f "$gen_path" "$target"
echo " Wrote $target (from $gen_path)"
}

main() {
local root
root="$(find_repo_root)"
cd "$root"

update_deps ".#packages.x86_64-linux.default" "deps.nix"

echo "==> Done. Commit deps.nix"
}

main "$@"
9 changes: 4 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@
<!-- UI Testing. -->
<PackageVersion Include="Avalonia.Headless.XUnit" Version="$(AvaloniaVersion)" />
<!-- Testing. -->
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.19" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Moq" Version="[4.18.4]" />
<PackageVersion Include="xunit" Version="2.6.6" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.6" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
</ItemGroup>
</Project>
</Project>
30 changes: 16 additions & 14 deletions WalletWasabi.Documentation/Guides/HowToUpdateDepsNix.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
## How to update Deps.nix file
## How to update `deps.nix`

### Windows (wsl)
### Windows (WSL)

1. Run Ubuntu.
2. Install nix (If you have it installed, skip this step)
```powershell
1. Open **Ubuntu (WSL)**.
2. Install **Nix** (skip if already installed):
```bash
sh <(curl -L https://nixos.org/nix/install) --no-daemon
```
2. Go to your `GingerWallet` folder. (The folder where you can find `flake.nix` file)
4. Run the following command to create a bash script:
```powershell
nix build .#packages.x86_64-linux.default.passthru.fetch-deps --extra-experimental-features nix-command --extra-experimental-features flakes
3. Go to the repository folder (anywhere inside the repo is fine, the script finds `flake.nix` automatically):
```bash
cd /mnt/c/Users/<You>/Documents/work/GingerPrivacy/GingerBackend
```
5. Run the bash script
```powershell
./result
4. Run the update script:
```bash
./Contrib/update-nuget-deps.sh
```
5. Commit the updated lockfile:
```bash
git add deps.nix
git commit -m "Update deps.nix"
```
6. The last terminal message tells you where is the new nix file. (e.g. `Succesfully wrote lockfile to /tmp/WalletWasabi.Backend-deps-7dpBuk.nix`)
7. Find the file under `\\wsl$\<DistroName>\tmp\`, rename it to `deps.nix` and copy it to GingerWallet folder to override the previous one.
9 changes: 7 additions & 2 deletions WalletWasabi.Fluent/Models/Wallets/HardwareWalletInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ public async Task<HwiEnumerateEntry[]> DetectAsync(CancellationToken cancelToken
using var cts = new CancellationTokenSource(TimeSpan.FromMinutes(3));
using var timeoutCts = CancellationTokenSource.CreateLinkedTokenSource(cts.Token, cancelToken);

var detectedHardwareWallets = (await client.EnumerateAsync(timeoutCts.Token).ConfigureAwait(false)).ToArray();
var all = (await client.EnumerateAsync(timeoutCts.Token).ConfigureAwait(false)).ToArray();

cancelToken.ThrowIfCancellationRequested();

return detectedHardwareWallets;
// Return only devices that are actually usable.
var usable = all
.Where(d => d.Code is null && d.Fingerprint is not null)
.ToArray();

return usable;
}

public async Task InitHardwareWalletAsync(HwiEnumerateEntry device, CancellationToken cancelToken)
Expand Down
9 changes: 5 additions & 4 deletions WalletWasabi.Tests/Helpers/MempoolInfoGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NBitcoin;
using NBitcoin.RPC;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;

namespace WalletWasabi.Tests.Helpers;

Expand Down Expand Up @@ -89,7 +90,7 @@ static IEnumerable<FeeRateGroup> ExtractFeeRateGroups(JToken? jt) =>

return new FeeRateGroup
{
Group = int.Parse(p.Name),
Group = int.Parse(p.Name, CultureInfo.InvariantCulture),
Sizes = p.Value.Value<ulong>("sizes"),
Count = p.Value.Value<uint>("count"),
Fees = Money.Satoshis(p.Value.Value<ulong>("fees")),
Expand Down
2 changes: 2 additions & 0 deletions WalletWasabi.Tests/Helpers/ServiceFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public static TransactionFactory CreateTransactionFactory(GingerRandom rnd, IEnu
KeyManager keyManager = watchOnly ? CreateWatchOnlyKeyManager() : CreateKeyManager(password);
SmartCoin[] sCoins = CreateCoins(rnd, keyManager, coins);
var coinsView = new CoinsView(sCoins);
#pragma warning disable CA2000 // Dispose objects before losing scope
var mockTransactionStore = new AllTransactionStore(".", Network.Main);
#pragma warning restore CA2000 // Dispose objects before losing scope
return new TransactionFactory(Network.Main, keyManager, coinsView, mockTransactionStore, password);
}

Expand Down
2 changes: 2 additions & 0 deletions WalletWasabi.Tests/Helpers/TestNodeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static async Task<CoreNode> CreateForHeavyConcurrencyAsync([CallerFilePat

private static CoreNodeParams CreateDefaultCoreNodeParams(MempoolService mempoolService, string dataDir)
{
#pragma warning disable CA2000 // Dispose objects before losing scope
var nodeParameters = new CoreNodeParams(
Network.RegTest,
mempoolService ?? new MempoolService(),
Expand All @@ -52,6 +53,7 @@ private static CoreNodeParams CreateDefaultCoreNodeParams(MempoolService mempool
userAgent: $"/WasabiClient:{Constants.ClientVersion}/",
fallbackFee: Money.Coins(0.0002m), // https://github.com/bitcoin/bitcoin/pull/16524
new MemoryCache(new MemoryCacheOptions()));
#pragma warning restore CA2000 // Dispose objects before losing scope
nodeParameters.ListenOnion = 0;
nodeParameters.Discover = 0;
nodeParameters.DnsSeed = 0;
Expand Down
17 changes: 11 additions & 6 deletions WalletWasabi.Tests/Helpers/WabiSabiTestFactory.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
using GingerCommon.Crypto.Random;
using Moq;
using NBitcoin;
using NBitcoin.Crypto;
using NBitcoin.RPC;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using WabiSabi.CredentialRequesting;
using WabiSabi.Crypto;
using WabiSabi.Crypto.Randomness;
using WabiSabi.Crypto.ZeroKnowledge;
using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Blockchain.TransactionOutputs;
using WalletWasabi.Crypto;
using WalletWasabi.Helpers;
using WalletWasabi.Models;
using WalletWasabi.Tests.TestCommon;
using WalletWasabi.Tests.UnitTests;
using WalletWasabi.WabiSabi;
using WalletWasabi.WabiSabi.Backend;
Expand All @@ -22,15 +27,11 @@
using WalletWasabi.WabiSabi.Backend.Rounds;
using WalletWasabi.WabiSabi.Backend.Rounds.CoinJoinStorage;
using WalletWasabi.WabiSabi.Client;
using WalletWasabi.WabiSabi.Client.CoinJoin.Client;
using WalletWasabi.WabiSabi.Client.RoundStateAwaiters;
using WalletWasabi.WabiSabi.Models;
using WalletWasabi.Wallets;
using WalletWasabi.WebClients.Wasabi;
using WalletWasabi.WabiSabi.Client.CoinJoin.Client;
using WabiSabi.Crypto.Randomness;
using System.Runtime.CompilerServices;
using WalletWasabi.Tests.TestCommon;
using GingerCommon.Crypto.Random;

namespace WalletWasabi.Tests.Helpers;

Expand All @@ -45,7 +46,9 @@ public static WabiSabiConfig CreateDefaultWabiSabiConfig()

public static Coin CreateCoin(Key? key = null, Money? amount = null, ScriptPubKeyType scriptPubKeyType = ScriptPubKeyType.Segwit)
{
#pragma warning disable CA2000 // Dispose objects before losing scope
key ??= new();
#pragma warning restore CA2000 // Dispose objects before losing scope
amount ??= Money.Coins(1);
return new(
new OutPoint(Hashes.DoubleSHA256(key.PubKey.ToBytes().Concat(BitConverter.GetBytes(amount)).ToArray()), 0),
Expand All @@ -54,7 +57,9 @@ public static Coin CreateCoin(Key? key = null, Money? amount = null, ScriptPubKe

public static Tuple<Coin, OwnershipProof> CreateCoinWithOwnershipProof(GingerRandom rnd, Key? key = null, Money? amount = null, uint256? roundId = null, ScriptPubKeyType scriptPubKeyType = ScriptPubKeyType.Segwit)
{
#pragma warning disable CA2000 // Dispose objects before losing scope
key ??= new();
#pragma warning restore CA2000 // Dispose objects before losing scope
var coin = CreateCoin(key, amount, scriptPubKeyType);
roundId ??= uint256.One;
var ownershipProof = CreateOwnershipProof(rnd, key, roundId);
Expand Down Expand Up @@ -354,7 +359,7 @@ public static CoinJoinClient CreateTestCoinJoinClient(
0,
TimeSpan.Zero,
TimeSpan.Zero,
null);
null!);

// Overwrite Maximum Request Delay parameter but still use the original method.
mock.Setup(m => m.GetScheduledDates(It.IsAny<int>(), It.IsAny<DateTimeOffset>(), It.IsAny<DateTimeOffset>(), It.IsNotIn(TimeSpan.FromSeconds(1))))
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi.Tests/IntegrationTests/P2pTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public async Task TestServicesAsync(string networkString)
KeyManager keyManager = KeyManager.CreateNew(out _, "password", network);
await using WasabiHttpClientFactory httpClientFactory = new(Common.TorSocks5Endpoint, backendUriGetter: () => new Uri("http://localhost:12345"));
using WasabiSynchronizer synchronizer = new(period: TimeSpan.FromSeconds(3), 10000, bitcoinStore, httpClientFactory);
FeeRateProvider feeProvider = new(httpClientFactory, network);
using FeeRateProvider feeProvider = new(httpClientFactory, network);

ServiceConfiguration serviceConfig = new(new IPEndPoint(IPAddress.Loopback, network.DefaultPort), Money.Coins(Constants.DefaultDustThreshold));
using MemoryCache cache = new(new MemoryCacheOptions
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi.Tests/RegressionTests/BackendTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public async Task GetUnconfirmedTxChainAsync()
// 3. Create wasabi synchronizer service.
await using WasabiHttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
using WasabiSynchronizer synchronizer = new(period: TimeSpan.FromSeconds(3), 10000, bitcoinStore, httpClientFactory);
FeeRateProvider feeProvider = new(httpClientFactory, network);
using FeeRateProvider feeProvider = new(httpClientFactory, network);

// 4. Create key manager service.
var keyManager = KeyManager.CreateNew(out _, password, network);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public async Task BuildTransactionReorgsTestAsync()
// 3. Create wasabi synchronizer service.
await using WasabiHttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
using WasabiSynchronizer synchronizer = new(period: TimeSpan.FromSeconds(3), 10000, bitcoinStore, httpClientFactory);
FeeRateProvider feeProvider = new(httpClientFactory, network);
using FeeRateProvider feeProvider = new(httpClientFactory, network);
using UnconfirmedTransactionChainProvider unconfirmedChainProvider = new(httpClientFactory);

// 4. Create key manager service.
Expand Down Expand Up @@ -261,14 +261,14 @@ public async Task BuildTransactionReorgsTestAsync()
await Task.Delay(2000); // Waits for the funding transaction get to the mempool.
Assert.Contains(fundingBumpTxId.TransactionId, wallet.Coins.Select(x => x.TransactionId));
Assert.DoesNotContain(fundingTxId, wallet.Coins.Select(x => x.TransactionId));
Assert.Single(wallet.Coins.Where(x => x.TransactionId == fundingBumpTxId.TransactionId));
Assert.Single(wallet.Coins, x => x.TransactionId == fundingBumpTxId.TransactionId);

// Confirm the coin
Interlocked.Exchange(ref setup.FiltersProcessedByWalletCount, 0);
await rpc.GenerateAsync(1);
await setup.WaitForFiltersToBeProcessedAsync(TimeSpan.FromSeconds(120), 1);

Assert.Single(wallet.Coins.Where(x => x.Confirmed && x.TransactionId == fundingBumpTxId.TransactionId));
Assert.Single(wallet.Coins, x => x.Confirmed && x.TransactionId == fundingBumpTxId.TransactionId);
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public async Task BuildTransactionValidationsTestAsync()
// 3. Create wasabi synchronizer service.
await using WasabiHttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
using WasabiSynchronizer synchronizer = new(period: TimeSpan.FromSeconds(3), 10000, bitcoinStore, httpClientFactory);
FeeRateProvider feeProvider = new(httpClientFactory, network);
using FeeRateProvider feeProvider = new(httpClientFactory, network);

// 4. Create key manager service.
var keyManager = KeyManager.CreateNew(out _, password, network);
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi.Tests/RegressionTests/CancelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public async Task CancelTestsAsync()
// 3. Create wasabi synchronizer service.
await using WasabiHttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
using WasabiSynchronizer synchronizer = new(period: TimeSpan.FromSeconds(3), 10000, bitcoinStore, httpClientFactory);
FeeRateProvider feeProvider = new(httpClientFactory, network);
using FeeRateProvider feeProvider = new(httpClientFactory, network);
using UnconfirmedTransactionChainProvider unconfirmedChainProvider = new(httpClientFactory);

// 4. Create key manager service.
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi.Tests/RegressionTests/MaxFeeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async Task CalculateMaxFeeTestAsync()
// 3. Create wasabi synchronizer service.
await using WasabiHttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
using WasabiSynchronizer synchronizer = new(period: TimeSpan.FromSeconds(3), 10000, bitcoinStore, httpClientFactory);
FeeRateProvider feeProvider = new(httpClientFactory, network);
using FeeRateProvider feeProvider = new(httpClientFactory, network);
using UnconfirmedTransactionChainProvider unconfirmedChainProvider = new(httpClientFactory);

// 4. Create key manager service.
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi.Tests/RegressionTests/ReplaceByFeeTxTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public async Task ReplaceByFeeTxTestAsync()
// 3. Create wasabi synchronizer service.
await using WasabiHttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
using WasabiSynchronizer synchronizer = new(period: TimeSpan.FromSeconds(3), 10000, bitcoinStore, httpClientFactory);
FeeRateProvider feeProvider = new(httpClientFactory, network);
using FeeRateProvider feeProvider = new(httpClientFactory, network);

// 4. Create key manager service.
var keyManager = KeyManager.CreateNew(out _, password, network);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public async Task SelfSpendSpeedupTestsAsync()
// 3. Create wasabi synchronizer service.
await using WasabiHttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
using WasabiSynchronizer synchronizer = new(period: TimeSpan.FromSeconds(3), 10000, bitcoinStore, httpClientFactory);
FeeRateProvider feeProvider = new(httpClientFactory, network);
using FeeRateProvider feeProvider = new(httpClientFactory, network);
using UnconfirmedTransactionChainProvider unconfirmedChainProvider = new(httpClientFactory);

// 4. Create key manager service.
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi.Tests/RegressionTests/SendSpeedupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public async Task SendSpeedupTestsAsync()
// 3. Create wasabi synchronizer service.
await using WasabiHttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
using WasabiSynchronizer synchronizer = new(period: TimeSpan.FromSeconds(3), 10000, bitcoinStore, httpClientFactory);
FeeRateProvider feeProvider = new(httpClientFactory, network);
using FeeRateProvider feeProvider = new(httpClientFactory, network);
using UnconfirmedTransactionChainProvider unconfirmedChainProvider = new(httpClientFactory);

// 4. Create key manager service.
Expand Down
2 changes: 1 addition & 1 deletion WalletWasabi.Tests/RegressionTests/SendTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public async Task SendTestsAsync()
// 3. Create wasabi synchronizer service.
await using WasabiHttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
using WasabiSynchronizer synchronizer = new(period: TimeSpan.FromSeconds(3), 10000, bitcoinStore, httpClientFactory);
FeeRateProvider feeProvider = new(httpClientFactory, network);
using FeeRateProvider feeProvider = new(httpClientFactory, network);
using UnconfirmedTransactionChainProvider unconfirmedChainProvider = new(httpClientFactory);

// 4. Create key manager service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public async Task SpendUnconfirmedTxTestAsync()
// 3. Create wasabi synchronizer service.
await using WasabiHttpClientFactory httpClientFactory = new(torEndPoint: null, backendUriGetter: () => new Uri(RegTestFixture.BackendEndPoint));
using WasabiSynchronizer synchronizer = new(period: TimeSpan.FromSeconds(3), 10000, bitcoinStore, httpClientFactory);
FeeRateProvider feeProvider = new(httpClientFactory, network);
using FeeRateProvider feeProvider = new(httpClientFactory, network);
using UnconfirmedTransactionChainProvider unconfirmedChainProvider = new(httpClientFactory);

// 4. Create key manager service.
Expand Down
Loading
Loading