-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
124 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "linar" | ||
name = "tinyzcash" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,21 @@ | ||
# tinyzcash | ||
# tinyzcash 0.1.0 | ||
A simple CLI application | ||
|
||
## USAGE: | ||
tinyzcash <SUBCOMMAND> | ||
|
||
## FLAGS: | ||
-h, --help Prints help information | ||
-V, --version Prints version information | ||
|
||
## SUBCOMMANDS: | ||
createblockchain create a new blockchain | ||
createwallet create a new wallet | ||
deposit deposit funds | ||
getbalance get the balance of a wallet | ||
help Prints this message or the help of the given subcommand(s) | ||
listaddress list all addresses | ||
printchain print the entire blockchain | ||
send send funds | ||
withdraw withdraw funds | ||
zsend send funds with privacy (shielded transaction) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
use std::fmt; | ||
use serde::{Deserialize, Serialize}; | ||
use orchard::{ | ||
Action as oAction, | ||
bundle::{Authorized}, | ||
}; | ||
use orchard::bundle::Authorization; | ||
use crate::transaction::Transaction; | ||
|
||
#[derive(Clone, Serialize, Deserialize, Default)] | ||
pub struct Bundle { | ||
actions:Vec<Action>, | ||
flags: u8, | ||
value_balance: i64, | ||
anchor: String, | ||
proof: String, | ||
binding_sig:String, | ||
} | ||
#[derive(Clone,Serialize, Deserialize)] | ||
pub struct Action{ | ||
nullifier: String, | ||
rk: String, | ||
cmx: String, | ||
out_ciphertext:String, | ||
ephemeral_key:String, | ||
enc_ciphertext:String, | ||
cv: String, | ||
spend_auth_sig: String, | ||
} | ||
|
||
impl From<&oAction<<Authorized as Authorization>::SpendAuth>> for Action { | ||
fn from(a: &oAction<<Authorized as Authorization>::SpendAuth>) -> Self { | ||
let rk:[u8; 32] = a.rk().into(); | ||
let sig :[u8; 64] = a.authorization().into(); | ||
Action{ | ||
nullifier: hex::encode(a.nullifier().to_bytes()), | ||
rk: hex::encode(rk), | ||
cmx: hex::encode(a.cmx().to_bytes()), | ||
out_ciphertext: hex::encode(a.encrypted_note().out_ciphertext), | ||
ephemeral_key: hex::encode(a.encrypted_note().epk_bytes), | ||
enc_ciphertext: hex::encode(a.encrypted_note().enc_ciphertext), | ||
cv: hex::encode(a.cv_net().to_bytes()), | ||
spend_auth_sig: hex::encode(sig), | ||
} | ||
} | ||
} | ||
|
||
impl From<&orchard::Bundle<Authorized, i64>> for Bundle { | ||
fn from(b: &orchard::Bundle<Authorized, i64>) -> Self { | ||
let sig :[u8; 64] = b.authorization().binding_signature().into(); | ||
|
||
Bundle{ | ||
actions: b.actions().iter().map(|action| Action::from(action)).collect(), | ||
flags: b.flags().to_byte(), | ||
value_balance: b.value_balance().clone(), | ||
anchor: hex::encode(b.anchor().to_bytes()), | ||
proof: hex::encode(b.authorization().proof().as_ref()), | ||
binding_sig: hex::encode(sig), | ||
} | ||
} | ||
} | ||
|
||
// impl fmt::Display for Bundle { | ||
// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
// _ = writeln!(f, "{}", hex::encode(&self.id)); | ||
// for (i, v) in self.vin.iter().enumerate() { | ||
// _ = writeln!(f, "vin{}>>>{}", i, v); | ||
// } | ||
// for (i, v) in self.vout.iter().enumerate() { | ||
// _ = writeln!(f, "vout{}>>>{}", i, v); | ||
// } | ||
// Ok(()) | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ mod wallet; | |
mod wallets; | ||
mod withdraw; | ||
mod zsend; | ||
mod bundle; | ||
|
||
fn main() { | ||
let mut c = cli::Cli { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters