diff --git a/Cargo.toml b/Cargo.toml index f794de0e..228d8d65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ bitcoin = { version = "0.30.0", features=["serde"] } bitcoin_hashes = "0.12.0" hex = "0.4.3" k256 = { version = "0.13.1", features=["arithmetic"] } -lightning-invoice = { version = "0.22.0", features=["serde"] } +lightning-invoice = { version = "0.23.0", features=["serde"] } minreq = { version = "2.7.0", features = ["json-using-serde", "https"] } rand = "0.8.5" getrandom = { version = "0.2", features = ["js"] } diff --git a/src/client.rs b/src/client.rs index b6cbf1f6..6b23e688 100644 --- a/src/client.rs +++ b/src/client.rs @@ -90,10 +90,18 @@ impl Client { outputs: blinded_messages.blinded_messages, }; - Ok(minreq::post(url) + let res = minreq::post(url) .with_json(&request)? .send()? - .json::()?) + .json::()?; + + let response: Result = + serde_json::from_value(res.clone()); + + match response { + Ok(res) => Ok(res), + Err(_) => Err(Error::CustomError(res.to_string())), + } } /// Check Max expected fee [NUT-05] @@ -129,9 +137,13 @@ impl Client { .send()? .json::()?; - println!("{:?}", value); + let response: Result = + serde_json::from_value(value.clone()); - Ok(serde_json::from_value(value)?) + match response { + Ok(res) => Ok(res), + Err(_) => Err(Error::CustomError(value.to_string())), + } } /// Split Token [NUT-06]