mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-02-21 07:09:51 -05:00
Add more error cases
This commit is contained in:
parent
949dbcaed2
commit
07dd12abf6
@ -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!()
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user