Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
880 changes: 822 additions & 58 deletions Cargo.lock

Large diffs are not rendered by default.

27 changes: 21 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,53 @@ publish = false
[dependencies]
android_logger = "0.6"
failure = "0.1"
futures = { version = "0.1", optional = true }
grpc = { version = "0.6", optional = true }
hex = { version = "0.3", optional = true }
jni = { version = "0.10", default-features = false }
log = "0.4"
log-panics = "2.0.0"
protobuf = "2"
rand = "0.4"
rusqlite = { version = "0.15", features = ["bundled"] }
time = "0.1"

[dependencies.ff]
git = "https://github.com/str4d/librustzcash.git"
rev = "89cfef8515d5d88809c485a44fdc54572b9e5666"
rev = "669df0fa7b2fbd8e1d2ee78d7f0c6544ea04bfd3"

[dependencies.pairing]
git = "https://github.com/str4d/librustzcash.git"
rev = "89cfef8515d5d88809c485a44fdc54572b9e5666"
rev = "669df0fa7b2fbd8e1d2ee78d7f0c6544ea04bfd3"

[dependencies.sapling-crypto]
git = "https://github.com/str4d/librustzcash.git"
rev = "89cfef8515d5d88809c485a44fdc54572b9e5666"
rev = "669df0fa7b2fbd8e1d2ee78d7f0c6544ea04bfd3"

[dependencies.zcash_client_backend]
git = "https://github.com/str4d/librustzcash.git"
rev = "89cfef8515d5d88809c485a44fdc54572b9e5666"
rev = "669df0fa7b2fbd8e1d2ee78d7f0c6544ea04bfd3"

[dependencies.zcash_primitives]
git = "https://github.com/str4d/librustzcash.git"
rev = "89cfef8515d5d88809c485a44fdc54572b9e5666"
rev = "669df0fa7b2fbd8e1d2ee78d7f0c6544ea04bfd3"

[dependencies.zip32]
git = "https://github.com/str4d/librustzcash.git"
rev = "89cfef8515d5d88809c485a44fdc54572b9e5666"
rev = "669df0fa7b2fbd8e1d2ee78d7f0c6544ea04bfd3"

[dev-dependencies]
tempfile = "3"

[features]
updater = ["futures", "grpc", "hex"]

[lib]
name = "zcashwalletsdk"
path = "src/main/rust/lib.rs"
crate-type = ["staticlib", "cdylib"]

[[bin]]
name = "update-sapling-tree"
path = "src/main/rust/bin/update_sapling_tree.rs"
required-features = ["updater"]
4 changes: 4 additions & 0 deletions src/main/java/cash/z/wallet/sdk/jni/JniConverter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class JniConverter {

external fun getBalance(dbData: String, account: Int): Long

external fun getReceivedMemoAsUtf8(dbData: String, idNote: Long): String

external fun getSentMemoAsUtf8(dbData: String, idNote: Long): String

external fun scanBlocks(db_cache: String, db_data: String): Boolean

external fun sendToAddress(
Expand Down
47 changes: 47 additions & 0 deletions src/main/proto/compact_formats.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
syntax = "proto3";
package cash.z.wallet.sdk.rpc;
option go_package = "walletrpc";

// Remember that proto3 fields are all optional. A field that is not present will be set to its zero value.
// bytes fields of hashes are in canonical little-endian format.

// CompactBlock is a packaging of ONLY the data from a block that's needed to:
// 1. Detect a payment to your shielded Sapling address
// 2. Detect a spend of your shielded Sapling notes
// 3. Update your witnesses to generate new Sapling spend proofs.
message CompactBlock {
uint32 protoVersion = 1; // the version of this wire format, for storage
uint64 height = 2; // the height of this block
bytes hash = 3;
uint32 time = 4;
bytes header = 5; // (hash and time) OR (full header)
repeated CompactTx vtx = 6; // compact transactions from this block
}

message CompactTx {
// Index and hash will allow the receiver to call out to chain
// explorers or other data structures to retrieve more information
// about this transaction.
uint64 index = 1;
bytes hash = 2;

// The transaction fee: present if server can provide. In the case of a
// stateless server and a transaction with transparent inputs, this will be
// unset because the calculation requires reference to prior transactions.
// in a pure-Sapling context, the fee will be calculable as:
// valueBalance + (sum(vPubNew) - sum(vPubOld) - sum(tOut))
uint32 fee = 3;

repeated CompactSpend spends = 4;
repeated CompactOutput outputs = 5;
}

message CompactSpend {
bytes nf = 1;
}

message CompactOutput {
bytes cmu = 1;
bytes epk = 2;
bytes ciphertext = 3;
}
49 changes: 49 additions & 0 deletions src/main/proto/service.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
syntax = "proto3";
package cash.z.wallet.sdk.rpc;
option go_package = "walletrpc";

import "compact_formats.proto";

// A BlockID message contains identifiers to select a block: a height or a
// hash. If the hash is present it takes precedence.
message BlockID {
uint64 height = 1;
bytes hash = 2;
}

// BlockRange technically allows ranging from hash to hash etc but this is not
// currently intended for support, though there is no reason you couldn't do
// it. Further permutations are left as an exercise.
message BlockRange {
BlockID start = 1;
BlockID end = 2;
}

// A TxFilter contains the information needed to identify a particular
// transaction: either a block and an index, or a direct transaction hash.
message TxFilter {
BlockID block = 1;
uint64 index = 2;
bytes hash = 3;
}

// RawTransaction contains the complete transaction data.
message RawTransaction {
bytes data = 1;
}

message SendResponse {
int32 errorCode = 1;
string errorMessage = 2;
}

// Empty placeholder. Someday we may want to specify e.g. a particular chain fork.
message ChainSpec {}

service CompactTxStreamer {
rpc GetLatestBlock(ChainSpec) returns (BlockID) {}
rpc GetBlock(BlockID) returns (CompactBlock) {}
rpc GetBlockRange(BlockRange) returns (stream CompactBlock) {}
rpc GetTransaction(TxFilter) returns (RawTransaction) {}
rpc SendTransaction(RawTransaction) returns (SendResponse) {}
}
Loading