Skip to content

Commit

Permalink
fix(phd): payment quote unit
Browse files Browse the repository at this point in the history
  • Loading branch information
thesimplekid committed Aug 12, 2024
1 parent 6796855 commit 55cf19d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions crates/cdk-phoenixd/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ pub enum Error {
/// Unknown invoice
#[error("Unknown invoice")]
UnknownInvoice,
/// Unsupported unit
#[error("Unit Unsupported")]
UnsupportedUnit,
/// Anyhow error
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
Expand Down
6 changes: 5 additions & 1 deletion crates/cdk-phoenixd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,18 @@ impl MintLightning for Phoenixd {
&self,
melt_quote_request: &MeltQuoteBolt11Request,
) -> Result<PaymentQuoteResponse, Self::Err> {
if CurrencyUnit::Sat != melt_quote_request.unit {
return Err(Error::UnsupportedUnit.into());
}

let invoice_amount_msat = melt_quote_request
.request
.amount_milli_satoshis()
.ok_or(Error::UnknownInvoiceAmount)?;

let amount = to_unit(
invoice_amount_msat,
&CurrencyUnit::Sat,
&CurrencyUnit::Msat,
&melt_quote_request.unit,
)?;

Expand Down

0 comments on commit 55cf19d

Please sign in to comment.