chain: move amount to a top-level module.
This commit is contained in:
parent
cee7d0b8eb
commit
a35604aef3
|
|
@ -1,4 +1,5 @@
|
||||||
//! Module of types for working with validated zatoshi Amounts
|
//! Strongly-typed zatoshi amounts that prevent under/overflows.
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
convert::{TryFrom, TryInto},
|
convert::{TryFrom, TryInto},
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
|
|
@ -13,11 +13,11 @@ use bitvec::prelude::*;
|
||||||
use rand_core::{CryptoRng, RngCore};
|
use rand_core::{CryptoRng, RngCore};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
amount::{Amount, NonNegative},
|
||||||
keys::sapling::{find_group_hash, Diversifier, TransmissionKey},
|
keys::sapling::{find_group_hash, Diversifier, TransmissionKey},
|
||||||
serialization::{
|
serialization::{
|
||||||
serde_helpers, ReadZcashExt, SerializationError, ZcashDeserialize, ZcashSerialize,
|
serde_helpers, ReadZcashExt, SerializationError, ZcashDeserialize, ZcashSerialize,
|
||||||
},
|
},
|
||||||
types::amount::{Amount, NonNegative},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use pedersen_hashes::*;
|
use pedersen_hashes::*;
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ extern crate serde;
|
||||||
mod merkle_tree;
|
mod merkle_tree;
|
||||||
|
|
||||||
pub mod addresses;
|
pub mod addresses;
|
||||||
|
pub mod amount;
|
||||||
pub mod block;
|
pub mod block;
|
||||||
pub mod commitments;
|
pub mod commitments;
|
||||||
pub mod equihash_solution;
|
pub mod equihash_solution;
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,10 @@ mod ciphertexts;
|
||||||
mod nullifiers;
|
mod nullifiers;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
amount::{Amount, NonNegative},
|
||||||
commitments::sapling::CommitmentRandomness,
|
commitments::sapling::CommitmentRandomness,
|
||||||
keys::sapling::{Diversifier, TransmissionKey},
|
keys::sapling::{Diversifier, TransmissionKey},
|
||||||
notes::memo::Memo,
|
notes::memo::Memo,
|
||||||
types::amount::{Amount, NonNegative},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use ciphertexts::{EncryptedCiphertext, OutCiphertext};
|
pub use ciphertexts::{EncryptedCiphertext, OutCiphertext};
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,10 @@ mod ciphertexts;
|
||||||
mod nullifiers;
|
mod nullifiers;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
amount::{Amount, NonNegative},
|
||||||
commitments::sprout::CommitmentRandomness,
|
commitments::sprout::CommitmentRandomness,
|
||||||
keys::sprout::PayingKey,
|
keys::sprout::PayingKey,
|
||||||
notes::memo::Memo,
|
notes::memo::Memo,
|
||||||
types::amount::{Amount, NonNegative},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use ciphertexts::EncryptedCiphertext;
|
pub use ciphertexts::EncryptedCiphertext;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,6 @@ pub enum SerializationError {
|
||||||
Amount {
|
Amount {
|
||||||
/// The source error indicating how the num failed to validate
|
/// The source error indicating how the num failed to validate
|
||||||
#[from]
|
#[from]
|
||||||
source: crate::types::amount::Error,
|
source: crate::amount::Error,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,9 @@ pub use joinsplit::{JoinSplit, JoinSplitData};
|
||||||
pub use shielded_data::{Output, ShieldedData, Spend};
|
pub use shielded_data::{Output, ShieldedData, Spend};
|
||||||
pub use transparent::{CoinbaseData, OutPoint, TransparentInput, TransparentOutput};
|
pub use transparent::{CoinbaseData, OutPoint, TransparentInput, TransparentOutput};
|
||||||
|
|
||||||
|
use crate::amount::Amount;
|
||||||
use crate::proofs::{Bctv14Proof, Groth16Proof};
|
use crate::proofs::{Bctv14Proof, Groth16Proof};
|
||||||
use crate::types::{amount::Amount, BlockHeight, LockTime};
|
use crate::types::{BlockHeight, LockTime};
|
||||||
|
|
||||||
/// A Zcash transaction.
|
/// A Zcash transaction.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
amount::{Amount, NonNegative},
|
||||||
ed25519_zebra,
|
ed25519_zebra,
|
||||||
notes::sprout,
|
notes::sprout,
|
||||||
proofs::ZkSnarkProof,
|
proofs::ZkSnarkProof,
|
||||||
treestate,
|
treestate,
|
||||||
types::amount::{Amount, NonNegative},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A _JoinSplit Description_, as described in [protocol specification §7.2][ps].
|
/// A _JoinSplit Description_, as described in [protocol specification §7.2][ps].
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
|
amount::{Amount, NonNegative},
|
||||||
commitments, keys,
|
commitments, keys,
|
||||||
notes::{sapling, sprout},
|
notes::{sapling, sprout},
|
||||||
proofs::{Groth16Proof, ZkSnarkProof},
|
proofs::{Groth16Proof, ZkSnarkProof},
|
||||||
|
|
@ -7,10 +8,7 @@ use crate::{
|
||||||
TransparentInput,
|
TransparentInput,
|
||||||
},
|
},
|
||||||
treestate::{self, note_commitment_tree::SaplingNoteTreeRootHash},
|
treestate::{self, note_commitment_tree::SaplingNoteTreeRootHash},
|
||||||
types::{
|
types::{BlockHeight, Script},
|
||||||
amount::{Amount, NonNegative},
|
|
||||||
BlockHeight, Script,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
use futures::future::Either;
|
use futures::future::Either;
|
||||||
use proptest::{array, collection::vec, prelude::*};
|
use proptest::{array, collection::vec, prelude::*};
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use proptest_derive::Arbitrary;
|
use proptest_derive::Arbitrary;
|
||||||
|
|
||||||
use crate::types::{
|
use crate::{
|
||||||
amount::{Amount, NonNegative},
|
amount::{Amount, NonNegative},
|
||||||
BlockHeight, Script,
|
types::{BlockHeight, Script},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::TransactionHash;
|
use super::TransactionHash;
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,6 @@ use std::{
|
||||||
io::{self, Read},
|
io::{self, Read},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod amount;
|
|
||||||
|
|
||||||
/// A u32 which represents a block height value.
|
/// A u32 which represents a block height value.
|
||||||
///
|
///
|
||||||
/// # Invariants
|
/// # Invariants
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue