-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from LtbLightning/send-receive
Send and Receive
- Loading branch information
Showing
15 changed files
with
1,138 additions
and
346 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
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
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,3 @@ | ||
fn main() { | ||
uniffi::generate_scaffolding("./src/pdk.udl").unwrap(); | ||
} |
This file was deleted.
Oops, something went wrong.
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,59 +1,50 @@ | ||
#[derive(Debug)] | ||
pub struct ValidationError { | ||
internal: InternalValidationError, | ||
} | ||
use std::fmt; | ||
|
||
use payjoin::bitcoin::psbt::PsbtParseError; | ||
use payjoin::receive::RequestError; | ||
|
||
impl From<InternalValidationError> for ValidationError { | ||
fn from(value: InternalValidationError) -> Self { | ||
ValidationError { internal: value } | ||
} | ||
#[derive(Debug, PartialEq, Eq)] | ||
pub enum Error { | ||
/// Error encountered during PSBT decoding from Base64 string. | ||
PsbtParseError(String), | ||
ReceiveError(String), | ||
///Error that may occur when the request from sender is malformed. | ||
///This is currently opaque type because we aren’t sure which variants will stay. You can only display it. | ||
RequestError(String), | ||
///Error that may occur when coin selection fails. | ||
SelectionError(String), | ||
///Error returned when request could not be created. | ||
///This error can currently only happen due to programmer mistake. | ||
CreateRequestError(String), | ||
PjParseError(String), | ||
UnexpectedError(String), | ||
} | ||
impl fmt::Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match self { | ||
Error::ReceiveError(e) => write!(f, "ReceiveError: {}", e), | ||
Error::RequestError(e) => write!(f, "RequestError: {}", e), | ||
Error::SelectionError(e) => write!(f, "SelectionError: {}", e), | ||
Error::CreateRequestError(e) => write!(f, "CreateRequestError: {}", e), | ||
Error::PjParseError(e) => write!(f, "PjParseError: {}", e), | ||
Error::PsbtParseError(e) => write!(f, "PsbtParseError: {}", e), | ||
Error::UnexpectedError(e) => write!(f, "UnexpectedError: {}", e), | ||
} | ||
} | ||
} | ||
impl std::error::Error for Error {} | ||
impl From<RequestError> for Error { | ||
fn from(value: RequestError) -> Self { | ||
Error::RequestError(value.to_string()) | ||
} | ||
} | ||
impl From<InputTypeError> for InternalValidationError { | ||
fn from(value: InputTypeError) -> Self { | ||
InternalValidationError::InvalidInputType(value) | ||
} | ||
impl From<PsbtParseError> for Error { | ||
fn from(value: PsbtParseError) -> Self { | ||
Error::PsbtParseError(value.to_string()) | ||
} | ||
} | ||
#[derive(Debug)] | ||
pub(crate) enum InternalValidationError { | ||
Psbt(bitcoin::psbt::PsbtParseError), | ||
Io(std::io::Error), | ||
InvalidInput, | ||
Type(InputTypeError), | ||
InvalidProposedInput(crate::psbt::PrevTxOutError), | ||
VersionsDontMatch { | ||
proposed: i32, | ||
original: i32, | ||
}, | ||
LockTimesDontMatch { | ||
proposed: LockTime, | ||
original: LockTime, | ||
}, | ||
SenderTxinSequenceChanged { | ||
proposed: Sequence, | ||
original: Sequence, | ||
}, | ||
SenderTxinContainsNonWitnessUtxo, | ||
SenderTxinContainsWitnessUtxo, | ||
SenderTxinContainsFinalScriptSig, | ||
SenderTxinContainsFinalScriptWitness, | ||
TxInContainsKeyPaths, | ||
ContainsPartialSigs, | ||
ReceiverTxinNotFinalized, | ||
ReceiverTxinMissingUtxoInfo, | ||
MixedSequence, | ||
MixedInputTypes { | ||
proposed: InputType, | ||
original: InputType, | ||
}, | ||
MissingOrShuffledInputs, | ||
TxOutContainsKeyPaths, | ||
FeeContributionExceedsMaximum, | ||
DisallowedOutputSubstitution, | ||
OutputValueDecreased, | ||
MissingOrShuffledOutputs, | ||
Inflation, | ||
AbsoluteFeeDecreased, | ||
PayeeTookContributedFee, | ||
FeeContributionPaysOutputSizeIncrease, | ||
FeeRateBelowMinimum, | ||
impl From<payjoin::Error> for Error { | ||
fn from(value: payjoin::Error) -> Self { | ||
Error::UnexpectedError(value.to_string()) | ||
} | ||
} |
Oops, something went wrong.