Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : QYVORA7// File : Sources/QyvoraNetworking/UTXOIndexer.swift8// Module : Qyvora Networking9// Repository : https://git.spboucher.ai/qyvora10// Project Website : Not specified11// Created : 2026-12-0512// Last Modified : 2026-12-0513//14// Author : Simon-Pierre Boucher15// Position : Professor of Finance16// Institution : Université du Québec en Outaouais (UQO)17// Organization : SP Boucher18// Website : https://spboucher.ai19// Git : https://git.spboucher.ai20//21// Preferred Contact: contact@spboucher.ai22// Development : dev@spboucher.ai23// Support : support@spboucher.ai24// Security/Admin : admin@spboucher.ai25//26// Copyright (c) 202627// Simon-Pierre Boucher28// All rights reserved where applicable. This file is governed by the29// applicable project license, copyright notices and relevant law.30// Existing third-party rights and notices remain unaffected.31//32// License : None specified (no license file in this repository)33//34// Do not embed credentials, private keys, access tokens,35// certificates or confidential personal information.36//37// =============================================================================38// END OF SP BOUCHER SOURCE HEADER39// =============================================================================4041import Foundation42import QyvoraCore4344// MARK: - Models shared by every indexer protocol4546/// What an indexer knows about one address.47public struct UTXOAddressStats: Equatable, Sendable {48 public let address: String49 /// True when the address appeared in any transaction, confirmed or not.50 public let isUsed: Bool51 /// True when an output of this address was spent (its public key is then on chain). When the indexer could not52 /// list every coin of the address (`isComplete` false) this is reported true: exposure is assumed, never excluded.53 public let hasSpent: Bool54 /// Transactions touching the address, confirmed and unconfirmed; nil when the protocol does not count them.55 public let transactionCount: Int?56 /// Confirmed balance in base units; nil when the indexer does not give it or it does not fit 64 bits.57 public let confirmedBalance: UInt64?58 /// False when the answer was cut by a server-side limit.59 public let isComplete: Bool6061 public init(address: String, isUsed: Bool, hasSpent: Bool, transactionCount: Int?, confirmedBalance: UInt64?, isComplete: Bool = true) {62 self.address = address63 self.isUsed = isUsed64 self.hasSpent = hasSpent65 self.transactionCount = transactionCount66 self.confirmedBalance = confirmedBalance67 self.isComplete = isComplete68 }69}7071/// An unspent output as an indexer reports it. Nothing here is trusted: the wallet rebuilds the script from its own72/// address, bounds the value, and where signatures do not commit to amounts checks it against the raw transaction.73public struct UTXOIndexerCoin: Equatable, Hashable, Sendable {74 /// 64 lower-case hexadecimal characters.75 public let txid: String76 public let vout: UInt3277 /// Base units.78 public let value: UInt6479 /// Block height, nil while unconfirmed.80 public let height: Int?81 /// True, false, or nil when the protocol does not say.82 public let isCoinbase: Bool?8384 public init(txid: String, vout: UInt32, value: UInt64, height: Int?, isCoinbase: Bool? = nil) {85 self.txid = txid86 self.vout = vout87 self.value = value88 self.height = height89 self.isCoinbase = isCoinbase90 }9192 /// Confirmations at a given tip height: 0 while unconfirmed or when the indexer places the coin above the tip.93 public func confirmations(tipHeight: Int) -> UInt32 {94 guard let height, height >= 0, tipHeight >= height else { return 0 }95 // both are non-negative: the difference fits, and the + 1 is done in 64 unsigned bits96 return UInt32(clamping: UInt64(tipHeight - height) + 1)97 }98}99100/// A transaction of an address history, reduced to what every protocol provides.101public struct UTXOIndexerTransaction: Equatable, Sendable, Identifiable {102 public struct Coin: Equatable, Sendable {103 /// Address as the indexer writes it (CashAddr with or without prefix on Bitcoin Cash), nil for scripts without one.104 public let address: String?105 /// scriptPubKey in hexadecimal, when the protocol provides it.106 public let scriptPubKey: String?107 /// Base units.108 public let value: UInt64109110 public init(address: String?, scriptPubKey: String?, value: UInt64) {111 self.address = address112 self.scriptPubKey = scriptPubKey113 self.value = value114 }115 }116117 public struct Input: Equatable, Sendable {118 /// Spent outpoint; nil for a coinbase input.119 public let txid: String?120 public let vout: UInt32?121 /// The output being spent, when the indexer resolves it.122 public let previous: Coin?123 public let sequence: UInt32?124125 public init(txid: String?, vout: UInt32?, previous: Coin?, sequence: UInt32?) {126 self.txid = txid127 self.vout = vout128 self.previous = previous129 self.sequence = sequence130 }131 }132133 public let txid: String134 public let inputs: [Input]135 public let outputs: [Coin]136 /// Base units; nil when not reported.137 public let fee: UInt64?138 /// Virtual size in vbytes (plain size on networks without SegWit); nil when not reported.139 public let virtualSize: Int?140 /// Block height, nil while unconfirmed.141 public let height: Int?142 /// Block time (Unix seconds), nil while unconfirmed or when not reported.143 public let time: Int?144 public var id: String { txid }145146 public init(txid: String, inputs: [Input], outputs: [Coin], fee: UInt64?, virtualSize: Int?, height: Int?, time: Int?) {147 self.txid = txid148 self.inputs = inputs149 self.outputs = outputs150 self.fee = fee151 self.virtualSize = virtualSize152 self.height = height153 self.time = time154 }155}156157/// Position in an address history; opaque, valid only with the client and the address that produced it.158public struct UTXOHistoryCursor: Equatable, Hashable, Sendable, Codable {159 public let token: String160 public init(token: String) { self.token = token }161}162163/// One page of history, newest first.164public struct UTXOHistoryPage: Equatable, Sendable {165 public let transactions: [UTXOIndexerTransaction]166 /// nil when this was the last page.167 public let next: UTXOHistoryCursor?168169 public init(transactions: [UTXOIndexerTransaction], next: UTXOHistoryCursor?) {170 self.transactions = transactions171 self.next = next172 }173}174175/// The best block an indexer knows.176public struct UTXOChainTip: Equatable, Sendable {177 public let height: Int178 /// Time of that block, when the protocol gives it: an indexer that stopped synchronising shows an old one.179 public let time: Date?180181 public init(height: Int, time: Date?) {182 self.height = height183 self.time = time184 }185}186187// MARK: - Protocol188189/// What the wallet needs from an indexer of a UTXO chain, whatever REST protocol it speaks.190///191/// Every implementation: talks only to the endpoints of the user's configuration, through the injected transport192/// (cold mode, politeness and response-size limits live there); validates what it puts in a URL; bounds and validates193/// every field of an answer and reports anything unexpected as `NetworkError.invalidResponse`, never by trapping;194/// returns amounts as exact integers in base units.195public protocol UTXOIndexer: Sendable {196 var network: BitcoinNetwork { get }197 var indexerProtocol: UTXOIndexerProtocol { get }198 /// False when the configuration holds no acceptable endpoint of this protocol for the network.199 var isConfigured: Bool { get }200 /// Hosts of the configured endpoints.201 var hosts: [String] { get }202 /// False when the protocol cannot return raw transactions (Bitcore): `rawTransaction` then throws203 /// `NetworkError.unsupported`. Raw transactions are needed to authenticate amounts where signatures do not commit204 /// to them (Dogecoin) and to build PSBTs for non-SegWit inputs.205 var servesRawTransactions: Bool { get }206207 /// Checks that every configured endpoint serves the expected chain (`BitcoinNetwork.identityBlock`).208 /// Throws `NetworkError.disagreement` when one serves another chain, `allEndpointsFailed` when none answered.209 func verifyChain() async throws210 func tip() async throws -> UTXOChainTip211 /// Hash of the main-chain block at `height`, display byte order.212 func blockHash(height: Int) async throws -> String213 func stats(address: String) async throws -> UTXOAddressStats214 /// Unspent outputs of an address, confirmed and unconfirmed. Confirmations follow from `UTXOIndexerCoin.height`215 /// and the tip (`confirmations(tipHeight:)`).216 func coins(address: String) async throws -> [UTXOIndexerCoin]217 /// One page of the history of an address, newest first; pass the cursor of the previous page for the next one.218 func history(address: String, cursor: UTXOHistoryCursor?) async throws -> UTXOHistoryPage219 /// Raw transaction in hexadecimal. The caller recomputes the txid: the answer is not trusted.220 func rawTransaction(txid: String) async throws -> String221 /// Fee estimates in base units per virtual byte, keyed by confirmation target in blocks. Empty when the node has222 /// no estimate. The caller converts with `FeeRate.fromEstimate` and clamps to the network's policy.223 func feeEstimates() async throws -> [Int: Double]224 /// Sends a raw transaction to every configured endpoint. Success when one accepts it or already knows it; returns225 /// the txid reported (empty when it was only "already known"); callers compare it with the txid they computed.226 func broadcast(rawHex: String) async throws -> String227}228229extension UTXOIndexer {230 public func tipHeight() async throws -> Int { try await tip().height }231}232233// MARK: - Validation helpers234235enum UTXOWire {236 /// Largest number of coins, transactions per page, and inputs or outputs per transaction accepted from an indexer.237 static let maximumCoins = 10_000238 static let maximumTransactionsPerPage = 100239 static let maximumEntriesPerTransaction = 20_000240 /// Largest script accepted, in hexadecimal characters (consensus limit 10 000 bytes).241 static let maximumScriptHex = 20_000242 /// Largest raw transaction accepted, in hexadecimal characters (4 MB serialized).243 static let maximumTransactionHex = 8_000_000244 /// Tip heights are accepted in 0 ..< this value: the bound the wallet service applies to a tip (Dogecoin, one block245 /// a minute, reaches it in about 180 years). A client announcing more is no answer in the survey, so that it is246 /// left out instead of being chosen as the most advanced and then refused by the service (QYV-APP-061).247 static let maximumTipHeight = 100_000_000248249 static func isTxid(_ s: String) -> Bool {250 s.utf8.count == 64 && s.utf8.allSatisfy { ($0 >= 0x30 && $0 <= 0x39) || ($0 >= 0x61 && $0 <= 0x66) }251 }252253 static func isHex(_ s: String, maximumCharacters: Int) -> Bool {254 s.utf8.count <= maximumCharacters && s.utf8.count % 2 == 0255 && s.utf8.allSatisfy { ($0 >= 0x30 && $0 <= 0x39) || ($0 >= 0x61 && $0 <= 0x66) || ($0 >= 0x41 && $0 <= 0x46) }256 }257258 private static func isAlphanumeric(_ c: UInt8) -> Bool { (c >= 0x30 && c <= 0x39) || (c >= 0x41 && c <= 0x5a) || (c >= 0x61 && c <= 0x7a) }259260 /// An address as it may appear in a URL path: letters and digits, optionally preceded by a CashAddr prefix261 /// (lower-case letters and one colon). Nothing else can reach the path of a request.262 static func isAddress(_ s: String) -> Bool {263 let bytes = [UInt8](s.utf8)264 guard !bytes.isEmpty, bytes.count <= 130 else { return false }265 let parts = bytes.split(separator: 0x3a, omittingEmptySubsequences: false)266 switch parts.count {267 case 1: return bytes.allSatisfy(isAlphanumeric)268 case 2: return !parts[0].isEmpty && parts[0].allSatisfy({ $0 >= 0x61 && $0 <= 0x7a }) && !parts[1].isEmpty && parts[1].allSatisfy(isAlphanumeric)269 default: return false270 }271 }272273 /// The address without its CashAddr prefix.274 static func bare(_ address: String) -> String {275 guard let colon = address.firstIndex(of: ":") else { return address }276 return String(address[address.index(after: colon)...])277 }278279 /// A height an indexer reports: nil for "unconfirmed" markers (absent, zero or negative) and for absurd values.280 static func height(_ value: Int?) -> Int? {281 guard let value, value > 0, value < 1_000_000_000 else { return nil }282 return value283 }284285 /// An address string taken from an answer, kept only when it is short printable ASCII.286 static func address(_ value: String?) -> String? {287 guard let value, !value.isEmpty, value.utf8.count <= 130, value.utf8.allSatisfy({ $0 > 0x20 && $0 < 0x7f }) else { return nil }288 return value289 }290291 /// An ISO 8601 UTC time as indexers write it ("2026-12-05T05:11:35Z", with any number of fractional digits).292 static func date(_ value: String?) -> Date? {293 guard var text = value, text.utf8.count >= 20, text.utf8.count <= 40, text.hasSuffix("Z"), text.utf8.allSatisfy({ $0 > 0x20 && $0 < 0x7f }) else { return nil }294 if let dot = text.firstIndex(of: ".") { text = String(text[..<dot]) + "Z" }295 return try? Date(text, strategy: .iso8601)296 }297298 static func script(_ value: String?) -> String? {299 guard let value, isHex(value, maximumCharacters: maximumScriptHex) else { return nil }300 return value.lowercased()301 }302303 /// `base` + path components + query, without letting any component introduce a separator.304 static func url(_ base: URL, _ components: [String], query: [(String, String)] = []) throws -> URL {305 var url = base306 for c in components {307 guard !c.isEmpty, !c.contains("/"), !c.contains("?"), !c.contains("#"), c != "..", c != "." else { throw NetworkError.invalidURL }308 url.appendPathComponent(c)309 }310 guard !query.isEmpty else { return url }311 guard var parts = URLComponents(url: url, resolvingAgainstBaseURL: false) else { throw NetworkError.invalidURL }312 parts.queryItems = query.map { URLQueryItem(name: $0.0, value: $0.1) }313 guard let result = parts.url else { throw NetworkError.invalidURL }314 return result315 }316317 /// Runs `check` against every base and applies the rule of `verifyChain`: a base on another chain fails the whole318 /// verification; bases that do not answer are tolerated as long as one confirmed the chain.319 static func verifyChain(bases: [URL], network: BitcoinNetwork, hashAt: @Sendable (URL, Int) async throws -> String) async throws {320 guard !bases.isEmpty else { throw NetworkError.allEndpointsFailed(["no endpoint configured"]) }321 let identity = network.identityBlock322 var answered = 0323 var failures = [String]()324 for base in bases {325 do {326 let hash = try await hashAt(base, identity.height)327 guard hash == identity.hash else {328 throw NetworkError.disagreement("\(base.host ?? "?") serves another chain than \(network.displayName)")329 }330 answered += 1331 } catch let e as NetworkError {332 if case .disagreement = e { throw e }333 failures.append("\(base.host ?? "?"): \(e.summary)")334 } catch {335 failures.append("\(base.host ?? "?"): \(NetworkError.transportSummary(error))")336 }337 }338 guard answered > 0 else { throw NetworkError.allEndpointsFailed(failures) }339 }340341 /// Whether the body of a refused broadcast says that the node already has the transaction.342 ///343 /// Only the messages by which a node says it holds this very transaction: `txn-already-in-mempool`,344 /// `txn-already-known`, "Transaction already in block chain", "transaction already exists" and the like. A345 /// conflict with another transaction of the mempool (`txn-mempool-conflict`), a missing input, or any text that346 /// merely contains "known" ("unknown error") is a refusal: counting it as a success would tell the user that a347 /// payment was sent when no node took it (QYV-SVC-061).348 static func saysAlreadyKnown(_ body: String) -> Bool {349 body.range(of: "txn-already-(known|in-mempool)|already (known|exists?|have|in (the )?(block ?chain|mempool|utxo set))|outputs already in utxo set",350 options: [.regularExpression, .caseInsensitive]) != nil351 }352}353354extension HTTPTransport {355 /// GET + JSON decoding; a body that is not the expected JSON is `invalidResponse` (the decoding error is not356 /// interpolated: it would print Swift internals into a message shown to the user).357 func json<T: Decodable & Sendable>(_ url: URL, as type: T.Type, what: String) async throws -> T {358 let data = try await get(url)359 do { return try JSONDecoder().decode(T.self, from: data) } catch {360 throw NetworkError.invalidResponse("\(what) is not the expected JSON")361 }362 }363}364365// MARK: - Esplora366367extension EsploraClient: UTXOIndexer {368 public var indexerProtocol: UTXOIndexerProtocol { .esplora }369 public var hosts: [String] { bases.compactMap(\.host) }370 public var servesRawTransactions: Bool { true }371372 public func tip() async throws -> UTXOChainTip {373 // the height is text written by the endpoint: bounded like the other protocols' (QYV-SVC-060)374 let height = try await tipHeight()375 guard height >= 0, height < UTXOWire.maximumTipHeight else { throw NetworkError.invalidResponse("tip height") }376 return UTXOChainTip(height: height, time: nil)377 }378379 public func stats(address: String) async throws -> UTXOAddressStats {380 let s = try await addressStats(address)381 let count = s.chain_stats.tx_count.addingReportingOverflow(s.mempool_stats.tx_count)382 let balance = s.chain_stats.funded_txo_sum >= s.chain_stats.spent_txo_sum ? s.chain_stats.funded_txo_sum - s.chain_stats.spent_txo_sum : nil383 return UTXOAddressStats(address: address, isUsed: s.isUsed, hasSpent: s.hasSpent,384 transactionCount: count.overflow || count.partialValue < 0 ? nil : count.partialValue, confirmedBalance: balance)385 }386387 public func coins(address: String) async throws -> [UTXOIndexerCoin] {388 let list = try await utxos(address)389 guard list.count <= UTXOWire.maximumCoins else { throw NetworkError.invalidResponse("too many coins") }390 return try list.map { u in391 guard UTXOWire.isTxid(u.txid), let vout = UInt32(exactly: u.vout) else { throw NetworkError.invalidResponse("coin") }392 return UTXOIndexerCoin(txid: u.txid, vout: vout, value: u.value, height: u.status.confirmed ? UTXOWire.height(u.status.block_height) : nil)393 }394 }395396 public func history(address: String, cursor: UTXOHistoryCursor?) async throws -> UTXOHistoryPage {397 let list = try await transactions(address, after: cursor?.token)398 guard list.count <= UTXOWire.maximumTransactionsPerPage else { throw NetworkError.invalidResponse("too many transactions") }399 let mapped = try list.map { try Self.convert($0) }400 // Esplora pages hold 25 confirmed transactions: a full page may have a successor, addressed by its last txid401 let confirmed = list.filter { $0.status.confirmed }402 let next = confirmed.count >= 25 ? confirmed.last.map { UTXOHistoryCursor(token: $0.txid) } : nil403 return UTXOHistoryPage(transactions: mapped, next: next)404 }405406 static func convert(_ t: EsploraTransaction) throws -> UTXOIndexerTransaction {407 guard UTXOWire.isTxid(t.txid), t.vin.count <= UTXOWire.maximumEntriesPerTransaction, t.vout.count <= UTXOWire.maximumEntriesPerTransaction else {408 throw NetworkError.invalidResponse("transaction")409 }410 func coin(_ p: EsploraTransaction.Prevout) -> UTXOIndexerTransaction.Coin {411 UTXOIndexerTransaction.Coin(address: UTXOWire.address(p.scriptpubkey_address), scriptPubKey: UTXOWire.script(p.scriptpubkey), value: p.value)412 }413 let inputs = t.vin.map { i -> UTXOIndexerTransaction.Input in414 // a coinbase input has no previous output; its outpoint is the null one415 let known = i.prevout != nil && UTXOWire.isTxid(i.txid)416 return UTXOIndexerTransaction.Input(txid: known ? i.txid : nil, vout: known ? UInt32(exactly: i.vout) : nil,417 previous: i.prevout.map(coin), sequence: i.sequence)418 }419 let vsize = t.weight.flatMap { $0 > 0 && $0 <= 4_000_000 ? ($0 + 3) / 4 : nil }420 return UTXOIndexerTransaction(txid: t.txid, inputs: inputs, outputs: t.vout.map(coin), fee: t.fee, virtualSize: vsize,421 height: t.status.confirmed ? UTXOWire.height(t.status.block_height) : nil,422 time: t.status.confirmed ? t.status.block_time.flatMap { $0 > 0 ? $0 : nil } : nil)423 }424425 public func rawTransaction(txid: String) async throws -> String {426 let hex = try await transactionHex(txid)427 guard UTXOWire.isHex(hex, maximumCharacters: UTXOWire.maximumTransactionHex), !hex.isEmpty else { throw NetworkError.invalidResponse("raw transaction") }428 return hex.lowercased()429 }430}431432// MARK: - Clients of a network433434/// The indexer clients of a network, one per protocol that has endpoints in the configuration.435public enum UTXOIndexers {436 /// Clients in the order Esplora, Blockbook, Bitcore; only those with at least one acceptable endpoint.437 /// An empty result means the network cannot be synchronised with this configuration (with the built-in one:438 /// Dogecoin Testnet, see `BitcoinNetwork.indexerAvailable`).439 public static func clients(for network: BitcoinNetwork, configuration: EndpointConfiguration = .default,440 transport: HTTPTransport) -> [any UTXOIndexer] {441 let all: [any UTXOIndexer] = [442 EsploraClient(network: network, configuration: configuration, transport: transport),443 BlockbookClient(network: network, configuration: configuration, transport: transport),444 BitcoreClient(network: network, configuration: configuration, transport: transport),445 ]446 return all.filter(\.isConfigured)447 }448449 /// The state of one client at the time of a survey.450 public struct Survey: Sendable {451 public let client: any UTXOIndexer452 /// nil when the client did not answer.453 public let tip: UTXOChainTip?454 /// Blocks behind the best client of the survey.455 public let lag: Int?456 /// True when the client trails the best one by more than the confirmation depth of the network457 /// (`minimumConfirmationsHint`): what it shows is out of date and it must not feed a transaction.458 public let isStale: Bool459 }460461 /// Asks every client for its tip and ranks them, best first; clients that did not answer come last.462 /// Public indexers do stop synchronising (on 2026-12-05 one Litecoin Testnet endpoint was three days behind the463 /// other): reading from the first configured one without this comparison can show an outdated wallet.464 public static func survey(_ clients: [any UTXOIndexer]) async -> [Survey] {465 var tips = [(any UTXOIndexer, UTXOChainTip?)]()466 for client in clients {467 // a tip outside the accepted range is no answer: it neither becomes the reference nor enters the468 // subtraction below, which would overflow on a hostile height (QYV-SVC-060)469 let tip = try? await client.tip()470 tips.append((client, tip.flatMap { (0..<UTXOWire.maximumTipHeight).contains($0.height) ? $0 : nil }))471 }472 let best = tips.compactMap { $0.1?.height }.max()473 return tips.map { client, tip -> Survey in474 let lag = tip.flatMap { t in best.map { $0 - t.height } }475 return Survey(client: client, tip: tip, lag: lag, isStale: (lag ?? 0) > client.network.minimumConfirmationsHint)476 }.sorted { ($0.tip?.height ?? -1) > ($1.tip?.height ?? -1) }477 }478479 /// What the clients of a survey that are current say about one confirmed block (QYV-APP-061).480 public struct Corroboration: Sendable, Equatable {481 /// Clients, other than the best one, that gave the same hash as it for `height`. 0: one source alone.482 public let agreeing: Int483 /// Height of the block compared: the lowest tip among the current clients, less the confirmation depth.484 public let height: Int485 }486487 /// Asks every current client of a survey (not stale, a tip in range) for the hash of one block under the488 /// confirmation depth and compares it with the best client's. Clients that follow the same chain agree; a489 /// different hash throws `NetworkError.disagreement` naming the two sources — it is a disagreement about confirmed490 /// blocks, and nothing should be read from either. A client that does not answer the question is not counted.491 /// With a single current client there is nothing to compare: `agreeing` is 0.492 ///493 /// This confirms the chain the best client follows, not each balance or payment it reports: those remain the494 /// word of the client they are read from.495 public static func corroborate(_ survey: [Survey]) async throws -> Corroboration {496 let current = survey.filter { $0.tip != nil && !$0.isStale }497 guard let best = current.first, let bestTip = best.tip else { return Corroboration(agreeing: 0, height: 0) }498 let lowest = current.compactMap { $0.tip?.height }.min() ?? bestTip.height499 let height = max(0, lowest - best.client.network.minimumConfirmationsHint)500 guard current.count >= 2, let reference = try? await best.client.blockHash(height: height) else { return Corroboration(agreeing: 0, height: height) }501 var agreeing = 0502 for other in current.dropFirst() {503 guard let hash = try? await other.client.blockHash(height: height) else { continue }504 guard hash.lowercased() == reference.lowercased() else {505 throw NetworkError.disagreement("the indexers of \(best.client.network.displayName) disagree on block \(height): \(best.client.hosts.joined(separator: ", ")) and \(other.client.hosts.joined(separator: ", ")) do not follow the same chain")506 }507 agreeing += 1508 }509 return Corroboration(agreeing: agreeing, height: height)510 }511}512