Add more error cases

This commit is contained in:
Thomas Eizinger 2021-05-17 19:32:02 +10:00
parent 949dbcaed2
commit 07dd12abf6
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96

View File

@ -8,19 +8,22 @@ use rand::{CryptoRng, RngCore};
pub struct EmptyTransaction {}
impl EmptyTransaction {
pub fn spend_from(input: OwnedTxOut<'_>, global_output_index: u64) -> InputAdded {
// TODO: Need to validate that given index matches with tx pubkey and commitment
pub fn spend_from(input: OwnedTxOut<'_>, global_output_index: u64) -> Result<InputAdded, MissingOpening> {
todo!()
}
}
pub struct MissingOpening; // The opening was missing from the TX
pub struct InputAdded {}
impl InputAdded {
pub fn with_static_decoy_inputs(self, decoys: [DecoyInput; 10]) -> DecoyOffsetsAdded {
pub fn with_decoys(self, decoys: [DecoyInput; 10]) -> Result<DecoyOffsetsAdded, DuplicateIndex> {
todo!()
}
pub fn with_random_decoy_inputs(
pub fn with_random_decoys(
self,
rng: &mut impl RngCore,
client: &(impl FetchDecoyInputs + CalculateKeyOffsetBoundaries),
@ -32,11 +35,13 @@ impl InputAdded {
self,
decoy_indices: [u64; 10],
client: &(impl FetchDecoyInputs),
) -> DecoyOffsetsAdded {
) -> Result<DecoyOffsetsAdded, DuplicateIndex> {
todo!()
}
}
pub struct DuplicateIndex; // One of the indices was an evil twin
pub struct DecoyOffsetsAdded {}
impl DecoyOffsetsAdded {
@ -45,11 +50,13 @@ impl DecoyOffsetsAdded {
to: Address,
amount: u64,
rng: &mut (impl RngCore + CryptoRng),
) -> OutputsAdded {
) -> Result<OutputsAdded, InsufficientFunds> {
todo!()
}
}
pub struct InsufficientFunds;
pub struct OutputsAdded {}
impl OutputsAdded {
@ -58,7 +65,7 @@ impl OutputsAdded {
to: Address,
amount: u64,
rng: &mut (impl RngCore + CryptoRng),
) -> Self {
) -> Result<Self, InsufficientFunds> {
todo!()
}