Skip to content

Commit

Permalink
Clarify amount fn units
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGould committed Dec 2, 2024
1 parent c6120cc commit bd4f896
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ impl Uri {
pub fn address(&self) -> String {
self.clone().0.address.to_string()
}
///Gets the amount in satoshis.
pub fn amount(&self) -> Option<f64> {
self.0.amount.map(|x| x.to_btc())
/// Gets the amount in satoshis.
pub fn amount_sats(&self) -> Option<u64> {
self.0.amount.map(|x| x.to_sat())
}
#[cfg(not(feature = "uniffi"))]
pub fn check_pj_supported(&self) -> Result<PjUri, PayjoinError> {
Expand Down Expand Up @@ -160,8 +160,8 @@ impl PjUriBuilder {
)
.into())
}
/// Accepts the amount you want to receive in sats and sets it in btc .
pub fn amount(&self, amount: u64) -> Arc<Self> {
/// Accepts the amount you want to receive in sats.
pub fn amount_sats(&self, amount: u64) -> Arc<Self> {
let amount = payjoin::bitcoin::Amount::from_sat(amount);
Arc::new(self.0.clone().amount(amount).into())
}
Expand Down Expand Up @@ -204,8 +204,8 @@ impl PjUriBuilder {
)
.into())
}
/// Accepts the amount you want to receive in sats and sets it in btc .
pub fn amount(&self, sats: u64) -> Self {
/// Accepts the amount you want to receive in sats.
pub fn amount_sats(&self, sats: u64) -> Self {
let amount = payjoin::bitcoin::Amount::from_sat(sats);
self.0.clone().amount(amount).into()
}
Expand Down Expand Up @@ -252,7 +252,7 @@ mod tests {
)
.unwrap();
let uri = builder
.amount(amount.to_sat())
.amount_sats(amount.to_sat())
.message("message".to_string())
.pjos(true)
.label("label".to_string())
Expand Down
2 changes: 1 addition & 1 deletion tests/bdk_integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ mod v2 {
let session =
initialize_session(address.clone(), directory.clone(), ohttp_keys.clone(), None)?;
let pj_uri_string =
session.pj_uri_builder().amount(Amount::ONE_BTC.to_sat()).build().as_string();
session.pj_uri_builder().amount_sats(Amount::ONE_BTC.to_sat()).build().as_string();
// Poll receive request
let (request, client_response) = session.extract_req()?;
let response = agent.post(request.url.as_string()).body(request.body).send().await?;
Expand Down

0 comments on commit bd4f896

Please sign in to comment.