Repository Public
1{2 "schema": "qyvora-review/1",3 "title": "Multi-chain upgrade — UTXO coins: Litecoin, Dogecoin, Bitcoin Cash",4 "reviewed_revision_base": "08b6c46",5 "reviewer": "area agent UTXO-COINS (internal audit, not an independent certification)",6 "date": "2026-12-05",7 "scope": [8 "Sources/QyvoraCore/Encoding/CashAddr.swift",9 "Sources/QyvoraCore/Networks.swift (UTXO coins)",10 "Sources/QyvoraBitcoin (changes since 36bfa4c: Address, Account, Signing, Transaction, PSBT, TransactionBuilder, CoinSelection, Descriptor)",11 "Sources/QyvoraNetworking/UTXOIndexer.swift, Blockbook.swift, Bitcore.swift, Esplora.swift (UTXOIndexer conformance), HTTP.swift (UTXO endpoint configuration)",12 "Sources/QyvoraWallet/WalletService+UTXOCoins.swift and the UTXO-coin parts of Chains, ChainTypes, ChainPersistence, WalletService+Chains, +Send, +Cold, +Onboarding, +Shield"13 ],14 "method": "Line-by-line reading of everything changed since commit 36bfa4c in the scope, looking for: traps reachable from untrusted input, non-canonical encodings accepted, what-is-shown ≠ what-is-signed, signing of server-provided values, limits bypassable through a public interface, wrong chain constants (each verified against the reference client's source and a second source), cross-family address confusion, replay, and what one lying endpoint can do. Each finding was reproduced by a test that fails before the fix (run on the build node against the pre-fix sources) and passes after. Conformance, differential, property and fuzz campaigns are in security/tests (files UTXOCoins*).",15 "limits": "Internal audit. The App target (interface) was not reviewed: it is being rebuilt; interface-level mitigations are recorded as open application findings. No live network was used with wallet material; public chain data and public reference sources were fetched read-only on 2026-12-05. Constant-time behaviour of secp256k1 is in the scope of the primitive review, not of this one. The Bitcoin (BTC) path was audited at 36bfa4c and only its changes were re-read.",16 "entries": [17 {18 "construct": "CashAddr.decode: length bounds, case rule, prefix, character set, checksum, padding, reserved bit, hash length",19 "location": "Sources/QyvoraCore/Encoding/CashAddr.swift:111",20 "verdict": "safe",21 "note": "Text is bounded to 160 characters and ASCII before any work; the payload must be 42 to 112 characters of the set; the 40-bit checksum covers the prefix; non-zero padding bits are refused by Bech32.fromWords, the reserved bit of the version byte and a hash whose length is not the announced one are refused. Linear time, no allocation proportional to anything but the input. Differential campaign utxo-cashaddr-decode (bitcash primitives) and fuzz target cashaddr."22 },23 {24 "construct": "CashAddr.polymod: 40-bit BCH checksum in UInt64",25 "location": "Sources/QyvoraCore/Encoding/CashAddr.swift:64",26 "verdict": "safe",27 "note": "The state is masked to 35 bits before the shift by 5: no overflow. Generators equal those of the specification and of bitcash (compared character for character through the encode campaign, 1 500 / 20 000 addresses)."28 },29 {30 "construct": "CashAddr.encode: refuses sizes and types outside the format",31 "location": "Sources/QyvoraCore/Encoding/CashAddr.swift:79",32 "verdict": "safe",33 "note": "nil unless the hash size is one of the eight sizes, the type is at most 15 and the prefix is 1 to 40 lower-case letters."34 },35 {36 "construct": "BitcoinAddress.init(text): format dispatch per network (Bech32 / CashAddr / Base58Check)",37 "location": "Sources/QyvoraBitcoin/Address.swift:91",38 "verdict": "safe",39 "note": "Text bounded to 130 ASCII characters (40 for Base58, whose decoding is quadratic). A Bech32 address is accepted only under the network's own prefix; on Dogecoin and Bitcoin Cash every SegWit address is refused (wrongNetwork). CashAddr: only the network's prefix, 20-byte hashes, types 0 and 1 (token-aware types and 32-byte P2SH: unsupportedAddressType). Base58: only the network's two version bytes."40 },41 {42 "construct": "Litecoin: the former P2SH version byte (0x05 / 0xc4, Bitcoin's own) is refused",43 "location": "Sources/QyvoraBitcoin/Address.swift:179",44 "verdict": "safe",45 "note": "A Bitcoin '3…' address pasted on Litecoin is refused with ambiguousLegacyFormat (Litecoin Core still decodes it; the wallet does not, because nothing tells it from a Bitcoin address). The current form 'M…' (0x32) and 'Q…' on testnet (0x3a) are accepted. Policy difference with the reference client, on the safe side."46 },47 {48 "construct": "Bitcoin Cash: the legacy Base58 form is accepted, converted to CashAddr and flagged",49 "location": "Sources/QyvoraBitcoin/Address.swift:190",50 "verdict": "safe",51 "note": "A legacy Bitcoin Cash address is byte for byte a Bitcoin address: the engine accepts it (the network does) and sets isLegacyFormat; the service turns the flag into a note of checkAddress and, since this audit, into a critical warning of the review.",52 "finding_id": "QYV-SVC-065"53 },54 {55 "construct": "Address version bytes, Bech32 prefixes, CashAddr prefixes, WIF versions of the six networks",56 "location": "Sources/QyvoraCore/Networks.swift:70",57 "verdict": "safe",58 "note": "Each value compared with the reference client's chainparams.cpp (Litecoin Core v0.21.4, Dogecoin Core v1.14.9, Bitcoin Cash Node v29.2.0, read 2026-12-05) and with bip-utils 2.14.1 (campaign utxo-address-formats; conformance test chainConstantsAgainstReferenceClients)."59 },60 {61 "construct": "Genesis hashes and identity blocks",62 "location": "Sources/QyvoraCore/Networks.swift:353",63 "verdict": "safe",64 "note": "Litecoin, Litecoin Testnet (testnet4), Dogecoin, Dogecoin Testnet genesis hashes equal the reference clients' assertions and what two public indexers serve. Bitcoin Cash shares Bitcoin's genesis: the identity block is 661648 (checkpoint of Bitcoin Cash Node, first block after the split from eCash of 2020-11-15; blocks up to 661647 are common to Bitcoin Cash and eCash, and the chain left Bitcoin at 478559 and Bitcoin SV at 556767): the hash was read on blockbook.bch.zelcore.io, api.bitcore.io and api.haskoin.com and differs from Bitcoin's block at that height (mempool.space). Testnet4 block 200000: same hash on api.bitcore.io and api.haskoin.com."65 },66 {67 "construct": "Fee floors, ceilings and dust rules per coin",68 "location": "Sources/QyvoraCore/Networks.swift:323",69 "verdict": "safe",70 "note": "Litecoin: floor 1 000 litoshi/kvB = DEFAULT_MIN_RELAY_TX_FEE, dust at DUST_RELAY_TX_FEE 30 000 with Bitcoin Core's formula. Dogecoin: floor 0.01 DOGE/kB = RECOMMENDED_MIN_TX_FEE (ten times the relay minimum), dust 0.01 DOGE = DEFAULT_DUST_LIMIT (the soft limit: no output of the wallet ever needs the dust surcharge), ceiling 1 DOGE/kB. Bitcoin Cash: 1 sat/byte, dust 546 sat for every script (the node computes 540 for P2SH: the wallet is stricter by 6 sat). Property test feeDustAndLimitConstants."71 },72 {73 "construct": "MainnetPolicy.utxoLimits and nativeCeiling",74 "location": "Sources/QyvoraCore/Networks.swift:439",75 "verdict": "safe",76 "note": "nil on test networks; value ceiling 150 USD converted with a fresh price, rounding down, nil (payment refused) for a price that is not finite and positive; absolute fee and fee-rate ceilings per coin. UTXOLimits has no public initializer."77 },78 {79 "construct": "BitcoinSighashType.isStandard(for:) and adapted(to:)",80 "location": "Sources/QyvoraBitcoin/Transaction.swift:105",81 "verdict": "safe",82 "note": "Under Bitcoin Cash's scheme a type must carry SIGHASH_FORKID (0x40) and be one of the six base values; elsewhere the flag is refused. SIGHASH_UTXOS (0x20, CashTokens) is never accepted."83 },84 {85 "construct": "BitcoinSighash.forkID: BIP-143 preimage with the amount, fork id 0",86 "location": "Sources/QyvoraBitcoin/Transaction.swift:316",87 "verdict": "safe",88 "note": "Requires the flag and a zero fork id (upper 24 bits). 1000 vectors of Bitcoin Cash Node replayed (amount 0), random transactions with amounts against an independent implementation (campaign utxo-forkid-sighash), signed transactions byte-identical to bitcash's."89 },90 {91 "construct": "BitcoinSighash.digest(scheme:): the digest an input signs under a network's scheme",92 "location": "Sources/QyvoraBitcoin/Transaction.swift:325",93 "verdict": "safe",94 "note": "The hash type is checked against the scheme first; Dogecoin never computes a BIP-143 digest, Bitcoin Cash never the original one."95 },96 {97 "construct": "BitcoinTransaction.outputValue(maximumMoney:) and checkSanity(maximumMoney:)",98 "location": "Sources/QyvoraBitcoin/Transaction.swift:277",99 "verdict": "safe",100 "note": "Overflow-checked sum against the network's monetary range (Dogecoin: 10^18 base units, which fits UInt64 and Int64)."101 },102 {103 "construct": "BitcoinSigner.signP2PKH",104 "location": "Sources/QyvoraBitcoin/Signing.swift:96",105 "verdict": "safe",106 "note": "The key must hash to the script (compressed or uncompressed form); the fork-id flag is added by the scheme, never by the caller; the witness is cleared. With the original digest the amount is not signed: authentication of the amount is the caller's duty and UTXOAccount.sign enforces it."107 },108 {109 "construct": "BitcoinVerifier.verifyInput under the three schemes",110 "location": "Sources/QyvoraBitcoin/Signing.swift:244",111 "verdict": "safe",112 "note": "Under Dogecoin's and Bitcoin Cash's schemes a witness program is reported unsupported, never valid, and a non-empty witness is malformed. On Bitcoin Cash a 65-byte signature element is a Schnorr signature (as in the node, where a 64-byte ECDSA signature is forbidden): reported unsupportedSignature, never valid. One of the 10 Bitcoin Cash inputs of the main-network vectors is of that kind."113 },114 {115 "construct": "UTXOAccount.sign(transaction:): previous transactions where the digest does not commit to amounts",116 "location": "Sources/QyvoraBitcoin/Account.swift:335",117 "verdict": "safe",118 "note": "P2PKH outside Bitcoin Cash: each coin must be authenticated by the transaction that created it (txid recomputed, index in range, amount and script equal), else unauthenticatedInput and nothing is signed. Every signature is verified under the network's scheme before the transaction is returned."119 },120 {121 "construct": "BitcoinUTXO.isAuthenticated(by:)",122 "location": "Sources/QyvoraBitcoin/CoinSelection.swift:156",123 "verdict": "safe",124 "note": "Recomputes the identifier of the supplied transaction (double SHA-256 of its serialization without witness), bounds the output index, compares amount and script."125 },126 {127 "construct": "UTXOAccount.sign(psbt:): signed one input of a PSBT whose other amounts were unknown",128 "location": "Sources/QyvoraBitcoin/Account.swift:404",129 "verdict": "fixed",130 "note": "Before the fix an input without any UTXO record was skipped and the account's other input was signed: with the original digest two such rounds give a transaction whose fee nobody saw. The account now refuses unless every input carries an authenticated previous transaction (Dogecoin, Bitcoin Cash, BIP-44 accounts). No service path exposed PSBTs for these coins.",131 "finding_id": "QYV-SVC-064"132 },133 {134 "construct": "PSBT.spentOutput / PSBT.fee: amounts from a previous transaction set through the public property, or from a witness-UTXO record under Dogecoin's scheme",135 "location": "Sources/QyvoraBitcoin/PSBT.swift:511",136 "verdict": "fixed",137 "note": "The identifier of a previous transaction was checked at parse and by the setter, not by the accessors: `inputs` is a public property. The accessors now repeat the check, bound the index against the transaction's inputs, and under Dogecoin's and Bitcoin Cash's schemes report no fee when an input lacks its previous transaction.",138 "finding_id": "QYV-SVC-064"139 },140 {141 "construct": "PSBT parse: PSBT_IN_NON_WITNESS_UTXO must hash to the outpoint",142 "location": "Sources/QyvoraBitcoin/PSBT.swift:320",143 "verdict": "safe",144 "note": "A PSBT whose previous transaction is not the one spent, or is too short for the output index, does not parse (nonWitnessUTXOMismatch). Fuzz target psbt-prevtx."145 },146 {147 "construct": "PSBT.signingType: the fork-id flag of a declared hash type",148 "location": "Sources/QyvoraBitcoin/PSBT.swift:661",149 "verdict": "safe",150 "note": "A declared PSBT_IN_SIGHASH_TYPE must fit the scheme (flag present on Bitcoin Cash, absent elsewhere); the allowed set is expressed without the flag (ALL by default)."151 },152 {153 "construct": "BitcoinSpendRequest.init(network:): the network's rules",154 "location": "Sources/QyvoraBitcoin/TransactionBuilder.swift:146",155 "verdict": "safe",156 "note": "Fee floor and ceiling, dust rule, monetary range, no replace-by-fee signal on Bitcoin Cash, no witness script where SegWit does not exist. The absolute cap of the builder is 1 000 000 base units (0.01 LTC, 0.01 BCH) and 10 DOGE on Dogecoin; the service applies the ceilings of an unaudited build on top."157 },158 {159 "construct": "Builder: witness programs refused as recipient, change, send-max and input without SegWit",160 "location": "Sources/QyvoraBitcoin/TransactionBuilder.swift:240",161 "verdict": "safe",162 "note": "On Dogecoin and Bitcoin Cash such an output would be spendable by anyone. Property test builderAndSignatureInvariantsPerCoin and fuzz target utxo-coin-sign."163 },164 {165 "construct": "Builder: sums over indexer-provided coins",166 "location": "Sources/QyvoraBitcoin/TransactionBuilder.swift:238",167 "verdict": "safe",168 "note": "The candidates' total is bounded once by the monetary range (at most 2^62), so no later sum (input totals, effective values in Int64) can overflow. Fuzz target utxo-coin-sign feeds raw 64-bit values."169 },170 {171 "construct": "Builder: changeless transactions keep at most the cost of a change output",172 "location": "Sources/QyvoraBitcoin/TransactionBuilder.swift:337",173 "verdict": "safe",174 "note": "A remainder is left to the fee only below the dust threshold or the cost of spending it later, and the final fee is checked against required + tolerance (absurdFee otherwise)."175 },176 {177 "construct": "BitcoinTransactionPlan.psbt(previousTransactions:)",178 "location": "Sources/QyvoraBitcoin/TransactionBuilder.swift:209",179 "verdict": "safe",180 "note": "A non-SegWit input needs its previous transaction, and it must match the coin."181 },182 {183 "construct": "FeeRate.fromEstimate(coinsPerKiloByte:) and clamped(to:)",184 "location": "Sources/QyvoraBitcoin/CoinSelection.swift:76",185 "verdict": "safe",186 "note": "nil unless finite, positive and at most 1000 coins per kB; rounded up; estimates are clamped to the network's bounds."187 },188 {189 "construct": "MultisigAccount: refused on networks without SegWit",190 "location": "Sources/QyvoraBitcoin/Account.swift:444",191 "verdict": "safe",192 "note": "P2WSH multisig cannot exist on Dogecoin or Bitcoin Cash."193 },194 {195 "construct": "OutputDescriptor pkh(KEY)",196 "location": "Sources/QyvoraBitcoin/Descriptor.swift:443",197 "verdict": "safe",198 "note": "Same key-expression parser as wpkh; one key; purpose refused where the network does not support it."199 },200 {201 "construct": "UTXOWire: validation of what enters a URL and of what an answer holds",202 "location": "Sources/QyvoraNetworking/UTXOIndexer.swift:262",203 "verdict": "safe",204 "note": "An address reaches a path only as letters and digits (plus a lower-case prefix and one colon); path components cannot introduce a separator; identifiers are 64 lower-case hexadecimal characters; scripts, raw transactions, coin lists, pages and entries per transaction are bounded."205 },206 {207 "construct": "UTXOWire.verifyChain: identity block of every endpoint",208 "location": "Sources/QyvoraNetworking/UTXOIndexer.swift:319",209 "verdict": "safe",210 "note": "An endpoint that serves another hash at the identity height fails the whole verification (disagreement → wrongChain); endpoints that do not answer are tolerated as long as one confirmed the chain. The check is made once per session and per endpoint list; an endpoint that passes it and lies afterwards is the subject of endpoint_impact."211 },212 {213 "construct": "UTXOIndexers.survey: subtraction of tips, unbounded Esplora tip",214 "location": "Sources/QyvoraNetworking/UTXOIndexer.swift:470",215 "verdict": "fixed",216 "note": "An Esplora endpoint answering a tip of Int.min made `best - tip` overflow: the process trapped at every synchronization of a coin with two indexers (verified: SIGTRAP on the build node before the fix).",217 "finding_id": "QYV-SVC-060"218 },219 {220 "construct": "UTXOIndexers.survey: the endpoint announcing the highest tip becomes the reading source",221 "location": "Sources/QyvoraNetworking/UTXOIndexer.swift:476",222 "verdict": "open",223 "note": "Meant against stalled indexers; it also lets any one configured endpoint take over what is read by announcing a tip up to 99 999 999 (a higher one is no answer). There is no cross-check of balances or history between indexers.",224 "finding_id": "QYV-APP-061"225 },226 {227 "construct": "UTXOWire.saysAlreadyKnown: which refusals of a broadcast count as success",228 "location": "Sources/QyvoraNetworking/UTXOIndexer.swift:348",229 "verdict": "fixed",230 "note": "Matched any text containing 'known' ('unknown error') and `txn-mempool-conflict`: a refused payment was reported as sent. Now only the node's own 'already have it' messages.",231 "finding_id": "QYV-SVC-061"232 },233 {234 "construct": "BlockbookClient: parsing of amounts, heights, pages, estimates",235 "location": "Sources/QyvoraNetworking/Blockbook.swift:140",236 "verdict": "safe",237 "note": "Amounts are decimal strings of at most 20 digits converted exactly; heights pass UTXOWire.height; the tip is bounded; estimates must be plain decimal text, finite, positive, at most 1000 coins per kB; the page returned is the one that counts. Fuzz target json-blockbook."238 },239 {240 "construct": "BitcoreClient: coins, markers, history rebuilt from coins",241 "location": "Sources/QyvoraNetworking/Bitcore.swift:122",242 "verdict": "safe",243 "note": "Coin lists are bounded by coinLimit and a longer address is reported incomplete (never silently truncated: coins() throws, stats() says isComplete false); outputs must belong to the transaction asked for. Outputs are ordered by mintIndex without checking that the indices are 0…n-1: a hostile instance can shift positions, which the wallet's cross-check of coins against their transaction then refuses (denial of service only). No raw transactions: rawTransaction throws unsupported. Fuzz target json-bitcore."244 },245 {246 "construct": "EsploraClient as a UTXOIndexer: tip bound",247 "location": "Sources/QyvoraNetworking/UTXOIndexer.swift:375",248 "verdict": "fixed",249 "note": "The tip is text written by the endpoint and was returned unbounded.",250 "finding_id": "QYV-SVC-060"251 },252 {253 "construct": "WalletService.verifiedIndexers",254 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:104",255 "verdict": "safe",256 "note": "Mainnet gate first, cold mode second, then the identity block of each client; a client on another chain fails everything."257 },258 {259 "construct": "WalletService.checkCoinTransaction / assembleUTXOCoin: what is kept of an indexer's answers",260 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:240",261 "verdict": "safe",262 "note": "Identifiers, counts (25 000 inputs or outputs), amounts and totals against the network's monetary range with overflow-checked sums, heights, duplicate outpoints. Every transaction must involve the address it was listed for; two versions of one transaction are refused; an unspent output must agree with its transaction (amount, script) or is left out; at most 5 000 coins per address; the script of a coin is always the wallet's own derived script, never the indexer's. Fuzz target utxo-indexer-normalise."263 },264 {265 "construct": "WalletService.enforceUnauditedCoinLimits",266 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:554",267 "verdict": "safe",268 "note": "Value (USD ceiling at a fresh price, refused without one), absolute fee, fee rate; called when a payment is prepared and again on what will be signed."269 },270 {271 "construct": "WalletService.validateCoinPlan: monetary range of the plan check",272 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:692",273 "verdict": "fixed",274 "note": "Bitcoin's 21 million was applied to every coin: a Dogecoin or Litecoin payment whose outputs exceed 2.1e15 base units was refused at signature.",275 "finding_id": "QYV-SVC-062"276 },277 {278 "construct": "WalletService.validateCoinPlan: the output excluded from the value ceiling must be the wallet's change",279 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:704",280 "verdict": "fixed",281 "note": "The ceiling was computed on every output except `changeIndex` without checking that this output returns to the wallet. BitcoinSendPlan and BitcoinTransactionPlan have no public initializer and no mutable property, so no public interface could build such a plan: defence in depth. The Bitcoin path has the same shape (QYV-SVC-066, open).",282 "finding_id": "QYV-SVC-063"283 },284 {285 "construct": "WalletService.previousTransactions(for:): raw transactions authenticated by their hash",286 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:727",287 "verdict": "safe",288 "note": "Asked only of clients that serve raw transactions; bounded to 8 000 000 hexadecimal characters by the client and to 32 MiB by the transport; a transaction that does not hash to the identifier asked for is refused. Parsing and hashing are linear (a 1 MB transaction of 20 000 outputs: within the time bound of the property test)."289 },290 {291 "construct": "WalletService.signAndBroadcastCoin",292 "location": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:756",293 "verdict": "safe",294 "note": "Plan validated and limits applied again; the signing account must be the profile's and the vault's; signatures verified under the network's scheme; outputs, lock time, outpoints and sequences equal to the reviewed plan; identifier computed locally and compared with the endpoint's."295 },296 {297 "construct": "Cold signing of the coins",298 "location": "Sources/QyvoraWallet/WalletService+Cold.swift:90",299 "verdict": "safe",300 "note": "The service does not export PSBTs for Litecoin, Dogecoin or Bitcoin Cash, and a PSBT given to reviewPSBT / signPSBT is handled by the Bitcoin account of the primary network only. The PSBT support of the engine for these coins is tested at the engine level (property psbtPreviousTransactionsAuthenticateTheFee, fuzz target psbt-prevtx)."301 },302 {303 "construct": "checkAddress for UTXO chains: wrong family, wrong network, missing CashAddr prefix, legacy form",304 "location": "Sources/QyvoraWallet/WalletService+Send.swift:264",305 "verdict": "safe",306 "note": "A CashAddr typed without its prefix is refused by the service (missingPrefix), although the engine can decode it: nothing in it says which chain was meant. Precise refusals for another coin's address, another network's, the former Litecoin form."307 },308 {309 "construct": "prepareSend: the legacy-format fact was lost between the address check and the review",310 "location": "Sources/QyvoraWallet/WalletService+Send.swift:429",311 "verdict": "fixed",312 "note": "The canonical CashAddr was handed down and the review said nothing of the Base58 recipient.",313 "finding_id": "QYV-SVC-065"314 },315 {316 "construct": "Bitcoin Cash payments of coins older than the splits of Bitcoin SV and eCash",317 "location": "Sources/QyvoraWallet/WalletService+Send.swift:485",318 "verdict": "open",319 "note": "Those chains kept Bitcoin Cash's fork id: a transaction spending only pre-split coins is valid there too. The review now carries a critical warning when every coin of the payment was confirmed at or before block 661647 (and names Bitcoin SV when all are at or before 556766). The replay itself cannot be prevented by the wallet; ancestry is not examined and the heights are the indexer's.",320 "finding_id": "QYV-APP-062"321 },322 {323 "construct": "Mainnet gate for UTXO networks",324 "location": "Sources/QyvoraWallet/WalletService.swift:333",325 "verdict": "safe",326 "note": "Every production network of the coins is behind the same gate as Bitcoin's (internal build flag and user opt-in, both)."327 },328 {329 "construct": "Account derivation of the coins at onboarding and in the recovery sheet",330 "location": "Sources/QyvoraWallet/WalletService+Onboarding.swift:323",331 "verdict": "safe",332 "note": "m/84'/2'/0' (Litecoin), m/44'/3'/0' (Dogecoin), m/44'/145'/0' (Bitcoin Cash), coin type 1 on the test networks; the recovery sheet prints the path of the same UTXOAccount it derives (WalletService+Shield.swift). Campaign utxo-derivation compares paths, account keys and addresses with bip-utils."333 },334 {335 "construct": "Litecoin MWEB serialization (flag 0x08) is not parsed",336 "location": "Sources/QyvoraBitcoin/Transaction.swift:192",337 "verdict": "open",338 "note": "An MWEB integrating transaction (peg-out source) does not parse: fail closed. The wallet's Litecoin inputs are P2WPKH (no previous transaction needed), so payments are unaffected; a BIP-44 Litecoin account or a PSBT carrying such a previous transaction could not spend a coin pegged out of MWEB. One main-network vector shows the case.",339 "finding_id": "QYV-SVC-067"340 }341 ],342 "endpoint_policy": {343 "rule": "Clients of a network: Esplora, Blockbook, Bitcore — those that have an endpoint in the configuration. Each must serve the identity block (once per session); the client with the highest tip is read (first-answer inside a client: its endpoints are tried in order); fee estimates come from the first client that answers; raw transactions from the first client that serves them and whose bytes hash to the identifier; a broadcast goes to the clients in order until one accepts. There is no quorum on balances, coins or history.",344 "defaults": {345 "litecoin": {346 "esplora": [347 "litecoinspace.org"348 ],349 "blockbook": [350 "blockbook.ltc.zelcore.io",351 "litecoin.atomicwallet.io"352 ],353 "bitcore": [354 "api.bitcore.io"355 ]356 },357 "litecoinTestnet": {358 "esplora": [359 "litecoinspace.org"360 ],361 "bitcore": [362 "api.bitcore.io"363 ]364 },365 "dogecoin": {366 "blockbook": [367 "blockbook.doge.zelcore.io"368 ],369 "bitcore": [370 "api.bitcore.io"371 ],372 "raw_transactions": "one source only (the Blockbook instance): without it Dogecoin payments are refused (featureUnavailable / network), never signed unauthenticated"373 },374 "dogecoinTestnet": {375 "none": "no keyless public indexer: the network cannot be synchronized with the built-in configuration"376 },377 "bitcoinCash": {378 "blockbook": [379 "blockbook.bch.zelcore.io"380 ],381 "bitcore": [382 "api.bitcore.io"383 ]384 },385 "bitcoinCashTestnet": {386 "bitcore": [387 "api.bitcore.io"388 ],389 "note": "a single endpoint: everything displayed for this test network rests on it"390 }391 },392 "evidence": [393 {394 "ref": "Sources/QyvoraNetworking/UTXOIndexer.swift:439",395 "contains": "public static func clients(for network: BitcoinNetwork, configuration: EndpointConfiguration = .default,"396 },397 {398 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:134",399 "contains": "private func readingIndexer(_ network: BitcoinNetwork, notes: inout [String]) async throws -> (client: any UTXOIndexer, tip: UTXOChainTip) {"400 },401 {402 "ref": "Sources/QyvoraNetworking/HTTP.swift:246",403 "contains": "public static let defaultBlockbook: [String: [String]] = ["404 },405 {406 "ref": "Sources/QyvoraNetworking/HTTP.swift:251",407 "contains": "public static let defaultBitcore: [String: [String]] = ["408 }409 ]410 },411 "endpoint_impact": [412 {413 "capability": "Serve another chain (Bitcoin instead of Bitcoin Cash, eCash, Bitcoin SV, chipnet instead of testnet4, a private fork)",414 "wallet_behaviour": "The identity block is asked of every endpoint before anything is read or broadcast; a different hash fails the network (wrongChain).",415 "impact": "None beyond the refusal.",416 "mitigation": "Sources/QyvoraNetworking/UTXOIndexer.swift:327",417 "residual_risk": "An endpoint can serve the right identity block and then lie: the rows below."418 },419 {420 "capability": "Wrong balance, hidden coins, invented coins",421 "wallet_behaviour": "Coins are bounded, cross-checked against the history the same endpoint serves, and placed on scripts the wallet derived itself. A coin the endpoint invents cannot be spent: on Dogecoin its previous transaction cannot be forged (double SHA-256), on Bitcoin Cash and Litecoin the signature commits to the amount, and in every case the network refuses an outpoint that does not exist.",422 "impact": "Display only: a balance that is too high, too low or zero; a payment built on invented coins fails at signature (Dogecoin) or at broadcast. Denial of service, no loss of funds.",423 "mitigation": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:341",424 "residual_risk": "The user can be shown an incoming payment that does not exist (or miss one that does) for as long as the endpoint lies: QYV-APP-061. Hidden coins make funds look lost; the recovery phrase and another indexer show them again."425 },426 {427 "capability": "Understate or overstate the amount of a real coin (the fee-burn attack)",428 "wallet_behaviour": "Dogecoin: before signing, the transaction that created each coin is fetched, its identifier recomputed, and its amount and script compared with the plan; any difference stops the payment (untrustedResponse), nothing is signed. Bitcoin Cash: the fork-id digest commits to the amount; Litecoin: the wallet's inputs are P2WPKH and BIP-143 commits to the amount — a signature made under a false amount is invalid on the network.",429 "impact": "None on funds. A payment that cannot be made while the endpoint lies.",430 "mitigation": "Sources/QyvoraBitcoin/Account.swift:334",431 "residual_risk": "On Dogecoin the raw transactions come from a single default source (Blockbook): if it is down or refuses, Dogecoin payments are unavailable, not unsafe."432 },433 {434 "capability": "Forge a previous transaction",435 "wallet_behaviour": "The bytes must hash to the outpoint's identifier.",436 "impact": "None (second preimage of double SHA-256).",437 "mitigation": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:727",438 "residual_risk": "None. An oversized answer is bounded (8 000 000 hexadecimal characters, 32 MiB per response) and parsed in linear time."439 },440 {441 "capability": "Wrong fee estimates",442 "wallet_behaviour": "Estimates are converted with bounds, clamped to the network's floor and ceiling and, on a main network of an unaudited build, to the build's rate ceiling; the builder caps the absolute fee; the limits are applied again at signature.",443 "impact": "At most the ceilings: 200 litoshi/vB and 0.001 LTC; 1 DOGE/kB and 5 DOGE; 20 sat/byte and 0.0005 BCH per transaction. A rate that is too low delays confirmation (replace-by-fee exists on Litecoin and Dogecoin, not on Bitcoin Cash).",444 "mitigation": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:498",445 "residual_risk": "On test networks only the network's own ceiling applies (5 000 lit/vB, 1 DOGE/kB, 1 000 sat/byte) and the builder's absolute cap (0.01 LTC, 10 DOGE, 0.01 BCH)."446 },447 {448 "capability": "Censor or fake a broadcast",449 "wallet_behaviour": "The transaction is sent to each client until one accepts; the identifier is computed locally and an endpoint answering another one is an error (broadcastMismatch). A refusal is reported as such (QYV-SVC-061 fixed: a refusal containing 'known' or a mempool conflict was reported as success).",450 "impact": "An endpoint can answer 'accepted' and drop the transaction: the wallet shows a pending payment that never confirms, and hides the coins it spent until the next synchronization.",451 "mitigation": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:794",452 "residual_risk": "No independent confirmation that a transaction reached the network. The signed bytes are returned to the application (rawHex) and can be broadcast elsewhere."453 },454 {455 "capability": "Forged history, forged confirmations, a tip far in the future",456 "wallet_behaviour": "Transactions must involve the address they are listed for and be internally consistent; the tip is bounded (below 10^8 in the service). Confirmations are tip minus height + 1 as the reading endpoint states them.",457 "impact": "Display: a payment shown as confirmed or settled that is not (or the reverse); history entries that never happened. No signature depends on confirmations except the coinbase maturity rule and the choice of confirmed coins.",458 "mitigation": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:180",459 "residual_risk": "QYV-APP-061: the endpoint announcing the highest tip is the one read, so any single configured endpoint can do this, not only the first. Bitcoin Cash Testnet has a single endpoint. A user who releases goods on the wallet's display alone can be defrauded by a lying endpoint. Since this audit an endpoint announcing a tip of 10^8 or more is left out of the survey (before, it was chosen and then refused, and every synchronization of the network failed)."460 },461 {462 "capability": "Crash the wallet with a hostile answer",463 "wallet_behaviour": "Every field is bounded before arithmetic; decoding errors are invalidResponse. One trap was found and fixed (QYV-SVC-060: tip of Int.min in the survey).",464 "impact": "None known after the fix. 8 fuzz targets on these parsers and on the synchronization itself.",465 "mitigation": "Sources/QyvoraNetworking/UTXOIndexer.swift:470",466 "residual_risk": "Fuzzing is not a proof; the campaigns are listed in the report. An indexer that marks every address as used makes a synchronization long and memory-hungry: the scan is bounded (2 000 indices per chain, 20 history pages per address, 32 MiB per response) but not as a whole — a slow or failed synchronization, not a crash observed."467 },468 {469 "capability": "Learn the wallet's addresses",470 "wallet_behaviour": "Every address of the gap-limit scan is sent to the indexer (address statistics, coins, history).",471 "impact": "Privacy: the operator of an endpoint links the addresses of the account and the client's IP address.",472 "mitigation": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:197",473 "residual_risk": "Inherent to an indexer-based light wallet; the user can configure an indexer of their own."474 }475 ],476 "replay_protection": {477 "bitcoin_cash_vs_bitcoin": "Bitcoin Cash signatures carry SIGHASH_FORKID (byte 0x41 for ALL) and sign the BIP-143-style digest with the amount; the wallet never signs without the flag on Bitcoin Cash and never with it elsewhere. A Bitcoin Cash signature is invalid under Bitcoin's digest and a Bitcoin signature (no flag) is rejected by Bitcoin Cash nodes. Tested: property replayProtectionBetweenTheChains (300 / 4000 keys and outpoints), differential utxo-signed-p2pkh-transaction, main-network vectors (invalid-under-another-scheme).",478 "bitcoin_cash_vs_bitcoin_sv_and_ecash": "Residual risk. Bitcoin SV (split at block 556767, 2018-11-15) and eCash / XEC (split at block 661648, 2020-11-15) kept the same fork id 0 and the same digest: a Bitcoin Cash transaction whose inputs all descend from coins that existed before a split, and were never mixed with coins created after it on either side, is valid on the other chain too and can be replayed there by anyone. The wallet cannot prevent it (no post-split input is added); since this audit the review of a payment whose coins were all confirmed before a split carries a critical warning (heights as the indexer reports them; ancestry not examined). Who is exposed: a user who restores into QYVORA a recovery phrase that held Bitcoin Cash before November 2020 (eCash) or November 2018 (Bitcoin SV) and still holds the corresponding coins on the other chain; a payment of such coins on Bitcoin Cash can move the same coins on the other chain to the same recipient key. Recorded as QYV-APP-062 (open).",479 "litecoin_dogecoin_vs_bitcoin": "Litecoin and Dogecoin use Bitcoin's transaction format and, for P2PKH inputs, the same original digest (verified: the same key and transaction give byte-identical signatures under schemes .legacy and .bip143). Nothing in the signature names the chain: it is bound to the outpoints it spends (txid:vout), which exist on one chain only — a transaction identifier commits to the whole ancestry back to coinbase transactions, which differ between chains that do not share a history. Litecoin P2WPKH (BIP-143) is the same algorithm as Bitcoin's P2WPKH with the same property.",480 "derivation_paths": {481 "litecoin": "m/84'/2'/0' (BIP-84, P2WPKH)",482 "dogecoin": "m/44'/3'/0' (BIP-44, P2PKH)",483 "bitcoinCash": "m/44'/145'/0' (BIP-44, P2PKH)",484 "bitcoin": "m/84'/0'/0'",485 "test_networks": "coin type 1 for all: Dogecoin Testnet and Bitcoin Cash Testnet share m/44'/1'/0' (same keys), Litecoin Testnet shares m/84'/1'/0' with Bitcoin Testnet and Signet. Test coins have no value; the address encodings differ (version bytes, prefixes) except the 0x6f / 0xc4 bytes common to the Base58 test networks.",486 "main_networks": "four distinct coin types: no key is shared between two coins (asserted by the property test over a random seed)."487 },488 "evidence": [489 {490 "ref": "Sources/QyvoraBitcoin/Transaction.swift:94",491 "contains": "public static let allForkID = BitcoinSighashType(rawValue: 0x41)"492 },493 {494 "ref": "Sources/QyvoraBitcoin/Transaction.swift:106",495 "contains": "scheme == .bip143ForkID ? hasForkID && withoutForkID.isStandard : isStandard"496 },497 {498 "ref": "security/tests/Tests/PropertyAuditTests/UTXOCoinsProperties.swift:627",499 "contains": "func replayProtectionBetweenTheChains() throws {"500 },501 {502 "ref": "Sources/QyvoraCore/Networks.swift:61",503 "contains": "case .bitcoinCash: return 145"504 }505 ]506 },507 "policy_differences": [508 "CashAddr: bitcash's Address.from_string accepts non-zero padding bits and does not check the hash length; the engine applies the specification (and Bitcoin Cash Node's convertbits without padding) and refuses them. bitcash knows three prefixes and six version bytes; the engine decodes any lower-case prefix and the sixteen types at the CashAddr layer, and the address layer accepts only the network's prefix with 20-byte P2PKH / P2SH.",509 "CashAddr: a prefix longer than 40 letters and text longer than 160 characters are refused before decoding (the specification sets no bound).",510 "Litecoin: the former P2SH version byte 0x05 (0xc4 on testnet), which Litecoin Core still decodes, is refused (ambiguousLegacyFormat).",511 "Bitcoin Cash: 32-byte P2SH (P2SH32) and token-aware CashAddr types are refused as recipients (unsupportedAddressType); a CashAddr without prefix is decoded by the engine and refused by the service (missingPrefix).",512 "Bitcoin Cash: Schnorr signatures (65-byte elements) are reported unsupportedSignature by the verifier; the wallet signs ECDSA only. One of the ten Bitcoin Cash inputs of the main-network vectors is Schnorr.",513 "Bitcoin Cash: dust is 546 satoshis for every script; the node computes 540 for P2SH. Dogecoin: the fee floor is the recommended 0.01 DOGE/kB, ten times the node's relay minimum; the dust threshold is the soft limit 0.01 DOGE, ten times the hard limit.",514 "Hash types: the wallet signs SIGHASH_ALL only (0x01; 0x41 on Bitcoin Cash); the signer accepts the six standard base types on request and never SIGHASH_UTXOS (0x20).",515 "Litecoin MWEB serialization (flag 0x08) is not parsed (QYV-SVC-067); MWEB addresses are refused.",516 "Replace-by-fee: transactions signal BIP-125 (sequence 0xfffffffd) on Litecoin and Dogecoin and not on Bitcoin Cash. Dogecoin Core 1.14.9 replaces by default (DEFAULT_ENABLE_REPLACEMENT true); Litecoin Core 0.21.4 does not (false): there the signal is harmless and unused — the service offers no fee bump for these coins.",517 "Taproot on Litecoin: ltc1p… (Bech32m, witness version 1) addresses are accepted as recipients; the deployment is defined in Litecoin Core's chainparams (DEPLOYMENT_TAPROOT, activated with MWEB in 2022). The wallet's own Litecoin addresses are P2WPKH only."518 ],519 "reference_defects": [520 "embit 0.8.0, Transaction.sighash_legacy: the blank outputs of SIGHASH_SINGLE are serialized with value 0xffffffff instead of -1 (CTxOut::SetNull), so its digest is wrong for SIGHASH_SINGLE on any input but the first. Evidence: the algorithm rewritten in the oracle from Bitcoin Core's SignatureHash reproduces the 621 Bitcoin Cash Node vectors whose script has no OP_CODESEPARATOR (5 of them SIGHASH_SINGLE beyond the first input) and equals the engine on every random case; embit differs on exactly the SIGHASH_SINGLE cases beyond the first input (187 of 1907 in the quick run recorded in the report). The wallet never signs SIGHASH_SINGLE."521 ],522 "wallet_audit_items": [523 {524 "id": "WA-UTXO-01",525 "title": "Litecoin, Dogecoin, Bitcoin Cash: derivation paths, and the recovery sheet prints the paths that are derived",526 "group": "recovery-phrase",527 "verdict": "pass",528 "scope": "service",529 "rationale": "Accounts are m/84'/2'/0' (Litecoin, native SegWit), m/44'/3'/0' (Dogecoin) and m/44'/145'/0' (Bitcoin Cash), coin type 1 on test networks: the SLIP-0044 values other wallets use. The recovery sheet builds each entry from the same `UTXOAccount` and prints its `accountPath`, its account key (xpub / tpub) and its first address. Account paths, account keys, addresses, public keys, private keys and WIF are compared with bip-utils on random seeds (400 in quick mode, 4 000 in full mode).",530 "residual_risk": "Extended keys are written with Bitcoin's version bytes (xpub / tpub), not the coin-specific ones some wallets display (Ltub, dgub): the sheet says so. Test networks share coin type 1, hence keys, between coins.",531 "evidence": [532 {533 "ref": "Sources/QyvoraWallet/WalletService+Onboarding.swift:323",534 "contains": "static func utxoAccountPath(_ network: BitcoinNetwork) -> DerivationPath { StandardPaths.account(network.defaultPurpose, network) }"535 },536 {537 "ref": "Sources/QyvoraWallet/WalletService+Shield.swift:417",538 "contains": "chain: network.displayName, networks: network.isTest ? \"test network\" : \"main network\", derivationPath: account.accountPath.description,"539 },540 {541 "ref": "Sources/QyvoraCore/Networks.swift:283",542 "contains": "public var defaultPurpose: UTXOAccountPurpose { supportsSegWit ? .bip84 : .bip44 }"543 },544 {545 "ref": "security/tests/Tests/DifferentialAuditTests/UTXOCoinsDiffTests.swift:335",546 "contains": "func accountDerivations() throws {"547 },548 {549 "ref": "Tests/QyvoraWalletTests/UTXOCoinTests.swift:98",550 "contains": "func accountsOfEveryCoinMatchThePublishedVectors() async throws {"551 }552 ]553 },554 {555 "id": "WA-UTXO-02",556 "title": "Address validation of the UTXO coins: no acceptance of another coin's address",557 "group": "fraud-protection",558 "verdict": "pass",559 "scope": "both",560 "rationale": "An address is accepted only in the encodings of its own network: Litecoin 0x30 / 0x32 / ltc1 (the former 0x05 P2SH form, Bitcoin's own, is refused); Dogecoin 0x1e / 0x16 and no SegWit address; Bitcoin Cash CashAddr with the network's prefix, 20-byte P2PKH and P2SH only. Version bytes and prefixes match the reference clients and bip-utils. CashAddr decoding matches the specification's vectors and bitcash on altered and crafted strings; every single substitution tried is refused. The service refuses a CashAddr without prefix and names the family of a foreign address. The legacy Base58 form of a Bitcoin Cash address — also a Bitcoin address — is accepted, converted, and raises a critical warning in the review.",561 "gap": "The interface must make the user acknowledge the critical warning before signing and should show the CashAddr form next to what was typed (QYV-APP-060). Test networks of different coins share the Base58 bytes 0x6f / 0xc4, as their reference clients do.",562 "finding": "QYV-SVC-065",563 "evidence": [564 {565 "ref": "Sources/QyvoraBitcoin/Address.swift:179",566 "contains": "} else if version == network.deprecatedP2SHVersion {"567 },568 {569 "ref": "Sources/QyvoraBitcoin/Address.swift:147",570 "contains": "guard decoded.hash.count == 20 else { throw Error.unsupportedAddressType }"571 },572 {573 "ref": "Sources/QyvoraWallet/WalletService+Send.swift:265",574 "contains": "throw WalletError.address(.missingPrefix(chain: coin, prefix: prefix))"575 },576 {577 "ref": "Sources/QyvoraWallet/WalletService+Send.swift:472",578 "contains": "static let legacyAddressWarningID = \"bch.legacy-address\""579 },580 {581 "ref": "security/tests/Tests/DifferentialAuditTests/UTXOCoinsDiffTests.swift:243",582 "contains": "func addressFormatsAndCrossNetworkAcceptance() throws {"583 },584 {585 "ref": "security/tests/Tests/PropertyAuditTests/UTXOCoinsProperties.swift:179",586 "contains": "func addressScriptRoundTripAndNoCrossCoinAcceptance() throws {"587 },588 {589 "ref": "security/tests/Tests/ConformanceAuditTests/UTXOCoinsVectors.swift:65",590 "contains": "func cashAddrSpecificationTables() throws {"591 },592 {593 "ref": "Tests/QyvoraWalletTests/UTXOCoinsAddressAuditRegressionTests.swift:53",594 "contains": "func aLegacyBitcoinCashRecipientIsACriticalWarningOfTheReview() async throws {"595 }596 ]597 },598 {599 "id": "WA-UTXO-03",600 "title": "Replay protection of the UTXO coins",601 "group": "replay-protection",602 "verdict": "partial",603 "scope": "service",604 "rationale": "Bitcoin Cash: every signature carries SIGHASH_FORKID (0x41) over the fork-id digest; it is invalid on Bitcoin, and a Bitcoin, Litecoin or Dogecoin signature is invalid on Bitcoin Cash (tested both ways on random keys and on main-network transactions). Litecoin and Dogecoin sign the same digest as Bitcoin; a signature is bound to outpoints that exist on one chain only, and the main networks use four distinct coin types, so no key is shared between coins.",605 "gap": "Bitcoin SV and eCash share Bitcoin Cash's fork id: a payment of coins that predate their splits (2018-11-15, 2020-11-15) can be replayed on those chains. The wallet cannot prevent it; since this audit the review carries a critical warning when every coin of the payment predates a split (heights as the indexer reports them; ancestry not examined). The interface must make the user acknowledge it (QYV-APP-060).",606 "finding": "QYV-APP-062",607 "evidence": [608 {609 "ref": "Sources/QyvoraBitcoin/Transaction.swift:106",610 "contains": "scheme == .bip143ForkID ? hasForkID && withoutForkID.isStandard : isStandard"611 },612 {613 "ref": "Sources/QyvoraBitcoin/Signing.swift:110",614 "contains": "let type = sighashType.adapted(to: scheme)"615 },616 {617 "ref": "security/tests/Tests/PropertyAuditTests/UTXOCoinsProperties.swift:627",618 "contains": "func replayProtectionBetweenTheChains() throws {"619 },620 {621 "ref": "security/tests/Tests/ConformanceAuditTests/UTXOCoinsVectors.swift:279",622 "contains": "\"invalid-under-another-scheme\""623 },624 {625 "ref": "Sources/QyvoraWallet/WalletService+Send.swift:478",626 "contains": "static let lastBlockSharedWithECash = 661_647"627 },628 {629 "ref": "Tests/QyvoraWalletTests/UTXOCoinsAuditRegressionTests.swift:261",630 "contains": "func bitcoinCashCoinsOlderThanAChainSplitRaiseACriticalWarning() async throws {"631 }632 ]633 },634 {635 "id": "WA-UTXO-04",636 "title": "Dogecoin: every coin is checked against the transaction that created it before it is signed",637 "group": "fraud-protection",638 "verdict": "pass",639 "scope": "service",640 "rationale": "The original signature hash does not commit to the amounts spent: an indexer understating a coin would turn the difference into fee. Before signing a P2PKH input outside Bitcoin Cash the account requires the previous transaction, recomputes its identifier, and compares the amount and the script; the service fetches the raw transactions and refuses any that does not hash to the identifier asked for. A PSBT reports a fee only from authenticated previous outputs and the account signs a PSBT only when the whole fee is known. On Bitcoin Cash and for Litecoin's P2WPKH inputs the signature commits to the amount: one made under a false amount is invalid on the network (tested).",641 "residual_risk": "Dogecoin has one default source of raw transactions (a Blockbook instance): without it payments are refused. Cold signing is not offered for these coins by the service.",642 "finding": "QYV-SVC-064",643 "evidence": [644 {645 "ref": "Sources/QyvoraBitcoin/Account.swift:335",646 "contains": "} else if requiresPreviousTransactions {"647 },648 {649 "ref": "Sources/QyvoraBitcoin/CoinSelection.swift:156",650 "contains": "public func isAuthenticated(by previous: BitcoinTransaction) -> Bool {"651 },652 {653 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:727",654 "contains": "guard let tx = try? BitcoinTransaction(hex: hex, allowWitness: network.supportsSegWit), tx.txid == txid else {"655 },656 {657 "ref": "Sources/QyvoraBitcoin/Account.swift:407",658 "contains": "guard copy.inputs.allSatisfy({ $0.nonWitnessUTXO != nil }) else { throw PSBTError.nonWitnessUTXORequired }"659 },660 {661 "ref": "Tests/QyvoraWalletTests/UTXOCoinsAuditRegressionTests.swift:192",662 "contains": "func aLyingIndexerCannotBurnFees() async throws {"663 },664 {665 "ref": "Tests/QyvoraBitcoinTests/UTXOCoinsAuditRegressionTests.swift:106",666 "contains": "func nothingIsSignedWhenTheFeeIsNotAuthenticated() throws {"667 },668 {669 "ref": "security/tests/Tests/PropertyAuditTests/UTXOCoinsProperties.swift:523",670 "contains": "func psbtPreviousTransactionsAuthenticateTheFee() throws {"671 }672 ]673 },674 {675 "id": "WA-UTXO-05",676 "title": "Fee floors, ceilings and dust of the UTXO coins",677 "group": "fees-nonces-utxos",678 "verdict": "pass",679 "scope": "service",680 "rationale": "Per network: a fee floor (Litecoin 1 lit/vB, Dogecoin 0.01 DOGE/kB — the reference wallet's recommended fee —, Bitcoin Cash 1 sat/byte), a ceiling above which nothing is built, and the dust rule of the reference client (Litecoin: Bitcoin Core's formula at 30 000 lit/kvB; Dogecoin: 0.01 DOGE; Bitcoin Cash: 546 sat). The builder conserves value exactly, never creates a dust output, leaves a remainder to the fee only within the cost of a change output, never pays a witness program where SegWit does not exist, and signals replace-by-fee except on Bitcoin Cash. Estimates of an indexer are clamped to the floor and ceiling.",681 "evidence": [682 {683 "ref": "Sources/QyvoraCore/Networks.swift:330",684 "contains": "return UTXOFeePolicy(minimumFeeRatePerKiloVByte: 1_000_000, maximumFeeRatePerKiloVByte: 100_000_000, dust: .fixed(1_000_000))"685 },686 {687 "ref": "Sources/QyvoraBitcoin/TransactionBuilder.swift:70",688 "contains": "case witnessScriptNotSupported"689 },690 {691 "ref": "Sources/QyvoraBitcoin/TransactionBuilder.swift:422",692 "contains": "guard fee <= ceiling else { throw BitcoinBuildError.absurdFee(fee: fee, expected: ceiling) }"693 },694 {695 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:533",696 "contains": "if let v = estimates[t], let r = FeeRate.fromEstimate(satPerVByte: v) { return (min(r.clamped(to: network), cap), t) }"697 },698 {699 "ref": "security/tests/Tests/PropertyAuditTests/UTXOCoinsProperties.swift:276",700 "contains": "func builderAndSignatureInvariantsPerCoin() throws {"701 },702 {703 "ref": "security/tests/Tests/PropertyAuditTests/UTXOCoinsProperties.swift:435",704 "contains": "func feeDustAndLimitConstants() throws {"705 },706 {707 "ref": "security/tests/Tests/ConformanceAuditTests/UTXOCoinsVectors.swift:310",708 "contains": "func chainConstantsAgainstReferenceClients() {"709 }710 ]711 },712 {713 "id": "WA-UTXO-06",714 "title": "Limits of an unaudited build on Litecoin, Dogecoin and Bitcoin Cash, at prepare and at sign",715 "group": "mainnet-gate",716 "verdict": "pass",717 "scope": "service",718 "rationale": "On a main network of an unaudited build one transaction sends at most 150 USD of the coin (converted with a fresh price; without one the payment is refused), pays at most 0.001 LTC / 5 DOGE / 0.0005 BCH of fee and at most 200 lit/vB / 1 DOGE/kB / 20 sat/byte. The ceilings are applied when the payment is prepared and again, on the transaction that will be signed, before the vault is used: the value is recomputed from the outputs, the fee from the wallet's own record of the coins, and the output excluded as change must be a script of the wallet's change chain. The plan types have no public initializer and no mutable property; plans altered from inside the module are refused in tests for each of the three coins.",719 "residual_risk": "The value ceiling depends on one price source (see the price-floor item of the multi-chain wallet audit). The limits bound one transaction, not the balance.",720 "finding": "QYV-SVC-063",721 "evidence": [722 {723 "ref": "Sources/QyvoraCore/Networks.swift:448",724 "contains": "return UTXOLimits(value: .usd(limits.nativeUSDPerTransaction), feePerTransaction: 500_000_000, feeRatePerVByte: 100_000)"725 },726 {727 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:621",728 "contains": "try await enforceUnauditedCoinLimits(network: network, amount: paidAmount, fee: plan.fee, vsize: plan.estimatedVSize)"729 },730 {731 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:709",732 "contains": "try await enforceUnauditedCoinLimits(network: network, amount: recipients, fee: plan.fee, vsize: plan.plan.estimatedVSize)"733 },734 {735 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:704",736 "contains": "(0..<limit).contains(where: { (try? account.scriptPubKey(chain: .change, index: $0)) == script }) else {"737 },738 {739 "ref": "Tests/QyvoraWalletTests/UTXOCoinsAuditRegressionTests.swift:80",740 "contains": "func coinLimitsHoldAtPrepareAndAtSignEvenWithAnAlteredPlan() async throws {"741 },742 {743 "ref": "Tests/QyvoraWalletTests/UTXOCoinTests.swift:477",744 "contains": "func dogecoinMainnetLimitsAtPrepareAndAtSignAndPreviousTransactions() async throws {"745 }746 ]747 },748 {749 "id": "WA-UTXO-07",750 "title": "Mainnet gate of the UTXO coins: both conditions",751 "group": "mainnet-gate",752 "verdict": "pass",753 "scope": "service",754 "rationale": "Litecoin, Dogecoin and Bitcoin Cash main networks are refused unless the build allows main networks and the user opted in — the same two conditions as Bitcoin's; the account, the indexers, the synchronization and the payment all pass through the gate, and no request is made for a main network while it is closed.",755 "evidence": [756 {757 "ref": "Sources/QyvoraWallet/WalletService.swift:333",758 "contains": "if !network.isTest, !MainnetPolicy.mainnetEnabled { throw WalletError.mainnetDisabled(WalletError.mainnetText) }"759 },760 {761 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:83",762 "contains": "try requireAllowed(network)"763 },764 {765 "ref": "Sources/QyvoraCore/Networks.swift:558",766 "contains": "return auditCompleted || (internalBuild && userOptIn)"767 },768 {769 "ref": "Tests/QyvoraWalletTests/UTXOCoinTests.swift:452",770 "contains": "func theCoinsAreBehindTheMainnetGate() async throws {"771 }772 ]773 },774 {775 "id": "WA-UTXO-08",776 "title": "Chain identity of the UTXO coin indexers",777 "group": "network",778 "verdict": "pass",779 "scope": "service",780 "rationale": "Before anything is read or broadcast each indexer must serve the network's identity block: the genesis block for Litecoin and Dogecoin; block 661648 for Bitcoin Cash (its genesis is Bitcoin's, Bitcoin SV's and eCash's) and block 200000 for its testnet4 (whose genesis is chipnet's). An endpoint on another chain fails the network (wrongChain). The constants were compared with the reference clients' sources and with two or three public indexers each.",781 "residual_risk": "The check is made once per session and per endpoint list; it identifies the chain, not the honesty of the endpoint.",782 "evidence": [783 {784 "ref": "Sources/QyvoraCore/Networks.swift:356",785 "contains": "return UTXOChainIdentity(height: 661_648, hash: \"0000000000000000029e471c41818d24b8b74c911071c4ef0b4a0509f9b5a8ce\")"786 },787 {788 "ref": "Sources/QyvoraNetworking/UTXOIndexer.swift:327",789 "contains": "guard hash == identity.hash else {"790 },791 {792 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:122",793 "contains": "throw WalletError.wrongChain(text)"794 },795 {796 "ref": "security/tests/Tests/ConformanceAuditTests/UTXOCoinsVectors.swift:310",797 "contains": "func chainConstantsAgainstReferenceClients() {"798 },799 {800 "ref": "Tests/QyvoraWalletTests/UTXOCoinTests.swift:222",801 "contains": "func bitcoinCashTestnetIdentityAddressesAndForkIdSpend() async throws {"802 }803 ]804 },805 {806 "id": "WA-UTXO-09",807 "title": "Endpoint policy of the UTXO coins: what one lying indexer can do",808 "group": "network",809 "verdict": "partial",810 "scope": "service",811 "rationale": "No signature can be obtained for something the user did not review, and no fee above the ceilings can be paid, whatever an indexer answers: amounts are authenticated (previous transactions on Dogecoin, signature commitment on Bitcoin Cash and Litecoin), fee estimates are clamped, identifiers are computed locally, answers are bounded and validated (8 fuzz targets, one trap found and fixed). What an indexer decides is what the wallet displays.",812 "gap": "Balances, history and confirmations are read from one indexer — the one announcing the highest tip — without cross-check: a lying or compromised endpoint can show a payment that does not exist, hide one, or report false confirmations. Bitcoin Cash Testnet has a single endpoint; Dogecoin has a single source of raw transactions.",813 "finding": "QYV-APP-061",814 "evidence": [815 {816 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:134",817 "contains": "private func readingIndexer(_ network: BitcoinNetwork, notes: inout [String]) async throws -> (client: any UTXOIndexer, tip: UTXOChainTip) {"818 },819 {820 "ref": "Sources/QyvoraNetworking/UTXOIndexer.swift:464",821 "contains": "public static func survey(_ clients: [any UTXOIndexer]) async -> [Survey] {"822 },823 {824 "ref": "Sources/QyvoraWallet/WalletService+UTXOCoins.swift:310",825 "contains": "throw WalletError.untrustedResponse(\"transaction \\(checked.txid.prefix(12))… does not involve the address it was listed for\")"826 },827 {828 "ref": "Tests/QyvoraNetworkingTests/UTXOCoinsAuditRegressionTests.swift:62",829 "contains": "func hostileTipHeightsNeitherTrapNorWinTheSurvey() async throws {"830 },831 {832 "ref": "Tests/QyvoraNetworkingTests/UTXOCoinsAuditRegressionTests.swift:95",833 "contains": "func aRefusedBroadcastIsNeverReportedAsAlreadyKnown() async throws {"834 }835 ]836 }837 ]838}839