From eaf339c4b04b160141586435c206bfc12735486a Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Tue, 25 Apr 2023 22:17:11 -0400 Subject: [PATCH] typos --- README.md | 2 +- integration_test/Cargo.toml | 2 +- integration_test/src/main.rs | 8 ++++---- src/cashu_mint.rs | 8 ++++---- src/cashu_wallet.rs | 16 ++++++++-------- src/types.rs | 4 ++-- tests/integration_test.rs | 14 +++++++------- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 26f9798d..821efc82 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Cashu Crab is a rust library for [Cashu](https://github.com/cashubtc) wallets written in Rust. Modeled after [Cashu-ts](https://github.com/cashubtc/cashu-ts. -**ALPHA** This libary is in early development and should not be seen as stable, the api will change hopefully along with the name. +**ALPHA** This library is in early development and should not be seen as stable, the api will change hopefully along with the name. ## Implemented [NUTs](https://github.com/cashubtc/nuts/): diff --git a/integration_test/Cargo.toml b/integration_test/Cargo.toml index 00732c7d..f443e9d7 100644 --- a/integration_test/Cargo.toml +++ b/integration_test/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] bitcoin = "0.30.0" -cashu-rs = {path = ".."} +cashu-crab = {path = ".."} tokio = { version = "1.28.0", features = ["full"] } url = "2.3.1" lightning-invoice = { version = "0.22.0", features=["serde"] } diff --git a/integration_test/src/main.rs b/integration_test/src/main.rs index 948c1fc4..c86e428b 100644 --- a/integration_test/src/main.rs +++ b/integration_test/src/main.rs @@ -5,9 +5,9 @@ use std::thread; use std::time::Duration; use bitcoin::Amount; -use cashu_rs::cashu_mint::CashuMint; -use cashu_rs::cashu_wallet::CashuWallet; -use cashu_rs::types::{BlindedMessages, MintKeys, ProofsStatus, Token, TokenData}; +use cashu_crab::cashu_mint::CashuMint; +use cashu_crab::cashu_wallet::CashuWallet; +use cashu_crab::types::{BlindedMessages, MintKeys, ProofsStatus, Token, TokenData}; use lightning_invoice::Invoice; use url::Url; @@ -56,7 +56,7 @@ async fn test_mint(wallet: &CashuWallet) -> String { let mint_req = wallet.request_mint(Amount::from_sat(21)).await.unwrap(); println!("Mint Req: {:?}", mint_req.pr.to_string()); - // Since before the mint happens the invoice in the mint req has to be payed this wait is here + // Since before the mint happens the invoice in the mint req has to be paid this wait is here // probally some way to simulate this in a better way // but for now pay it quick thread::sleep(Duration::from_secs(30)); diff --git a/src/cashu_mint.rs b/src/cashu_mint.rs index 59501a90..8098dd8c 100644 --- a/src/cashu_mint.rs +++ b/src/cashu_mint.rs @@ -10,7 +10,7 @@ use crate::{ error::Error, types::{ BlindedMessage, BlindedMessages, CheckFeesRequest, CheckFeesResponse, - CheckSpendableRequest, CheckSpendableResponse, MeltRequest, MeltResposne, MintInfo, + CheckSpendableRequest, CheckSpendableResponse, MeltRequest, MeltResponse, MintInfo, MintKeySets, MintKeys, MintRequest, PostMintResponse, Proof, RequestMintResponse, SplitRequest, SplitResponse, }, @@ -98,7 +98,7 @@ impl CashuMint { proofs: Vec, invoice: Invoice, outputs: Option>, - ) -> Result { + ) -> Result { let url = self.url.join("melt")?; let request = MeltRequest { @@ -110,7 +110,7 @@ impl CashuMint { Ok(minreq::post(url) .with_json(&request)? .send()? - .json::()?) + .json::()?) } /// Split Token [NUT-06] @@ -123,7 +123,7 @@ impl CashuMint { .json::()?; // TODO: need to handle response error - // specfically token already spent + // specifically token already spent println!("{:?}", res); Ok(serde_json::from_value(res).unwrap()) diff --git a/src/cashu_wallet.rs b/src/cashu_wallet.rs index 6bc4c356..61df5f2b 100644 --- a/src/cashu_wallet.rs +++ b/src/cashu_wallet.rs @@ -26,7 +26,7 @@ impl CashuWallet { pub async fn check_proofs_spent(&self, proofs: Vec) -> Result { let spendable = self.mint.check_spendable(&proofs).await?; - // Seperate proofs in spent and unspent based on mint response + // Separate proofs in spent and unspent based on mint response let (spendable, spent): (Vec<_>, Vec<_>) = proofs .iter() .zip(spendable.spendable.iter()) @@ -160,31 +160,31 @@ impl CashuWallet { /// Send pub async fn send(&self, amount: Amount, proofs: Vec) -> Result { - let mut amount_avaliable = Amount::ZERO; + let mut amount_available = Amount::ZERO; let mut send_proofs = SendProofs::default(); for proof in proofs { - if amount_avaliable > amount { + if amount_available > amount { send_proofs.change_proofs.push(proof); break; } else { - amount_avaliable += proof.amount; + amount_available += proof.amount; send_proofs.send_proofs.push(proof); } } - if amount_avaliable.lt(&amount) { + if amount_available.lt(&amount) { println!("Not enough funds"); return Err(Error::InsufficantFunds); } - // If amount avaliable is EQUAL to send amount no need to split - if amount_avaliable.eq(&amount) { + // If amount available is EQUAL to send amount no need to split + if amount_available.eq(&amount) { println!("Equal Proofs: {:#?}", send_proofs); return Ok(send_proofs); } - let amount_to_keep = amount_avaliable - amount; + let amount_to_keep = amount_available - amount; let amount_to_send = amount; let split_payload = self diff --git a/src/types.rs b/src/types.rs index 3b2efbc8..5e1f54c6 100644 --- a/src/types.rs +++ b/src/types.rs @@ -179,14 +179,14 @@ pub struct MeltRequest { /// bollt11 pub pr: Invoice, /// Blinded Message that can be used to return change [NUT-08] - /// Amount feild of blindedMessages `SHOULD` be set to zero + /// Amount field of blindedMessages `SHOULD` be set to zero pub outputs: Option>, } /// Melt Response [NUT-05] /// Lightning fee return [NUT-08] if change is defined #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub struct MeltResposne { +pub struct MeltResponse { pub paid: bool, pub preimage: String, pub change: Option, diff --git a/tests/integration_test.rs b/tests/integration_test.rs index 393c6d91..1ff02b42 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -49,7 +49,7 @@ async fn test_mint() { let mint_req = mint.request_mint(Amount::from_sat(21)).await.unwrap(); println!("Mint Req: {:?}", mint_req.pr.to_string()); - // Since before the mint happens the invoice in the mint req has to be payed this wait is here + // Since before the mint happens the invoice in the mint req has to be paid this wait is here // probally some way to simulate this in a better way // but for now pay it quick thread::sleep(Duration::from_secs(30)); @@ -80,9 +80,9 @@ async fn test_receive() { let mint_keys = mint.get_keys().await.unwrap(); let wallet = CashuWallet::new(mint, mint_keys); - // FIXME: Have to manully paste an unspent token + // FIXME: Have to manually paste an unspent token let token = - "cashuAeyJ0b2tlbiI6W3sicHJvb2ZzIjpbeyJpZCI6Im9DV2NkWXJyeVRrUiIsImFtb3VudCI6MiwiQyI6IjAyOTMwNTJhNWEwN2FjMTkxMDgyODQyZTExMDVkOTQ2MzliNWI5NmE3MTU3NTQzZTllMjdkOTg3MWU5YjE2NDJkNCIsInNlY3JldCI6IlQxZ0lYUWlpZnBNY21OMU9ENnV4Nk1rMS93bXIxU3VHU2tvVXIyTkpqZE09In1dLCJtaW50IjoiaHR0cHM6Ly9sZWdlbmQubG5iaXRzLmNvbS9jYXNodS9hcGkvdjEvU0t2SFJ1czlkbWpXSGhzdEhyc2F6VyJ9XX0="; + "cashuAeyJ0b2tlbiI6W3sicHJvb2ZzIjpbeyJpZCI6Im9DV2NkWXJyeVRrUiIsImFtb3VudCI6MiwiQyI6IjAyOTMwNTJhNWEwN2FjMTkxMDgyODQyZTExMDVkOTQ2MzliNWI5NmE3MTU3NTQzZTllMjdkOTg3MWU5YjE2ANDJkNCIsInNlY3JldCI6IlQxZ0lYUWlpZnBNY21OMU9ENnV4Nk1rMS93bXIxU3VHU2tvVXIyTkpqZE09In1dLCJtaW50IjoiaHR0cHM6Ly9sZWdlbmQubG5iaXRzLmNvbS9jYXNodS9hcGkvdjEvU0t2SFJ1czlkbWpXSGhzdEhyc2F6VyJ9XX0="; let prom = wallet.receive(token).await.unwrap(); // println!("{:?}", prom); @@ -96,7 +96,7 @@ async fn test_check_spendable() { let mint_keys = mint.get_keys().await.unwrap(); let wallet = CashuWallet::new(mint, mint_keys); - // FIXME: Have to manully paste an unspent token + // FIXME: Have to manually paste an unspent token let token = "cashuAeyJ0b2tlbiI6W3sicHJvb2ZzIjpbeyJpZCI6Im9DV2NkWXJyeVRrUiIsImFtb3VudCI6MiwiQyI6IjAyNGQ0ZDUxNWIxYzk2MWZkYzYxY2M5MDFmNzBkOGUwZDA0ZWIwYTI2MzBhNWYxYTdmM2I5ZmRhODdmMGJkNjNmNyIsInNlY3JldCI6IkVUc2pXSGJheXYyTUJQeXo1b0toay85dVdoaldIeXJkODdBQy9XY3VjbkE9In1dLCJtaW50IjoiaHR0cHM6Ly9sZWdlbmQubG5iaXRzLmNvbS9jYXNodS9hcGkvdjEvU0t2SFJ1czlkbWpXSGhzdEhyc2F6VyJ9XX0="; @@ -114,9 +114,9 @@ async fn test_split() { let mint_keys = mint.get_keys().await.unwrap(); let wallet = CashuWallet::new(mint.clone(), mint_keys); - // FIXME: Have to manully paste an unspent token + // FIXME: Have to manually paste an unspent token let token = - "cashuAeyJ0b2tlbiI6W3sicHJvb2ZzIjpbeyJpZCI6Im9DV2NkWXJyeVRrUiIsImFtb3VudCI6MiwiQyI6IjAyNDVjYjBhYzhlMWNmNGViMjk2ZjAyMTFiMDdjYTBjNTczOWM1MTMwMDEzMzM3MjczOTE1ZTVlMDY2NjZlOTBiZCIsInNlY3JldCI6ImRWNThLbU5VOWE0UU45c0QyVDd5bGkvam9qcWpwb3o0VVhkSGR6dkdRZ289In1dLCJtaW50IjoiaHR0cHM6Ly9sZWdlbmQubG5iaXRzLmNvbS9jYXNodS9hcGkvdjEvU0t2SFJ1czlkbWpXSGhzdEhyc2F6VyJ9XX0="; + "cashuAeyJ0b2tlbiI6W3sicHJvb2ZzIjpbeyJpZCI6Im9DV2NkWXJyeVRrUiIsImFtb3VudCI6MiwiQyI6IjAyANDVjYjBhYzhlMWNmNGViMjk2ZjAyMTFiMDdjYTBjNTczOWM1MTMwMDEzMzM3MjczOTE1ZTVlMDY2NjZlOTBiZCIsInNlY3JldCI6ImRWNThLbU5VOWE0UU45c0QyVDd5bGkvam9qcWpwb3o0VVhkSGR6dkdRZ289In1dLCJtaW50IjoiaHR0cHM6Ly9sZWdlbmQubG5iaXRzLmNvbS9jYXNodS9hcGkvdjEvU0t2SFJ1czlkbWpXSGhzdEhyc2F6VyJ9XX0="; let proofs = wallet.receive(token).await.unwrap(); let split = wallet.create_split(Amount::ONE_SAT, Amount::ONE_SAT, proofs).await.unwrap(); @@ -137,7 +137,7 @@ async fn test_send() { let mint_keys = mint.get_keys().await.unwrap(); let wallet = CashuWallet::new(mint, mint_keys); - // FIXME: Have to manully paste an unspent token + // FIXME: Have to manually paste an unspent token let token = "cashuAeyJ0b2tlbiI6W3sicHJvb2ZzIjpbeyJpZCI6Im9DV2NkWXJyeVRrUiIsImFtb3VudCI6MiwiQyI6IjAzMGI4NWFhYjI5MDY2MGRlNDk4NTEzODZmYTJhZWY2MTk3YzM2MzRkZDE4OGMzMjM2ZDI2YTFhNDdmODZlNzQxNCIsInNlY3JldCI6IjNET0c3eHM2T2RRYno1Nmk1c0lRQjhndHUzbjRMdjRGSU5TeEtLUkJ6UzA9In1dLCJtaW50IjoiaHR0cHM6Ly9sZWdlbmQubG5iaXRzLmNvbS9jYXNodS9hcGkvdjEvU0t2SFJ1czlkbWpXSGhzdEhyc2F6VyJ9XX0="; let prom = wallet.receive(token).await.unwrap();