From bd4f8968ce9589ed708f0030749fd0df0cfda62f Mon Sep 17 00:00:00 2001 From: DanGould Date: Sun, 1 Dec 2024 16:47:34 -0500 Subject: [PATCH] Clarify amount fn units --- src/uri.rs | 16 ++++++++-------- tests/bdk_integration_test.rs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/uri.rs b/src/uri.rs index c23939d..e5075c7 100644 --- a/src/uri.rs +++ b/src/uri.rs @@ -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 { - self.0.amount.map(|x| x.to_btc()) + /// Gets the amount in satoshis. + pub fn amount_sats(&self) -> Option { + self.0.amount.map(|x| x.to_sat()) } #[cfg(not(feature = "uniffi"))] pub fn check_pj_supported(&self) -> Result { @@ -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 { + /// Accepts the amount you want to receive in sats. + pub fn amount_sats(&self, amount: u64) -> Arc { let amount = payjoin::bitcoin::Amount::from_sat(amount); Arc::new(self.0.clone().amount(amount).into()) } @@ -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() } @@ -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()) diff --git a/tests/bdk_integration_test.rs b/tests/bdk_integration_test.rs index d18bac7..8a45f9b 100644 --- a/tests/bdk_integration_test.rs +++ b/tests/bdk_integration_test.rs @@ -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?;