Update to latest librustzcash
This commit is contained in:
parent
d36c42da8f
commit
91ea6f5476
|
@ -5,8 +5,8 @@
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/grpc/grpc-swift.git",
|
"location" : "https://github.com/grpc/grpc-swift.git",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "4c63368b7462305903507e8acebd77264c0fb695",
|
"revision" : "87cecdeb2aae6b359b754d0dc7099e8237cf1824",
|
||||||
"version" : "1.8.2"
|
"version" : "1.11.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -18,13 +18,31 @@
|
||||||
"version" : "0.13.3"
|
"version" : "0.13.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"identity" : "swift-atomics",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/apple/swift-atomics.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "919eb1d83e02121cdb434c7bfc1f0c66ef17febe",
|
||||||
|
"version" : "1.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "swift-collections",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/apple/swift-collections.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "f504716c27d2e5d4144fa4794b12129301d17729",
|
||||||
|
"version" : "1.0.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"identity" : "swift-log",
|
"identity" : "swift-log",
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/apple/swift-log.git",
|
"location" : "https://github.com/apple/swift-log.git",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "5d66f7ba25daf4f94100e7022febf3c75e37a6c7",
|
"revision" : "6fe203dc33195667ce1759bf0182975e4653ba1c",
|
||||||
"version" : "1.4.2"
|
"version" : "1.4.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -32,8 +50,8 @@
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/apple/swift-nio.git",
|
"location" : "https://github.com/apple/swift-nio.git",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "124119f0bb12384cef35aa041d7c3a686108722d",
|
"revision" : "bc4c55b9f9584f09eb971d67d956e28d08caa9d0",
|
||||||
"version" : "2.40.0"
|
"version" : "2.43.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -41,8 +59,8 @@
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/apple/swift-nio-extras.git",
|
"location" : "https://github.com/apple/swift-nio-extras.git",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "a75e92bde3683241c15df3dd905b7a6dcac4d551",
|
"revision" : "6c84d247754ad77487a6f0694273b89b83efd056",
|
||||||
"version" : "1.12.1"
|
"version" : "1.14.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -50,8 +68,8 @@
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/apple/swift-nio-http2.git",
|
"location" : "https://github.com/apple/swift-nio-http2.git",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "108ac15087ea9b79abb6f6742699cf31de0e8772",
|
"revision" : "00576e6f1efa5c46dca2ca3081dc56dd233b402d",
|
||||||
"version" : "1.22.0"
|
"version" : "1.23.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -59,8 +77,8 @@
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/apple/swift-nio-ssl.git",
|
"location" : "https://github.com/apple/swift-nio-ssl.git",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "42436a25ff32c390465567f5c089a9a8ce8d7baf",
|
"revision" : "ba7c0d7f82affc518147ea61d240330bf7f7ea9b",
|
||||||
"version" : "2.20.0"
|
"version" : "2.22.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -68,8 +86,8 @@
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/apple/swift-nio-transport-services.git",
|
"location" : "https://github.com/apple/swift-nio-transport-services.git",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "2cb54f91ddafc90832c5fa247faf5798d0a7c204",
|
"revision" : "b6e37a0d442745760d6ed0195d8f283d3ce0414a",
|
||||||
"version" : "1.13.0"
|
"version" : "1.14.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -77,8 +95,8 @@
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/apple/swift-protobuf.git",
|
"location" : "https://github.com/apple/swift-protobuf.git",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "e1499bc69b9040b29184f7f2996f7bab467c1639",
|
"revision" : "88c7d15e1242fdb6ecbafbc7926426a19be1e98a",
|
||||||
"version" : "1.19.0"
|
"version" : "1.20.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -86,8 +104,7 @@
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/zcash-hackworks/zcash-light-client-ffi",
|
"location" : "https://github.com/zcash-hackworks/zcash-light-client-ffi",
|
||||||
"state" : {
|
"state" : {
|
||||||
"branch" : "bin/librustzcash_0_7",
|
"revision" : "8eefbd8d70356b426d8e1dd7b07d2703a5a8e222"
|
||||||
"revision" : "e8fbb84c1bec44af9dbef7e27c85f25e8f51a5af"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -16,7 +16,7 @@ let package = Package(
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.package(url: "https://github.com/grpc/grpc-swift.git", from: "1.8.0"),
|
.package(url: "https://github.com/grpc/grpc-swift.git", from: "1.8.0"),
|
||||||
.package(url: "https://github.com/stephencelis/SQLite.swift.git", from: "0.13.0"),
|
.package(url: "https://github.com/stephencelis/SQLite.swift.git", from: "0.13.0"),
|
||||||
.package(name:"libzcashlc", url: "https://github.com/zcash-hackworks/zcash-light-client-ffi", branch: "bin/librustzcash_0_7")
|
.package(name:"libzcashlc", url: "https://github.com/zcash-hackworks/zcash-light-client-ffi", revision: "8eefbd8d70356b426d8e1dd7b07d2703a5a8e222")
|
||||||
],
|
],
|
||||||
targets: [
|
targets: [
|
||||||
.target(
|
.target(
|
||||||
|
|
|
@ -1059,14 +1059,6 @@ extension CompactBlockProcessor {
|
||||||
for try await utxo in stream {
|
for try await utxo in stream {
|
||||||
utxos.append(utxo)
|
utxos.append(utxo)
|
||||||
}
|
}
|
||||||
guard try rustBackend.clearUtxos(
|
|
||||||
dbData: dataDb,
|
|
||||||
address: tAddress,
|
|
||||||
sinceHeight: startHeight - 1,
|
|
||||||
networkType: self.config.network.networkType
|
|
||||||
) >= 0 else {
|
|
||||||
throw CompactBlockProcessorError.generalError(message: "attempted to clear utxos but -1 was returned")
|
|
||||||
}
|
|
||||||
return storeUTXOs(utxos, in: dataDb)
|
return storeUTXOs(utxos, in: dataDb)
|
||||||
} catch {
|
} catch {
|
||||||
throw mapError(error)
|
throw mapError(error)
|
||||||
|
|
|
@ -30,21 +30,6 @@ extension CompactBlockProcessor {
|
||||||
}
|
}
|
||||||
.flatMap({ $0 })
|
.flatMap({ $0 })
|
||||||
|
|
||||||
do {
|
|
||||||
for tAddress in tAddresses {
|
|
||||||
guard try rustBackend.clearUtxos(
|
|
||||||
dbData: config.dataDb,
|
|
||||||
address: tAddress,
|
|
||||||
sinceHeight: config.walletBirthday - 1,
|
|
||||||
networkType: config.network.networkType
|
|
||||||
) >= 0 else {
|
|
||||||
throw rustBackend.lastError() ?? .genericError(message: "clearUtxos failed. no error message available")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
throw FetchUTXOError.clearingFailed(error)
|
|
||||||
}
|
|
||||||
|
|
||||||
var utxos: [UnspentTransactionOutputEntity] = []
|
var utxos: [UnspentTransactionOutputEntity] = []
|
||||||
let stream: AsyncThrowingStream<UnspentTransactionOutputEntity, Error> = downloader.fetchUnspentTransactionOutputs(tAddresses: tAddresses.map { $0.stringEncoded }, startHeight: config.walletBirthday)
|
let stream: AsyncThrowingStream<UnspentTransactionOutputEntity, Error> = downloader.fetchUnspentTransactionOutputs(tAddresses: tAddresses.map { $0.stringEncoded }, startHeight: config.walletBirthday)
|
||||||
for try await transaction in stream {
|
for try await transaction in stream {
|
||||||
|
|
|
@ -13,12 +13,12 @@ public protocol PendingTransactionEntity: SignedTransactionEntity, AbstractTrans
|
||||||
/**
|
/**
|
||||||
recipient address
|
recipient address
|
||||||
*/
|
*/
|
||||||
var toAddress: String { get set }
|
var toAddress: String { get }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
index of the account from which the funds were sent
|
index of the account from which the funds were sent
|
||||||
*/
|
*/
|
||||||
var accountIndex: Int { get set }
|
var accountIndex: Int { get }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
height which the block was mined at.
|
height which the block was mined at.
|
||||||
|
@ -34,7 +34,7 @@ public protocol PendingTransactionEntity: SignedTransactionEntity, AbstractTrans
|
||||||
/**
|
/**
|
||||||
value is 1 if the transaction was cancelled
|
value is 1 if the transaction was cancelled
|
||||||
*/
|
*/
|
||||||
var cancelled: Int { get set }
|
var cancelled: Int { get }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
how many times this transaction encoding was attempted
|
how many times this transaction encoding was attempted
|
||||||
|
@ -61,7 +61,7 @@ public protocol PendingTransactionEntity: SignedTransactionEntity, AbstractTrans
|
||||||
|
|
||||||
- Note: represented in timeIntervalySince1970
|
- Note: represented in timeIntervalySince1970
|
||||||
*/
|
*/
|
||||||
var createTime: TimeInterval { get set }
|
var createTime: TimeInterval { get }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Checks whether this transaction is the same as the given transaction
|
Checks whether this transaction is the same as the given transaction
|
||||||
|
|
|
@ -12,28 +12,6 @@ import libzcashlc
|
||||||
class ZcashRustBackend: ZcashRustBackendWelding {
|
class ZcashRustBackend: ZcashRustBackendWelding {
|
||||||
static let minimumConfirmations: UInt32 = 10
|
static let minimumConfirmations: UInt32 = 10
|
||||||
|
|
||||||
static func clearUtxos(
|
|
||||||
dbData: URL,
|
|
||||||
address: TransparentAddress,
|
|
||||||
sinceHeight: BlockHeight,
|
|
||||||
networkType: NetworkType
|
|
||||||
) throws -> Int32 {
|
|
||||||
let dbData = dbData.osStr()
|
|
||||||
|
|
||||||
let result = zcashlc_clear_utxos(
|
|
||||||
dbData.0,
|
|
||||||
dbData.1,
|
|
||||||
[CChar](address.stringEncoded.utf8CString),
|
|
||||||
Int32(sinceHeight),
|
|
||||||
networkType.networkId
|
|
||||||
)
|
|
||||||
|
|
||||||
guard result >= 0 else {
|
|
||||||
throw lastError() ?? .genericError(message: "No error message available")
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
static func createAccount(dbData: URL, seed: [UInt8], networkType: NetworkType) throws -> UnifiedSpendingKey {
|
static func createAccount(dbData: URL, seed: [UInt8], networkType: NetworkType) throws -> UnifiedSpendingKey {
|
||||||
let dbData = dbData.osStr()
|
let dbData = dbData.osStr()
|
||||||
|
|
||||||
|
@ -69,7 +47,6 @@ class ZcashRustBackend: ZcashRustBackendWelding {
|
||||||
zcashlc_create_to_address(
|
zcashlc_create_to_address(
|
||||||
dbData.0,
|
dbData.0,
|
||||||
dbData.1,
|
dbData.1,
|
||||||
Int32(usk.account),
|
|
||||||
uskPtr.baseAddress,
|
uskPtr.baseAddress,
|
||||||
UInt(usk.bytes.count),
|
UInt(usk.bytes.count),
|
||||||
[CChar](address.utf8CString),
|
[CChar](address.utf8CString),
|
||||||
|
@ -597,7 +574,6 @@ class ZcashRustBackend: ZcashRustBackendWelding {
|
||||||
zcashlc_shield_funds(
|
zcashlc_shield_funds(
|
||||||
dbData.0,
|
dbData.0,
|
||||||
dbData.1,
|
dbData.1,
|
||||||
Int32(usk.account),
|
|
||||||
uskBuffer.baseAddress,
|
uskBuffer.baseAddress,
|
||||||
UInt(usk.bytes.count),
|
UInt(usk.bytes.count),
|
||||||
memo.bytes,
|
memo.bytes,
|
||||||
|
|
|
@ -31,23 +31,6 @@ public enum DbInitResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
protocol ZcashRustBackendWelding {
|
protocol ZcashRustBackendWelding {
|
||||||
/// clears the cached utxos for the given address from the specified height on for the
|
|
||||||
/// provided addresses. This will clear all UTXOs for the address from the database.
|
|
||||||
/// if there are unspent funds, the balance will be zero after clearing up UTXOs,
|
|
||||||
/// needing to put them back again to restore the balance (if they weren't spent)
|
|
||||||
/// - Parameters:
|
|
||||||
/// - dbData: location of the data db file
|
|
||||||
/// - address: the address of the UTXO
|
|
||||||
/// - sinceheight: clear the UXTOs from that address on
|
|
||||||
/// - networkType: network type of this key
|
|
||||||
/// - Returns: the amount of UTXOs cleared or -1 on error
|
|
||||||
static func clearUtxos(
|
|
||||||
dbData: URL,
|
|
||||||
address: TransparentAddress,
|
|
||||||
sinceHeight: BlockHeight,
|
|
||||||
networkType: NetworkType
|
|
||||||
) throws -> Int32
|
|
||||||
|
|
||||||
/// Adds the next available account-level spend authority, given the current set of [ZIP 316]
|
/// Adds the next available account-level spend authority, given the current set of [ZIP 316]
|
||||||
/// account identifiers known, to the wallet database.
|
/// account identifiers known, to the wallet database.
|
||||||
///
|
///
|
||||||
|
|
|
@ -124,8 +124,6 @@ class PendingTransactionRepositoryTests: XCTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testUpdate() {
|
func testUpdate() {
|
||||||
let newAccountIndex = 1
|
|
||||||
let newValue = Zatoshi(123_456)
|
|
||||||
let transaction = createAndStoreMockedTransaction()
|
let transaction = createAndStoreMockedTransaction()
|
||||||
|
|
||||||
guard let id = transaction.id else {
|
guard let id = transaction.id else {
|
||||||
|
@ -142,8 +140,11 @@ class PendingTransactionRepositoryTests: XCTestCase {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
stored!.accountIndex = newAccountIndex
|
let oldEncodeAttempts = stored!.encodeAttempts
|
||||||
stored!.value = newValue
|
let oldSubmitAttempts = stored!.submitAttempts
|
||||||
|
|
||||||
|
stored!.encodeAttempts += 1
|
||||||
|
stored!.submitAttempts += 5
|
||||||
|
|
||||||
XCTAssertNoThrow(try pendingRepository.update(stored!))
|
XCTAssertNoThrow(try pendingRepository.update(stored!))
|
||||||
|
|
||||||
|
@ -152,8 +153,8 @@ class PendingTransactionRepositoryTests: XCTestCase {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
XCTAssertEqual(updatedTransaction.value, newValue)
|
XCTAssertEqual(updatedTransaction.encodeAttempts, oldEncodeAttempts + 1)
|
||||||
XCTAssertEqual(updatedTransaction.accountIndex, newAccountIndex)
|
XCTAssertEqual(updatedTransaction.submitAttempts, oldSubmitAttempts + 5)
|
||||||
XCTAssertEqual(updatedTransaction.toAddress, stored!.toAddress)
|
XCTAssertEqual(updatedTransaction.toAddress, stored!.toAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue