Commit Graph

67 Commits

Author SHA1 Message Date
Francisco Gindre 59dc56c9b4 Merge branch 'feature/zip-316-and-latest-upstream' into release/0.17.0-alpha.3 2022-11-01 15:09:39 -03:00
Francisco Gindre a12666e932 [#602] Improve error logging for InitializerError and RustWeldingError 2022-11-01 13:57:42 -03:00
Francisco Gindre 08e6738cf7 Fix compiler error 2022-11-01 07:47:31 -03:00
Francisco Gindre a0d02c4d57 PR Suggestions
`XCAsyncTestCase` does not work as intended but `wait {}` does what
we need.

restored `needsToStartScanningWhenStopped` as a Bool var on actor

fixed Enhancement test
2022-10-31 20:17:21 -03:00
Francisco Gindre 1c8e06742a Fix Tests than need to call the async TestCoordinator build function 2022-10-31 10:17:48 -03:00
Francisco Gindre 01d85f5748 Fix compiler errors 2022-10-31 09:57:10 -03:00
Francisco Gindre dbd4b8934c Merge branch 'master' into merge-master 2022-10-31 09:34:38 -03:00
Michal Fousek 02ee0a54ea [#593] Fix testSmallDownloadAsync test
- Test was failling with:
generalError(message: "block not found in cache, should always be in cache in darkside mode")
- There was no wait so lightwalletd in darkside mode didn't have enough time to accept mocked state.
2022-10-28 12:18:19 +02:00
Francisco Gindre b5d659e8a8 Fix various tests and deleted some that are not useful anymore
Closes #588
Closes #584
Closes #589
Closes #591
2022-10-27 20:09:08 -03:00
Lukas Korba cfe71d5da2
[#523] Make a CompactBlockProcessor an Actor (#565)
- Sample app refactored for the processor being an actor
- tests refactored as well
- dark side tests fixed
- utilities separated to new file
- synchronizer's start and stop are no longer in async context
- updating the UI for the scan fixed
2022-10-27 12:51:38 +02:00
Francisco Gindre 7403bcc809 Remove .orig file committed by mistake 2022-10-21 20:32:01 -03:00
Francisco Gindre 37b060852c
Merge pull request #567 from nuttycom/pending_transaction_entity_recipient
Add internal recipient information to `PendingTransactionEntity`
2022-10-21 18:27:52 -03:00
Francisco Gindre 2fb25dcd35 Fix: Transaction repository tests pass 2022-10-21 18:19:08 -03:00
Francisco Gindre 1979e410b5 Fix pre populated Db to have transactions from darksidewalletd seed 2022-10-21 13:54:53 -03:00
Kris Nuttycombe a483537cb1 Ensure that the persisted test database has had migrations applied. 2022-10-20 14:22:24 -06:00
Francisco Gindre 789cf01188 Add Fee field to Transaction, ConfirmedTransaction, ReceivedTransactions and Pen
dingTransactions.
Update Notes DAOs with new fields.

Make Zatoshi Codable

add tests for Recipient.forEncodedAddress
2022-10-19 17:37:06 -03:00
Kris Nuttycombe 849083ffd9 Fix UInt32 conversions to SQL in PendingTransactionDao 2022-10-19 14:13:18 -06:00
Francisco Gindre 30a9c066ad Replace `db.run` with `db.execute` to fix migration issues 2022-10-19 11:29:15 -03:00
Kris Nuttycombe 0fbf90dc82 Add migration to re-create pending_transactions table with nullable columns. 2022-10-18 19:44:34 -06:00
Kris Nuttycombe f5d7aa0f17 Modify PendingTransactionEntity to be able to represent internal shielding tx. 2022-10-18 10:07:23 -06:00
Francisco Gindre 923eca19ce [#561] Fix unified typecodes tests
Fix tests.

Fix tests.

Use Account 6 vectors on testListTransparentReceivers

only use first tree addresses from the vector for testListTransparentReceivers

Fix unified address generation tests.

Fix build and PR suggestions
2022-10-18 11:40:36 -03:00
Kris Nuttycombe 91ea6f5476 Update to latest librustzcash 2022-10-17 15:00:08 -06:00
Francisco Gindre 8a26e2e469 UFVK validation was validating sapling keys 2022-10-03 21:12:10 -03:00
Francisco Gindre 7f480e417d Merge branch 'master' into merge-master 2022-10-03 20:15:40 -03:00
Lukas Korba 9b6ff51b29
[#492] Get rid of blocking API (#551)
- blocking API removed, only latestBlockHeight() stayed
- non-blocking closure based API removed
- unit tests updated to use async API

[#492] Get rid of blocking API (#551)

- forgotten commented code cleaned up
- some comments were still mentioning result (completion closure), removed
2022-10-03 20:05:11 -03:00
Lukas Korba fa5bbbb2bf
[#541] Initialise gRPC on a separate thread (#545)
MultiThreadedEventLoopGroup has been replaced with NIOTSEventLoopGroup. It's recommended by authors of grpc-swift especially for iOS platform and it allows us to set the priority because NIOTSEventLoopGroup is GCD based while MultiThreadedEventLoopGroup is pthread based.

[#541] Initialise gRPC on a separate thread (#545)

- priority increased to .default
2022-10-03 15:54:43 -03:00
Francisco Gindre 7806b5114f
Use UnifiedSpendingKey for shielding and Spending (#535)
[#534] Use UnifiedSpendingKey for shielding and Spending

This commit implements the use of Unified Spending Keys for shielding
and spending as well as rolling Unified Addresses.

Users should obtain addresses by rolling them from the SDK.
USKs replace Sapling Extended Spending keys and TransparentAccountPrivKeys
when shielding or spending

Closes #534

Co-authored-by: Kris Nuttycombe <kris@nutty.land>

* Fix rebase issues

* PR Suggestion. Make `lastError` an Optional

* Fix test `testReOrgRemovesOutboundTxAndIsNeverMined`

Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2022-10-02 23:11:17 -03:00
Francisco Gindre ca5221ac75 Merge branch 'master' into merge-master-to-zip-316 2022-09-30 09:53:34 -03:00
Francisco Gindre 28985a4e38
Merge pull request #536 from LukasKorba/486_sendToAddress_async_await
[#486] sendToAddress async/await
2022-09-23 12:08:31 -07:00
Lukas Korba 2c93802828 [#487] shieldFunds to async/await
- API refactored to async

[#487] shieldFunds to async/await

- unit tests refactored
2022-09-21 16:36:41 +02:00
Lukas Korba 61683a85f3 [486] sendToAddress async/await
- sendToAddress and SaplingParameterDownloader refactored to async
- unit tests WIP

[486] sendToAddress async/await

- testing code cleanup

[#486] sendToAddress async/await

- reducing number of Tasks in Sample app

[#486] sendToAddress async/await

- I finally figure out how to make the dark side tests async, using new sendToAddress APIs and pass, POC done, 18 more tests to refactor

[#486] sendToAddress async/await

- async sendToAddress unit test refactored except NetworkUpgradeTests

[#486] sendToAddress async/await

- NetworkUpgradeTests refactored to async API

[#486] sendToAddress async/await

- cleanup

[#486] sendToAddress async/await (#536)

- PR comments resolved
2022-09-21 13:47:17 +02:00
Francisco Gindre 38b8fd09d8
Merge pull request #531 from zcash/receiver_type_codes
Receiver type codes
2022-09-20 10:27:54 -07:00
Francisco Gindre a9805cfe7e [#530] Implement ability to extract available typecodes from UA
this introduces several types under UnifiedAddress `ReceiverTypecodes`
and `UnifiedAddress.Errors` to host possible errors on third-party
generated UAs and their composition

Implement extracting the typecodes from a UA
2022-09-19 14:52:30 -03:00
Francisco Gindre db15465ebe Merge branch 'master' into release/0.16.10-beta 2022-09-16 18:04:14 -03:00
Francisco Gindre 60aa28628b [#532] [0.16.x-beta] Download does not stop correctly
Issue Reported:

When the synchronizer is stopped, the processor does not cancel
the download correctly. Then when attempting to resume sync, the
synchronizer is not on .stopped and can't be resumed

this doesn't appear to happen in master branch that uses
structured concurrency for operations.

Fix:
This commit makes sure that the download streamer checks cancelation
before processing any block, or getting called back to report progress
2022-09-16 16:59:31 -03:00
Francisco Gindre e82a6d26ee
Merge pull request #518 from zcash/merge_master_to_zip_316
Merge master to zip 316
2022-09-15 08:03:29 -07:00
Francisco Gindre bee1c9db80 Merge branch 'master' into merge_master_to_zip_316 2022-09-15 11:04:49 -03:00
Lukas Korba 2b65bd46e4 [476] CompactBlockProcessor to async/await
- getting rid of the Operation Queue
- the cleanup is needed
- the update of tests is needed
- tested and it successfully finishes the sync process

[476] CompactBlockProcessor to async/await

- old processNewBlocks() removed

[476] CompactBlockProcessor to async/await

- unused operations removed

[476] CompactBlockProcessor to async/await

- unit tests update

[476] CompactBlockProcessor to async/await

- unit tests refactored

[476] CompactBlockProcessor to async/await

- cleanup of deprecated method

[476] CompactBlockProcessor to async/await

- fail(error) was called even for canceled tasks but that must be excluded

[476] CompactBlockProcessor to async/await

- removal of all ZcashOperations from the code (unit test will follow)

[476] CompactBlockProcessor to async/await

- network tests in building and success order again

[476] CompactBlockProcessor to async/await

- offline tests in building and success order

[476] CompactBlockProcessor to async/await (519)

- cleanup of suspending the task

[476] CompactBlockProcessor to async/await (519)

- most comments resolved

[476] CompactBlockProcessor to async/await (519)

- thread safe state for both sync and async context

[476] CompactBlockProcessor to async/await (519)

- fixed build for a sample project

[476] CompactBlockProcessor to async/await (519)

- func testStartNotifiesSuscriptors() reverted

[476] CompactBlockProcessor to async/await (519)

- TODO added to track why we used NSLock instead of an Actor
- Task priority enhanced

[476] CompactBlockProcessor to async/await (519)

- cleanup in Tasks and priorities
2022-09-15 08:10:12 +02:00
Francisco Gindre cd345f6ddc Add test utilities for db Migration 2022-09-12 16:58:29 -06:00
Francisco Gindre a1bc2937d4 Issue #374 - XCTest don't load Resources from the module's bundle
Tests referencing Bundle.module were failing.
Fixed with proposed solution here:
https://stackoverflow.com/questions/47177036/use-resources-in-unit-tests-with-swift-package-manager
2022-09-12 16:58:29 -06:00
Francisco Gindre 4428f9ffb2 Merge branch 'feature/zip-316-and-latest-upstream' into merge_master_to_zip_316 2022-09-12 13:40:05 -03:00
Francisco Gindre 0282d81584 Fix Errors introduced by Merge-Commit 2022-09-08 20:44:38 -03:00
Francisco Gindre 458d3d7106 Merge branch 'feature/zip-316-and-latest-upstream' into merge_master_to_zip_316 2022-09-07 20:58:46 -03:00
Francisco Gindre 9b930391a4 [#384] Adopt Type Safe Memos in the FFI and SDK
Closes #384

This makes the SDK use the Memo and MemoBytes types across the FFI and the
public interface of the SDKSynchronizer. Addresses the comments by @defuse  on
issue https://github.com/zcash/ZcashLightClientKit/issues/378.
These changes depend on zcash-light-client-ffi repo changes managing
memos as byte arrays instead of string encoding of memos.

There are some compromises in terms of database representation of memos
and their exposure in transaction representing entities because we
wanted to avoid changing the database at this moment and be retro-
compatible with earlier versions and maintain deprecated APIs for wallets
to have time to adopt.

Memo and MemoBytes are WIP and subject to change. we are exploring
making Memo an opaque type based on a struct and drop the enum approach
to make the interface less throwing.

Fix: wrap new functions and deprecate old API. catch Memo errors

update get_sent and get_received memo functions from rust welding
point to branch in FFI repo

Fix type Tests/DarksideTests/BalanceTests.swift

Co-authored-by: Carter Jernigan <git@carterjernigan.com>

PR suggestions. Inverted condition

PR Suggestions + cleanup

merge fixes

Suggestions from PR to treat null bytes on TextMemo

refactor unpaddedRawBytes function and add tests

undo change in PendingTransactionSQLDAO

Fix broken import on Swift Package for libzcashlc

Fix libzcashlc url

Fix travis.yml
2022-09-07 14:49:08 -03:00
Francisco Gindre ed87a2781c [#461] Adopt a Type-Safe Keys and Addresses API
This PR creates data types for Addresses and Keys so that they are
not represented by Strings anymore. This avoids mistakenly use
the wrong keys because they are all alike for the type system.

New Protocols:
=============

StringEncoded -> Protocol that makes a type can be expressed in an
string-encoded fashion either for UI or Interchange purposes.

Undescribable -> A protocol that implements methods that override default
decriptions used by debuggers, loggers and event trackers to avoid types
conforming to it to be leaked to logs.

Deleted Protocols:
==================

UnifiedFullViewingKey --> turned into a struct.
UnifiedAddress --> turned into a struct

new Error Type:
================

````
enum KeyEncodingError: Error {
    case invalidEncoding
}
````

This error is thrown when an Address or Key type (addresses are public
keys in the end) can be decoded from their String representation,
typically upon initialization from a User input.

New Types:
=========

SaplingExtendedSpendingKey -> Type for Sapling Extended Full Viewing Keys
this type will be replaced with Unified Spending Keys soon.

SaplingExtendedFullViewingKey -> Extended Full Viewing Key for Sapling.
Maintains existing funcionality. Will be probably deprecated in favor of
UFVK.

TransparentAccountPrivKey -> Private key for transparent account. Used
only for shielding operations. Note: this will probably be deprecated soon.

UnifiedFullViewingKey -> Replaces the protocol that had the same name.

TransparentAddress -> Replaces a type alias with a struct

SaplingAddress --> Represents a Sapling receiver address. Comonly called zAddress. This address corresponds to the Zcash Sapling shielded pool.
Although this it is fully functional, we encourage developers to
choose `UnifiedAddress` before Sapling or Transparent ones.

UnifiedAddress -> Represents a UA. String-encodable and Equatable. Use of
UAs must be favored instead of individual receivers for different pools.
This type can't be decomposed into their Receiver types yet.

Recipient -> This represents all valid receiver types to be used as
inputs for outgoing transactions.

````
public enum Recipient: Equatable, StringEncoded {
    case transparent(TransparentAddress)
    case sapling(SaplingAddress)
    case unified(UnifiedAddress)
````

The wrapped concrete receiver is a valid receiver type.

Deleted Type Aliases:
=====================

The following aliases were deleted and turned into types
````
public typealias TransparentAddress = String
public typealias SaplingShieldedAddress = String

````

Changes to Derivation Tool
==========================

DerivationTool has been changed to accomodate this new types and
remove Strings whenever possible.

Changes to Synchronizer and CompactBlockProcessor
=================================================
Accordingly these to components have been modified to accept the
new types intead of strings when possible.

Changes to Demo App
===================
The demo App has been patch to compile and work with the new types.
Developers must consider that the use (and abuse) of forced_try and
forced unwrapping is a "license" that maintainers are using for the
sake of brevity. We consider that clients of this SDK do know how to
handle Errors and Optional and it is not the objective of the demo
code to show good practices on those matters.

Closes #461
2022-09-05 15:09:07 -03:00
Francisco Gindre d737ddefa9 Merge branch 'master' into merge_master_to_zip_316 2022-09-01 17:51:46 -03:00
Lukas Korba 16d1948b5b
[#465] CompactBlockDownloading to Async/Await (#507)
Closes #465
- CompactBlockDownloading closures removed
- CompactBlockDownloading new async API provided
2022-08-29 16:31:01 -03:00
Lukas Korba 742e6bd8ec
[#464] CompactBlockStorage To async/await (#494)
- await/async APIs provided
- async throws unit tests using new API implemented

[464] CompactBlockStorage To async/await (494)

- removed deprecated closure APIs
- upgraded use of the async APIs
- tests updated
2022-08-26 14:52:12 -03:00
Lukas Korba f1a570bbc2
[#463] Migrate LightwalletService to Async/Await (#493)
- migration of the protocol's methods done
- split the code so there's blocking and non-blocking API separately

[463] Migrate LightwalletService to Async/Await

- draft

[463] Migrate LightwalletService to Async/Await

- failing tests under investigation

[463] Migrate LightwalletService to Async/Await

- code cleanup
- tests cleanup
- async throws unit tests added

[463] Migrate LightwalletService to Async/Await

- sample app updated to the latest API

[463] Migrate LightwalletService to Async/Await

- cleanup

[463] Migrate LightwalletService to Async/Await

- cleanup

[463] Migrate LightwalletService to Async/Await

- fixed non-building tests

[463] Migrate LightwalletService to Async/Await

- reverting back to lastHeight()

[463] Migrate LightwalletService to Async/Await

updated code to AsyncStream

[463] Migrate LightwalletService to Async/Await (493)

- tests fixed
- blockRange reimplemented to use AsyncStream
- grpc proto files regenerated to exclude Server
2022-08-25 10:39:59 -03:00
Kris Nuttycombe 905ee401d1 Use zcash_client_sqlite to manage migrations for the wallet db.
This change removes responsibility for maintaining the state of
the wallet database from `ZcashLightClientKit` in favor of using
the migration system now provided by librustzcash. This will help
to ensure that the structure of the database is kept consistent with
the functions that query and update the database state.

Co-authored-by: Francisco Gindre <francisco.gindre@gmail.com>
2022-08-24 09:38:42 -06:00