Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

More of the names wallets and their keys go by hold a folder back

Țugui Dragoșec4f2795d431
diff --git a/Packages/PeelCore/Sources/PeelCore/Support/FileSize.swift b/Packages/PeelCore/Sources/PeelCore/Support/FileSize.swift
index a9737d46..3144d1c6 100644
--- a/Packages/PeelCore/Sources/PeelCore/Support/FileSize.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Support/FileSize.swift
@@ -212,13 +212,26 @@ public enum FileSize {
static let repositoryMarkers: Set<String> = [".git", ".hg", ".svn", ".jj", ".pijul", "_darcs"]
- /// True for the names wallets and signing keys go by: `wallet.dat` (Bitcoin, Litecoin and their forks), a
- /// `wallets` folder (Electrum, Sparrow, Wasabi, Bitcoin Core from 0.21), `*.wallet` (Monero), and
- /// `keystore` (Ethereum, and the key an Android app is signed with).
+ /// True for the names wallets and their keys go by, as each project's own documentation or source gives them:
+ /// `wallet.dat` and names ending in it (Bitcoin, Litecoin and their forks, Zcash's Zingo), a `wallets` or
+ /// `wallets2` folder (Electrum, Sparrow, Wasabi, Bitcoin Core, Green), `keystore` and `keystores` (Ethereum,
+ /// Foundry, and the key an Android app is signed with), `*.wallet` (Bisq, Exodus, Kaspa), `*.keys` (Monero),
+ /// `*.mmdbdoc_v1` (MyMonero), `hsm_secret`, `emergency.recover`, and `channel.backup` (Lightning nodes),
+ /// `seed.dat` (phoenixd), `wallet.seed` (Grin), `mnemonics` (Liana), `keyring-file`, `keyring-test`, and
+ /// `priv_validator_key.json` (Cosmos), `sui.keystore`, `sqlite_wallets` (Algorand), `encryption-identity.txt`
+ /// (Zallet), and `.aptos`.
static func isWallet(_ name: String) -> Bool {
let name = name.lowercased()
- return name == "wallet.dat" || name == "wallets" || name == "keystore" || name.hasSuffix(".wallet")
+ return walletNames.contains(name) || walletSuffixes.contains { name.hasSuffix($0) }
}
+
+ private static let walletNames: Set<String> = [
+ "wallets", "wallets2", "keystore", "keystores", "hsm_secret", "emergency.recover", "channel.backup",
+ "seed.dat", "wallet.seed", "mnemonics", "keyring-file", "keyring-test", "priv_validator_key.json",
+ "sui.keystore", "sqlite_wallets", "encryption-identity.txt", ".aptos",
+ ]
+
+ private static let walletSuffixes = ["wallet.dat", ".wallet", ".keys", ".mmdbdoc_v1"]
}
/// What is known about the folders being walked.
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileSizeTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileSizeTests.swift
index 979e8650..af2f8a35 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/FileSizeTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileSizeTests.swift
@@ -244,17 +244,34 @@ struct FileSizeTests {
try directory.file("core/wallet.dat", bytes: 64)
let electrum = try directory.directory("electrum")
try directory.file("electrum/wallets/default_wallet")
- let monero = try directory.directory("monero")
- try directory.file("monero/a/mine.wallet")
+ let bisq = try directory.directory("bisq")
+ try directory.file("bisq/btc_mainnet/wallet/bisq_BTC.wallet")
let android = try directory.directory("android")
try directory.file("android/keystore/release")
#expect(await FileSize.contents(of: plain)?.holdsWallet == false)
- for folder in [core, electrum, monero, android] {
+ for folder in [core, electrum, bisq, android] {
#expect(await FileSize.contents(of: folder)?.holdsWallet == true, "\(folder.lastPathComponent) reads as holding no wallet")
}
}
+ /// The names wallets and their keys go by, as each project's documentation or source gives them, and names
+ /// that only look close.
+ @Test func knowsTheNamesWalletsAndTheirKeysGoBy() {
+ let wallets = [
+ "wallet.dat", "zingo-wallet.dat", "wallets", "wallets2", "keystore", "keystores", "bisq_BTC.wallet",
+ "exodus.wallet", "mine.keys", "account.mmdbdoc_v1", "hsm_secret", "emergency.recover", "channel.backup",
+ "seed.dat", "wallet.seed", "mnemonics", "keyring-file", "keyring-test", "priv_validator_key.json",
+ "sui.keystore", "sqlite_wallets", "encryption-identity.txt", ".aptos", "Wallet.DAT",
+ ]
+ for name in wallets {
+ #expect(FileSize.isWallet(name), "\(name) was not read as a wallet")
+ }
+ for name in ["notes.txt", "keys", "wallet.datx", "seed.txt", "keystore.txt", "Wallets.app", ".bitmonero"] {
+ #expect(!FileSize.isWallet(name), "\(name) was read as a wallet")
+ }
+ }
+
/// A folder whose contents are only in the cloud is skipped: listing it fetches the whole tree from the
/// provider and adds nothing, since it holds no local bytes. Ordinary folders are not dataless.
@Test func doesNotWalkIntoAFolderThatIsOnlyInTheCloud() throws {