Commit Graph

248 Commits

Author SHA1 Message Date
Jack Grigg 0591784ce4
Add mainnet support to Rust backend via a feature flag 2019-05-14 17:10:03 +01:00
Jack Grigg e69f4b6003
Migrate to refactored librustzcash branch 2019-05-14 17:10:03 +01:00
Kevin Gorham 7ec61df4a9 Changes to support memo sample
Mostly includes convenience functions for determining balance.
2019-04-24 03:16:15 -04:00
Kevin Gorham 30d36b723e
Improve logging behavior.
This simplifies the process of constructing an SdkSynchronizer.
2019-04-24 02:43:33 -04:00
Kevin Gorham 01b1ca1fed Add KDocs to Synchronizer implementations and tidy their code 2019-03-30 00:20:32 -04:00
Kevin Gorham 7265a793c4 Restore tests to compiling 2019-03-29 02:05:45 -04:00
Kevin Gorham 72283cee81 Cleanup Synchronizer API, add KDocs and remove dead code 2019-03-29 02:04:25 -04:00
Kevin Gorham 796fe9602c Update dependencies 2019-03-29 02:03:11 -04:00
Kevin Gorham 359e5c0adc Clean up data API
Remove unused functionality and disable modification to tables that should only be written by librustzcash
2019-03-27 01:37:46 -04:00
Kevin Gorham e7108ca818 Cleanup
This commit will get iteratively polished until the PR is ready
- Addresses PR feedback https://github.com/zcash/zcash-android-wallet-sdk/pull/16#discussion_r264948336
2019-03-27 01:37:46 -04:00
Kevin Gorham b978bb5bc7 Update the logic for determining balance 2019-03-27 01:37:46 -04:00
Kevin Gorham 4aaf55f057 Add a layer of logic for bubbling up errors
This allows the app to show an error dialog rather than crashing silently
2019-03-27 01:37:46 -04:00
Kevin Gorham 17be0c85cb Improve logic and behavior during app startup.
Never start downloading blocks prior to sapling activation height, only allow firstrun when dataDb is empty and also add birthday support. Also added corrections to isFirstRun logic.
2019-03-27 01:37:46 -04:00
Kevin Gorham ef58fecbf1 Remove unused things and document limits of Junit 5 usage
It is not really practical to try and use JUnit 5 for Android Instrumentation tests at this time. See documentation in build.gradle for details.
2019-03-27 01:37:46 -04:00
Kevin Gorham 3efc91806a Prevent change from being returned in transaction queries 2019-03-27 01:37:46 -04:00
Kevin Gorham 0ed5731ff4 Add address information to notes query and other cleanup 2019-03-27 01:37:46 -04:00
Kevin Gorham 4cbdd2ab27 Add additional logging to mock synchronizer 2019-03-27 01:37:46 -04:00
Kevin Gorham 82918dc09f Twig: Refactor to be much more useful. 2019-03-27 01:37:46 -04:00
Kevin Gorham ecff3ce588 Add conversion logic and extensions for consistency and correctness
Working with bigdecimals anytime we need to multiply or divide values because it was causing issues when repeatedly toggling currency on the send screen. Coupled this with lots of improvements on the app side to do less processing while changing currencies
2019-03-27 01:37:46 -04:00
Kevin Gorham 2132bc14fd Fix bugs 2019-03-27 01:37:46 -04:00
Kevin Gorham 1b37784e44 Create mock synchronizer to help with driving the UI.
After experiencing several issues that make it more difficult to test send behavior, including the amount of time required to wait for blocks to get mined when testnet is slow,
it became obvious that it was time to investigate mocking. Most of the behavior in the SDK is driven by channels so the mock only has to focus on putting useful data in the
expected channels at the right time. One tradeoff here was the need to make all the synchronizer properties private, that way any implementation can achieve compatability
without necessasily leveraging the same combinations of building blocks. This tradeoff felt acceptable given that these dependencies can be injected and available as singletons,
if needed. This also had a side effect of elevating several channels into the Synchronizer interface, rather than reaching into the synchronizer to directly access those dependencies.
Another benefit is that it's now easier to see what matters most to the app, particularly which channels are essential.
2019-03-27 01:37:46 -04:00
Kevin Gorham bf7b3ee744 Iterate and refine send and active transaction behavior
Send is now functional and shows up in active transactions.
This involved:
- reducing the exposure of the seed
- consistently using Ints for blockheight everywhere to match zcash
- adding the use of spending keys
- adding account initialization on startup
- using accounts but defaulting to account 0
- internalizing birthday so we no longer need a reference outside of the library
- enabling cancellation during send
- cleanup active transaction manager
2019-03-27 01:37:46 -04:00
Kevin Gorham 888646f73b Create ActiveTransactionManager to monitor active transactions
When a transaction is sent it transitions through a lifecycle, beginning with creating the raw transaction and ending with it being mined and added to the blockchain
2019-03-27 01:37:46 -04:00
Kevin Gorham 4d226a8c5e Create CompactBlockProcessor and refine responsibilities of collaborators
The synchronizer now primarily collaborates with a downloader, processor and repository; each with a more focused set of responsibilities.
The downloader streams blocks into a channel, the processor saves blocks from that channel and scans for transactions, the repository
exposes transaction change events.
2019-03-27 01:37:46 -04:00
Kevin Gorham a871c5e476 Integrate with dataDb init commands and grpc service updates.
On the rust side, we now have access to the init DB commands. On the Go side we have time available for blocks
2019-03-27 01:37:46 -04:00
Kevin Gorham 57630f8eba Create CompactBlockDownloader, iterate on business logic using new JUnit5 setup
streaming is working and tests are functional
2019-03-27 01:37:46 -04:00
Kevin Gorham b688013f16 Switch to JUnit 5 2019-03-27 01:37:46 -04:00
Kevin Gorham 6c869a47df Create synchronizer and add layer of business logic onto the data layer
App is functional and displays transactions
2019-03-27 01:37:46 -04:00
Kevin Gorham 1501f1a7d2 Add data access layer for dataDb
Update the scanBlocks request and integrate with the data that it generates inside dataDb
2019-03-27 01:37:46 -04:00
Jack Grigg 1474fae4b8
Move SQL backend into librustzcash
Also some tweaks due to error-handling changes in librustzcash.
2019-03-13 06:56:28 +00:00
Kevin Gorham 245841807c add hex as required dependency, then use it inside init_blocks_table 2019-02-23 20:16:45 -05:00
Kevin Gorham 2c4a48b772 modify update_sapling_tree utility to output JSON 2019-02-22 10:04:32 -05:00
Kevin Gorham 148563b7e6 modify scan operation to start from sapling activation.
Rather than starting from zero because we do not need non-sapling blocks, prior to sapling's activation.
2019-02-22 10:04:32 -05:00
Jack Grigg 870283c8ea
JniConverter.getVerifiedBalance() 2019-02-19 01:45:38 +00:00
Jack Grigg 2a091a1da1
crate::sql::get_verified_balance() 2019-02-19 01:39:36 +00:00
Jack Grigg 4c901fc21f
Exclude spendable notes from selection that aren't verified 2019-02-19 01:25:25 +00:00
Jack Grigg 2695e8f6fd
Mark notes as unspent when the transaction they are spent in expires 2019-02-19 00:59:09 +00:00
Jack Grigg 273881c3b6
Re-introduce requirement that scanned blocks are height-sequential
This prevents the data DB from getting into a state where the Sapling
commitment tree is invalid, which was occurring too easily in testing.
2019-02-18 12:47:16 +00:00
Jack Grigg d145091139
Debug logging in note selection 2019-02-18 12:31:57 +00:00
Jack Grigg 1cd1a4d2f1
Lock notes after transaction creation to prevent serial double-spends
Does not prevent parallel double-spends.
2019-02-18 12:27:14 +00:00
Jack Grigg 208a9497dd
Ensure we always select anchors from blocks that we have 2019-02-18 11:55:34 +00:00
Jack Grigg b95f0b1fc9
Fix witness-updating bug, and enforce witness validity 2019-02-14 19:47:18 +00:00
Jack Grigg 966b6a9df5
Include fee in target value 2019-02-13 10:16:56 +00:00
Jack Grigg e3ecc6f7dc
Fix underflow in target height when selecting anchor
This won't occur in practice because Sapling activated at a height well
above ANCHOR_OFFSET, but good to fix anyway.
2019-02-13 10:10:23 +00:00
Jack Grigg 6842c293fe
Ensure we have sufficient balance before using transaction::Builder
The Builder does return an error if insufficient spend value is
provided, but we can give a more meaningful error here.
2019-02-12 20:55:43 +00:00
Jack Grigg 9b29276dba
Return a more useful error if send_to_address() is called with no blocks 2019-02-12 20:49:35 +00:00
Jack Grigg 8eeddb2de0
Test that send_to_address() fails with incorrect ExtendedSpendingKeys 2019-02-12 19:46:16 +00:00
Jack Grigg 933fb07f42
Wrap all exceptions and panics to relay them over JNI 2019-02-12 02:56:17 +00:00
Jack Grigg 25e79f042b
Use failure::Error in utils::exception instead of jni::errors::Error 2019-02-11 16:52:00 +00:00
Jack Grigg 42b2076dc1
Add exception utilities to the crate 2019-02-11 16:35:44 +00:00
Jack Grigg 37c0efad77
Utilities for conveying Rust exceptions and panics to Java
Source: affa85c026/exonum-java-binding/core/rust/src/utils/exception.rs
License: Apache-2.0
2019-02-11 16:33:11 +00:00
Jack Grigg 6d86b2cf16
Extract rust_vec_to_java() utility function 2019-02-11 16:20:11 +00:00
Jack Grigg 5dfadd4393
Extract java_string_to_rust() utility function 2019-02-11 15:44:49 +00:00
Jack Grigg 1163c557a8
Use spending_key helper instead of manually constructing account path 2019-02-11 15:36:34 +00:00
Jack Grigg 886017a4f5
Migrate to Rust 2018 edition
Requires a minimum of Rust 1.31.
2019-02-11 15:11:09 +00:00
Jack Grigg c4231fb404
Fix bug in collect() return type 2019-02-11 15:03:27 +00:00
Jack Grigg eca0bbc697
Explicitly panic instead of unwrapping when an invariant is broken 2019-02-11 14:28:19 +00:00
Jack Grigg e3ccb73a99
Remove unnecessary unwraps 2019-02-11 14:28:18 +00:00
Jack Grigg d1c3c55b0d
Test that scan_cached_blocks finds change notes 2019-02-11 14:28:17 +00:00
Jack Grigg 70f9ab54c6
Simple binary to calculate the latest Sapling commitment tree
The gRPC Rust bindings are committed instead of requiring protoc to build.
2019-02-11 14:27:43 +00:00
Jack Grigg b78a611f7b
JNI APIs to fetch memo fields as UTF8 2019-02-08 21:06:25 +00:00
Jack Grigg 6ae75baf35
Test that scan_cached_blocks finds received notes 2019-02-08 21:06:24 +00:00
Jack Grigg e8eda3db33
Test that init_accounts_table stores the correct address 2019-02-08 21:06:23 +00:00
Jack Grigg 5dea1dbc04
Test that initialisation APIs are one-shot 2019-02-08 21:06:22 +00:00
Jack Grigg 8d9124fab5
Pass paths into the SQL API using AsRef<Path> instead of &str
This enables both &str and &Path to be used, depending on how the API is
being called.
2019-02-08 21:06:21 +00:00
Jack Grigg 45adb0af4a
Store creation time and expiry height in transactions table
- Creation time can be used in the UI before a transaction gets mined.
- Expiry height enables the UI to indicate expired transactions.
2019-02-07 14:39:50 +00:00
Jack Grigg c51a90f4de
Fix clippy lints 2019-02-07 13:02:50 +00:00
Jack Grigg acd8c395f3
Tidy up imports 2019-02-07 12:58:33 +00:00
Jack Grigg a9674a148b
Remove cfg(target_os="android") restriction
The crate lives inside the Android SDK, and will only ever target
Android devices, so it's fine to simplify here.
2019-02-07 12:56:04 +00:00
Jack Grigg e99ed5bdeb
Extract SQL API into a separate module 2019-02-07 12:50:40 +00:00
Kevin Gorham 66fff55967 bugfix: update JNI method signature to match implementation.
We removed the need to pass the seed around because that is highly sensitive data. Instead, we work with less sensitive sending keys.
2019-02-05 11:24:40 -05:00
Jack Grigg 62b4d43341
Remove seed argument from JniConverter.getAddress(), add account arg 2019-02-01 21:57:13 +00:00
Jack Grigg b608b026ed
Remove seed argument from JniConverter.scanBlocks()
The API now scans cached CompactBlocks using the ExtendedFullViewingKeys
for the internally-tracked accounts.
2019-02-01 21:57:12 +00:00
Jack Grigg d9232c885d
JniConverter.initAccountsTable() 2019-02-01 21:57:11 +00:00
Jack Grigg c26249373d
JniConverter.initBlocksTable() 2019-02-01 21:57:10 +00:00
Jack Grigg 41bb9a1a4b
JniConverter.initDataDb() 2019-02-01 21:57:08 +00:00
Jack Grigg aa391063d1
JniConverter.getBalance() 2019-02-01 21:57:07 +00:00
Jack Grigg d98191d110
JniConverter.sendToAddress() 2019-02-01 21:57:06 +00:00
Jack Grigg 3966798f53
API for creating transactions 2019-02-01 21:57:05 +00:00
Jack Grigg ab2b5903a0
Improvements to JniConverter.scanBlocks()
- Store Sapling tree with blocks
- Store witnesses with full notes
- Track note spends
- Track change notes
- Store index within block for each transaction
  - This will make it easier to request entire blocks of transactions at
    some point, and then filter out only the transactions we care about.
- Store block times while scanning blocks
- Return bool with error state from JniConverter.scanBlocks()
- Support cached blocks that are height-ascending but not sequential
  - Blocks that do not contain Sapling data may be skipped.
- Return error from scan_cached_blocks() if heights are not ascending
2019-02-01 17:41:09 +00:00
Jack Grigg 3188cf8942
Remove now-unused ValueReceived protobuf 2019-01-31 16:09:37 +00:00
Jack Grigg f622a3bcd8
Persist received notes in an SQLite database 2019-01-31 16:09:25 +00:00
Kevin Gorham afc9a57d5d
checkpoint. DB works
Updated tests and found the root problem was with the SQL export,
meaning everything is actually working as expected.
2018-12-01 01:48:05 +00:00
Kevin Gorham c9f11c6d2b
allow test to pass 2018-12-01 01:48:04 +00:00
Kevin Gorham b499edd438
test scan blocks 2018-12-01 01:48:03 +00:00
Kevin Gorham addcf60fc4
add error logging in Rust
This allows errors to bubble up to the android log file, rather than
having to sift through a tombstone file on the device.
2018-12-01 01:48:02 +00:00
Kevin Gorham 5df6e95e4f
saving and retrieving data is working and db files are generated 2018-12-01 01:48:01 +00:00
Kevin Gorham 72b594b0d0
added JNI test
I am a little excited about this because it will be a great way to test
Rust functionality quickly and iterate quickly because we will not have
to update and run the full app.
2018-12-01 01:48:00 +00:00
Kevin Gorham 241c646f14
checkpoint. data access object exists 2018-12-01 01:47:59 +00:00
Kevin Gorham 58f5a24a90
checkpoint. database exists 2018-12-01 01:47:58 +00:00
Kevin Gorham 81667f17cc
start with a test and maybe it will actually get used, Eventually. 2018-12-01 01:47:57 +00:00
Jack Grigg 83e00e1611
JniConverter.scanBlocks() 2018-12-01 01:47:41 +00:00
Jack Grigg 7bc3f2eede
Generate Rust protobuf representing received value 2018-12-01 01:46:35 +00:00
Jack Grigg fc6c3c6b2b
Split address_from_seed to expose ExtendedFullViewingKey 2018-12-01 01:46:34 +00:00
Jack Grigg 6ab9c6610c
JniConverter.getAddress(seed) 2018-12-01 01:43:05 +00:00
Jack Grigg 193a1f3b22
cargo fmt 2018-11-21 13:51:37 +00:00
Kevin Gorham 19212b14c4 ignore unused variable 2018-11-21 02:04:06 -05:00
Kevin Gorham 32af4b9559 initial commit of sample project code
The next step is to clean this up and integrate it with the latest version of the android app
2018-11-20 12:59:08 -05:00