This repository was archived by the owner on Feb 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Implement BDK Database types for gloo::LocalStorage #5
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c27713e
Implement BDK Database types for gloo::LocalStorage
benthecarman 8c72f09
Fixes for cargo clippy
benthecarman 872750d
Clippy CI checks
benthecarman 26ec3bf
Final updates
benthecarman f4b9c8d
Remove clippy check
benthecarman ef8aaf9
Move storage mod into MutinyBrowserStorage
benthecarman e7de053
Update bdk to rust-bitcoin 29 version
benthecarman de5cdaf
Add rust-toolchain.toml file
benthecarman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,87 @@ | ||
use gloo_storage::errors::StorageError; | ||
use std::fmt; | ||
|
||
#[derive(Debug)] | ||
benthecarman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#[allow(dead_code)] | ||
// copied from LDK lite | ||
/// An error that possibly needs to be handled by the user. | ||
pub enum Error { | ||
/// Returned when trying to start Mutiny while it is already running. | ||
AlreadyRunning, | ||
/// Returned when trying to stop Mutiny while it is not running. | ||
NotRunning, | ||
/// The funding transaction could not be created. | ||
FundingTxCreationFailed, | ||
/// A network connection has been closed. | ||
ConnectionFailed, | ||
/// Payment of the given invoice has already been initiated. | ||
NonUniquePaymentHash, | ||
/// The given invoice is invalid. | ||
InvoiceInvalid, | ||
/// Invoice creation failed. | ||
InvoiceCreationFailed, | ||
/// No route for the given target could be found. | ||
RoutingFailed, | ||
/// A given peer info could not be parsed. | ||
PeerInfoParseFailed, | ||
/// A channel could not be opened. | ||
ChannelCreationFailed, | ||
/// A channel could not be closed. | ||
ChannelClosingFailed, | ||
/// Persistence failed. | ||
PersistenceFailed, | ||
/// A wallet operation failed. | ||
WalletOperationFailed, | ||
/// A signing operation failed. | ||
WalletSigningFailed, | ||
/// A chain access operation failed. | ||
ChainAccessFailed, | ||
} | ||
|
||
impl fmt::Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
match *self { | ||
Self::AlreadyRunning => write!(f, "Mutiny is already running."), | ||
Self::NotRunning => write!(f, "Mutiny is not running."), | ||
Self::FundingTxCreationFailed => { | ||
write!(f, "Funding transaction could not be created.") | ||
} | ||
Self::ConnectionFailed => write!(f, "Network connection closed."), | ||
Self::NonUniquePaymentHash => write!(f, "An invoice must not get payed twice."), | ||
Self::InvoiceInvalid => write!(f, "The given invoice is invalid."), | ||
Self::InvoiceCreationFailed => write!(f, "Failed to create invoice."), | ||
Self::RoutingFailed => write!(f, "Failed to find route."), | ||
Self::PeerInfoParseFailed => write!(f, "Failed to parse the given peer information."), | ||
Self::ChannelCreationFailed => write!(f, "Failed to create channel."), | ||
Self::ChannelClosingFailed => write!(f, "Failed to close channel."), | ||
Self::PersistenceFailed => write!(f, "Failed to persist data."), | ||
Self::WalletOperationFailed => write!(f, "Failed to conduct wallet operation."), | ||
Self::WalletSigningFailed => write!(f, "Failed to sign given transaction."), | ||
Self::ChainAccessFailed => write!(f, "Failed to conduct chain access operation."), | ||
} | ||
} | ||
} | ||
|
||
impl std::error::Error for Error {} | ||
|
||
impl From<bdk::Error> for Error { | ||
fn from(e: bdk::Error) -> Self { | ||
match e { | ||
bdk::Error::Signer(_) => Self::WalletSigningFailed, | ||
_ => Self::WalletOperationFailed, | ||
} | ||
} | ||
} | ||
|
||
// todo uncomment when we add esplora stuff | ||
// impl From<esplora::EsploraError> for Error { | ||
// fn from(_e: esplora::EsploraError) -> Self { | ||
// Self::ChainAccessFailed | ||
// } | ||
// } | ||
|
||
impl From<StorageError> for Error { | ||
fn from(_e: StorageError) -> Self { | ||
Self::PersistenceFailed | ||
} | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.