2019-10-18 11:45:19 -07:00
|
|
|
//
|
|
|
|
// Stubs.swift
|
|
|
|
// ZcashLightClientKitTests
|
|
|
|
//
|
|
|
|
// Created by Francisco Gindre on 18/09/2019.
|
|
|
|
// Copyright © 2019 Electric Coin Company. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
2020-04-09 15:25:43 -07:00
|
|
|
import GRPC
|
2019-12-16 14:25:45 -08:00
|
|
|
import SwiftProtobuf
|
2019-11-14 06:38:54 -08:00
|
|
|
@testable import ZcashLightClientKit
|
2019-10-18 11:45:19 -07:00
|
|
|
|
2021-09-23 06:26:41 -07:00
|
|
|
// swiftlint:disable function_parameter_count identifier_name
|
2019-12-16 14:25:45 -08:00
|
|
|
class AwfulLightWalletService: MockLightWalletService {
|
|
|
|
override func latestBlockHeight() throws -> BlockHeight {
|
2020-08-10 15:19:59 -07:00
|
|
|
throw LightWalletServiceError.criticalError
|
2019-10-18 11:45:19 -07:00
|
|
|
}
|
|
|
|
|
2019-12-16 14:25:45 -08:00
|
|
|
override func blockRange(_ range: CompactBlockRange) throws -> [ZcashCompactBlock] {
|
2019-10-18 11:45:19 -07:00
|
|
|
throw LightWalletServiceError.invalidBlock
|
|
|
|
}
|
|
|
|
|
2019-12-16 14:25:45 -08:00
|
|
|
override func latestBlockHeight(result: @escaping (Result<BlockHeight, LightWalletServiceError>) -> Void) {
|
2019-10-18 11:45:19 -07:00
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
2020-08-10 15:19:59 -07:00
|
|
|
result(.failure(LightWalletServiceError.invalidBlock))
|
2019-10-18 11:45:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-26 08:54:48 -08:00
|
|
|
override func blockRange(_ range: CompactBlockRange, result: @escaping (Result<[ZcashCompactBlock], LightWalletServiceError>) -> Void) {
|
2019-10-18 11:45:19 -07:00
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
2020-08-10 15:19:59 -07:00
|
|
|
result(.failure(LightWalletServiceError.invalidBlock))
|
2019-10-18 11:45:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-23 06:26:41 -07:00
|
|
|
override func submit(spendTransaction: Data, result: @escaping(Result<LightWalletServiceResponse, LightWalletServiceError>) -> Void) {
|
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
|
|
|
result(.failure(LightWalletServiceError.invalidBlock))
|
|
|
|
}
|
2019-12-03 07:19:44 -08:00
|
|
|
}
|
|
|
|
|
2021-09-23 06:26:41 -07:00
|
|
|
/**
|
|
|
|
Submits a raw transaction over lightwalletd. Blocking
|
|
|
|
*/
|
2019-12-16 14:25:45 -08:00
|
|
|
override func submit(spendTransaction: Data) throws -> LightWalletServiceResponse {
|
2020-08-10 15:19:59 -07:00
|
|
|
throw LightWalletServiceError.invalidBlock
|
2019-12-03 07:19:44 -08:00
|
|
|
}
|
2019-10-18 11:45:19 -07:00
|
|
|
}
|
2019-11-14 06:38:54 -08:00
|
|
|
|
2019-12-16 14:25:45 -08:00
|
|
|
class SlightlyBadLightWalletService: MockLightWalletService {
|
2021-09-23 06:26:41 -07:00
|
|
|
override func submit(spendTransaction: Data, result: @escaping(Result<LightWalletServiceResponse, LightWalletServiceError>) -> Void) {
|
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
2019-12-16 14:25:45 -08:00
|
|
|
result(.success(LightWalletServiceMockResponse.error))
|
2021-09-23 06:26:41 -07:00
|
|
|
}
|
2019-12-16 14:25:45 -08:00
|
|
|
}
|
2021-09-23 06:26:41 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
Submits a raw transaction over lightwalletd. Blocking
|
|
|
|
*/
|
2019-12-16 14:25:45 -08:00
|
|
|
override func submit(spendTransaction: Data) throws -> LightWalletServiceResponse {
|
|
|
|
LightWalletServiceMockResponse.error
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension LightWalletServiceMockResponse {
|
|
|
|
static var error: LightWalletServiceMockResponse {
|
2021-09-23 06:26:41 -07:00
|
|
|
LightWalletServiceMockResponse(
|
|
|
|
errorCode: -100,
|
|
|
|
errorMessage: "Ohhh this is bad, really bad, you lost all your internet money",
|
|
|
|
unknownFields: UnknownStorage()
|
|
|
|
)
|
2019-12-16 14:25:45 -08:00
|
|
|
}
|
2021-09-23 06:26:41 -07:00
|
|
|
|
2019-12-16 14:25:45 -08:00
|
|
|
static var success: LightWalletServiceMockResponse {
|
|
|
|
LightWalletServiceMockResponse(errorCode: 0, errorMessage: "", unknownFields: UnknownStorage())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-14 06:38:54 -08:00
|
|
|
class MockRustBackend: ZcashRustBackendWelding {
|
2022-08-24 08:38:42 -07:00
|
|
|
static func initDataDb(dbData: URL, seed: [UInt8]?, networkType: ZcashLightClientKit.NetworkType) throws -> ZcashLightClientKit.DbInitResult {
|
|
|
|
.seedRequired
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func clearUtxos(dbData: URL, address: String, sinceHeight: BlockHeight, networkType: NetworkType) throws -> Int32 {
|
|
|
|
-1
|
|
|
|
}
|
2021-05-28 15:45:18 -07:00
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func getNearestRewindHeight(dbData: URL, height: Int32, networkType: NetworkType) -> Int32 {
|
2021-04-19 10:16:24 -07:00
|
|
|
-1
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func network(dbData: URL, address: String, sinceHeight: BlockHeight, networkType: NetworkType) throws -> Int32 {
|
2021-04-08 10:18:16 -07:00
|
|
|
-1
|
|
|
|
}
|
|
|
|
|
2022-06-28 15:02:02 -07:00
|
|
|
static func initAccountsTable(dbData: URL, ufvks: [UnifiedFullViewingKey], networkType: NetworkType) throws -> Bool {
|
2021-04-02 15:18:16 -07:00
|
|
|
false
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func getVerifiedTransparentBalance(dbData: URL, address: String, networkType: NetworkType) throws -> Int64 {
|
2021-04-02 15:18:16 -07:00
|
|
|
-1
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func getTransparentBalance(dbData: URL, address: String, networkType: NetworkType) throws -> Int64 {
|
2021-04-02 15:18:16 -07:00
|
|
|
-1
|
|
|
|
}
|
|
|
|
|
2021-09-23 06:26:41 -07:00
|
|
|
static func putUnspentTransparentOutput(
|
|
|
|
dbData: URL,
|
|
|
|
txid: [UInt8],
|
|
|
|
index: Int,
|
|
|
|
script: [UInt8],
|
|
|
|
value: Int64,
|
|
|
|
height: BlockHeight,
|
|
|
|
networkType: NetworkType
|
|
|
|
) throws -> Bool {
|
2021-04-02 15:18:16 -07:00
|
|
|
false
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func downloadedUtxoBalance(dbData: URL, address: String, networkType: NetworkType) throws -> WalletBalance {
|
2021-04-02 15:18:16 -07:00
|
|
|
throw RustWeldingError.genericError(message: "unimplemented")
|
|
|
|
}
|
|
|
|
|
2021-09-23 06:26:41 -07:00
|
|
|
static func createToAddress(
|
|
|
|
dbData: URL,
|
|
|
|
account: Int32,
|
|
|
|
extsk: String,
|
|
|
|
to address: String,
|
|
|
|
value: Int64,
|
|
|
|
memo: String?,
|
|
|
|
spendParamsPath: String,
|
|
|
|
outputParamsPath: String,
|
|
|
|
networkType: NetworkType
|
|
|
|
) -> Int64 {
|
2021-04-02 15:18:16 -07:00
|
|
|
-1
|
|
|
|
}
|
|
|
|
|
2021-09-23 06:26:41 -07:00
|
|
|
static func shieldFunds(
|
|
|
|
dbCache: URL,
|
|
|
|
dbData: URL,
|
|
|
|
account: Int32,
|
2022-06-28 14:40:52 -07:00
|
|
|
xprv: String,
|
2021-09-23 06:26:41 -07:00
|
|
|
extsk: String,
|
|
|
|
memo: String?,
|
|
|
|
spendParamsPath: String,
|
|
|
|
outputParamsPath: String,
|
|
|
|
networkType: NetworkType
|
|
|
|
) -> Int64 {
|
2021-04-02 15:18:16 -07:00
|
|
|
-1
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func deriveTransparentAddressFromSeed(seed: [UInt8], account: Int, index: Int, networkType: NetworkType) throws -> String? {
|
2021-04-02 15:18:16 -07:00
|
|
|
throw KeyDerivationErrors.unableToDerive
|
|
|
|
}
|
|
|
|
|
2022-06-28 14:40:52 -07:00
|
|
|
static func deriveTransparentAccountPrivateKeyFromSeed(seed: [UInt8], account: Int, networkType: NetworkType) throws -> String? {
|
2021-04-02 15:18:16 -07:00
|
|
|
throw KeyDerivationErrors.unableToDerive
|
|
|
|
}
|
|
|
|
|
2022-06-28 14:40:52 -07:00
|
|
|
static func deriveTransparentAddressFromAccountPrivateKey(_ xprv: String, index: Int, networkType: NetworkType) throws -> String? {
|
2021-04-02 15:18:16 -07:00
|
|
|
throw KeyDerivationErrors.unableToDerive
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func derivedTransparentAddressFromPublicKey(_ pubkey: String, networkType: NetworkType) throws -> String {
|
2021-04-02 15:18:16 -07:00
|
|
|
throw KeyDerivationErrors.unableToDerive
|
|
|
|
}
|
|
|
|
|
2022-06-28 14:40:52 -07:00
|
|
|
static func deriveUnifiedFullViewingKeyFromSeed(_ seed: [UInt8], numberOfAccounts: Int32, networkType: NetworkType) throws -> [UnifiedFullViewingKey] {
|
2021-04-02 15:18:16 -07:00
|
|
|
throw KeyDerivationErrors.unableToDerive
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func isValidExtendedFullViewingKey(_ key: String, networkType: NetworkType) throws -> Bool {
|
2021-02-22 11:43:28 -08:00
|
|
|
false
|
|
|
|
}
|
|
|
|
|
2022-06-28 14:40:52 -07:00
|
|
|
static func isValidUnifiedFullViewingKey(_ ufvk: String, networkType: NetworkType) throws -> Bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func deriveTransparentPrivateKeyFromSeed(seed: [UInt8], networkType: NetworkType) throws -> String? {
|
2020-12-11 13:07:51 -08:00
|
|
|
nil
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func initAccountsTable(dbData: URL, exfvks: [String], networkType: NetworkType) throws -> Bool {
|
2020-10-14 15:50:26 -07:00
|
|
|
false
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func deriveTransparentAddressFromSeed(seed: [UInt8], networkType: NetworkType) throws -> String? {
|
2020-10-09 13:58:36 -07:00
|
|
|
nil
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func deriveExtendedFullViewingKeys(seed: [UInt8], accounts: Int32, networkType: NetworkType) throws -> [String]? {
|
2020-10-09 13:58:36 -07:00
|
|
|
nil
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func deriveExtendedSpendingKeys(seed: [UInt8], accounts: Int32, networkType: NetworkType) throws -> [String]? {
|
2020-10-09 13:58:36 -07:00
|
|
|
nil
|
|
|
|
}
|
|
|
|
|
2022-06-28 14:40:52 -07:00
|
|
|
static func deriveUnifiedAddressFromSeed(seed: [UInt8], accountIndex: Int32, networkType: NetworkType) throws -> String? {
|
2020-10-09 13:58:36 -07:00
|
|
|
nil
|
|
|
|
}
|
|
|
|
|
2022-06-28 14:40:52 -07:00
|
|
|
static func deriveUnifiedAddressFromViewingKey(_ ufvk: String, networkType: NetworkType) throws -> String? {
|
2020-10-09 13:58:36 -07:00
|
|
|
nil
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func consensusBranchIdFor(height: Int32, networkType: NetworkType) throws -> Int32 {
|
2021-09-23 06:26:41 -07:00
|
|
|
guard let consensus = consensusBranchID else {
|
2021-07-28 09:59:10 -07:00
|
|
|
return try rustBackend.consensusBranchIdFor(height: height, networkType: networkType)
|
2021-06-17 16:58:30 -07:00
|
|
|
}
|
2021-09-23 06:26:41 -07:00
|
|
|
return consensus
|
2020-06-09 17:23:46 -07:00
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static var networkType = NetworkType.testnet
|
2019-11-14 06:38:54 -08:00
|
|
|
static var mockDataDb = false
|
|
|
|
static var mockAcounts = false
|
|
|
|
static var mockError: RustWeldingError?
|
|
|
|
static var mockLastError: String?
|
|
|
|
static var mockAccounts: [String]?
|
|
|
|
static var mockAddresses: [String]?
|
|
|
|
static var mockBalance: Int64?
|
|
|
|
static var mockVerifiedBalance: Int64?
|
|
|
|
static var mockMemo: String?
|
|
|
|
static var mockSentMemo: String?
|
|
|
|
static var mockValidateCombinedChainSuccessRate: Float?
|
|
|
|
static var mockValidateCombinedChainFailAfterAttempts: Int?
|
|
|
|
static var mockValidateCombinedChainKeepFailing = false
|
|
|
|
static var mockValidateCombinedChainFailureHeight: BlockHeight = 0
|
|
|
|
static var mockScanblocksSuccessRate: Float?
|
2019-12-03 09:11:24 -08:00
|
|
|
static var mockCreateToAddress: Int64?
|
2019-11-14 06:38:54 -08:00
|
|
|
static var rustBackend = ZcashRustBackend.self
|
2021-06-17 16:58:30 -07:00
|
|
|
static var consensusBranchID: Int32?
|
2019-11-14 06:38:54 -08:00
|
|
|
|
|
|
|
static func lastError() -> RustWeldingError? {
|
|
|
|
mockError ?? rustBackend.lastError()
|
|
|
|
}
|
|
|
|
|
|
|
|
static func getLastError() -> String? {
|
|
|
|
mockLastError ?? rustBackend.getLastError()
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func isValidShieldedAddress(_ address: String, networkType: NetworkType) throws -> Bool {
|
2020-02-26 08:54:48 -08:00
|
|
|
true
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func isValidTransparentAddress(_ address: String, networkType: NetworkType) throws -> Bool {
|
2020-02-26 08:54:48 -08:00
|
|
|
true
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func initDataDb(dbData: URL, networkType: NetworkType) throws {
|
2019-11-14 06:38:54 -08:00
|
|
|
if !mockDataDb {
|
2022-08-24 08:38:42 -07:00
|
|
|
_ = try rustBackend.initDataDb(dbData: dbData, seed: nil, networkType: networkType)
|
2019-11-14 06:38:54 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func initAccountsTable(dbData: URL, seed: [UInt8], accounts: Int32, networkType: NetworkType) -> [String]? {
|
|
|
|
mockAccounts ?? rustBackend.initAccountsTable(dbData: dbData, seed: seed, accounts: accounts, networkType: networkType)
|
2019-11-14 06:38:54 -08:00
|
|
|
}
|
|
|
|
|
2021-09-23 06:26:41 -07:00
|
|
|
static func initBlocksTable(
|
|
|
|
dbData: URL,
|
|
|
|
height: Int32,
|
|
|
|
hash: String,
|
|
|
|
time: UInt32,
|
|
|
|
saplingTree: String,
|
|
|
|
networkType: NetworkType
|
|
|
|
) throws {
|
2019-11-14 06:38:54 -08:00
|
|
|
if !mockDataDb {
|
2021-09-23 06:26:41 -07:00
|
|
|
try rustBackend.initBlocksTable(
|
|
|
|
dbData: dbData,
|
|
|
|
height: height,
|
|
|
|
hash: hash,
|
|
|
|
time: time,
|
|
|
|
saplingTree: saplingTree,
|
|
|
|
networkType: networkType
|
|
|
|
)
|
2019-11-14 06:38:54 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func getAddress(dbData: URL, account: Int32, networkType: NetworkType) -> String? {
|
|
|
|
mockAddresses?[Int(account)] ?? rustBackend.getAddress(dbData: dbData, account: account, networkType: networkType)
|
2019-11-14 06:38:54 -08:00
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func getBalance(dbData: URL, account: Int32, networkType: NetworkType) -> Int64 {
|
|
|
|
mockBalance ?? rustBackend.getBalance(dbData: dbData, account: account, networkType: networkType)
|
2019-11-14 06:38:54 -08:00
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func getVerifiedBalance(dbData: URL, account: Int32, networkType: NetworkType) -> Int64 {
|
|
|
|
mockVerifiedBalance ?? rustBackend.getVerifiedBalance(dbData: dbData, account: account, networkType: networkType)
|
2019-11-14 06:38:54 -08:00
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func getReceivedMemoAsUTF8(dbData: URL, idNote: Int64, networkType: NetworkType) -> String? {
|
|
|
|
mockMemo ?? rustBackend.getReceivedMemoAsUTF8(dbData: dbData, idNote: idNote, networkType: networkType)
|
2019-11-14 06:38:54 -08:00
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func getSentMemoAsUTF8(dbData: URL, idNote: Int64, networkType: NetworkType) -> String? {
|
|
|
|
mockSentMemo ?? getSentMemoAsUTF8(dbData: dbData, idNote: idNote, networkType: networkType)
|
2019-11-14 06:38:54 -08:00
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func validateCombinedChain(dbCache: URL, dbData: URL, networkType: NetworkType) -> Int32 {
|
2019-11-14 06:38:54 -08:00
|
|
|
if let rate = self.mockValidateCombinedChainSuccessRate {
|
|
|
|
if shouldSucceed(successRate: rate) {
|
2021-07-28 09:59:10 -07:00
|
|
|
return validationResult(dbCache: dbCache, dbData: dbData, networkType: networkType)
|
2019-11-14 06:38:54 -08:00
|
|
|
} else {
|
|
|
|
return Int32(mockValidateCombinedChainFailureHeight)
|
|
|
|
}
|
|
|
|
} else if let attempts = self.mockValidateCombinedChainFailAfterAttempts {
|
|
|
|
self.mockValidateCombinedChainFailAfterAttempts = attempts - 1
|
|
|
|
if attempts > 0 {
|
2021-07-28 09:59:10 -07:00
|
|
|
return validationResult(dbCache: dbCache, dbData: dbData, networkType: networkType)
|
2019-11-14 06:38:54 -08:00
|
|
|
} else {
|
|
|
|
if attempts == 0 {
|
|
|
|
return Int32(mockValidateCombinedChainFailureHeight)
|
|
|
|
} else if attempts < 0 && mockValidateCombinedChainKeepFailing {
|
|
|
|
return Int32(mockValidateCombinedChainFailureHeight)
|
|
|
|
} else {
|
2021-07-28 09:59:10 -07:00
|
|
|
return validationResult(dbCache: dbCache, dbData: dbData, networkType: networkType)
|
2019-11-14 06:38:54 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-28 09:59:10 -07:00
|
|
|
return rustBackend.validateCombinedChain(dbCache: dbCache, dbData: dbData, networkType: networkType)
|
2019-11-14 06:38:54 -08:00
|
|
|
}
|
|
|
|
|
2021-09-23 06:26:41 -07:00
|
|
|
private static func validationResult(dbCache: URL, dbData: URL, networkType: NetworkType) -> Int32 {
|
2019-11-14 06:38:54 -08:00
|
|
|
if mockDataDb {
|
|
|
|
return -1
|
|
|
|
} else {
|
2021-07-28 09:59:10 -07:00
|
|
|
return rustBackend.validateCombinedChain(dbCache: dbCache, dbData: dbData, networkType: networkType)
|
2019-11-14 06:38:54 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func rewindToHeight(dbData: URL, height: Int32, networkType: NetworkType) -> Bool {
|
|
|
|
mockDataDb ? true : rustBackend.rewindToHeight(dbData: dbData, height: height, networkType: networkType)
|
2019-11-14 06:38:54 -08:00
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func scanBlocks(dbCache: URL, dbData: URL, limit: UInt32, networkType: NetworkType) -> Bool {
|
2019-11-14 06:38:54 -08:00
|
|
|
if let rate = mockScanblocksSuccessRate {
|
|
|
|
if shouldSucceed(successRate: rate) {
|
2021-07-28 09:59:10 -07:00
|
|
|
return mockDataDb ? true : rustBackend.scanBlocks(dbCache: dbCache, dbData: dbData, networkType: networkType)
|
2019-11-14 06:38:54 -08:00
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
2021-07-28 09:59:10 -07:00
|
|
|
return rustBackend.scanBlocks(dbCache: dbCache, dbData: dbData, networkType: Self.networkType)
|
2019-11-14 06:38:54 -08:00
|
|
|
}
|
|
|
|
|
2021-09-23 06:26:41 -07:00
|
|
|
static func createToAddress(
|
|
|
|
dbData: URL,
|
|
|
|
account: Int32,
|
|
|
|
extsk: String,
|
|
|
|
consensusBranchId: Int32,
|
|
|
|
to address: String,
|
|
|
|
value: Int64,
|
|
|
|
memo: String?,
|
|
|
|
spendParamsPath: String,
|
|
|
|
outputParamsPath: String,
|
|
|
|
networkType: NetworkType
|
|
|
|
) -> Int64 {
|
2021-04-02 15:18:16 -07:00
|
|
|
-1
|
2019-11-14 06:38:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static func shouldSucceed(successRate: Float) -> Bool {
|
|
|
|
let random = Float.random(in: 0.0...1.0)
|
|
|
|
return random <= successRate
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func deriveExtendedFullViewingKey(_ spendingKey: String, networkType: NetworkType) throws -> String? {
|
2020-02-26 08:54:48 -08:00
|
|
|
nil
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func deriveExtendedFullViewingKeys(seed: String, accounts: Int32, networkType: NetworkType) throws -> [String]? {
|
2020-02-26 08:54:48 -08:00
|
|
|
nil
|
|
|
|
}
|
|
|
|
|
2021-07-28 09:59:10 -07:00
|
|
|
static func deriveExtendedSpendingKeys(seed: String, accounts: Int32, networkType: NetworkType) throws -> [String]? {
|
2020-02-26 08:54:48 -08:00
|
|
|
nil
|
|
|
|
}
|
|
|
|
|
2021-09-15 05:21:29 -07:00
|
|
|
static func decryptAndStoreTransaction(dbData: URL, txBytes: [UInt8], minedHeight: Int32, networkType: NetworkType) -> Bool {
|
2020-04-06 08:54:31 -07:00
|
|
|
false
|
|
|
|
}
|
2019-11-14 06:38:54 -08:00
|
|
|
}
|