Update deps

This commit is contained in:
benthecarman
2024-01-09 19:13:50 +00:00
parent aee80a532c
commit e41b8326d8
5 changed files with 53 additions and 48 deletions

View File

@@ -16,6 +16,6 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
bitcoin-waila = { path = "../waila", version = "0.2.6" }
bitcoin = "0.29.2"
nostr = { version = "=0.23.0-bitcoin-v0.29", default-features = false, features = ["nip19"] }
bitcoin = "0.30.2"
nostr = { version = "0.26.0", default-features = false, features = ["std"] }
wasm-bindgen = "0.2.84"

View File

@@ -16,21 +16,21 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
bech32 = "0.9.1"
bitcoin = { version = "0.29.2", default-features = false, features = ["serde"] }
bip21 = "0.2.0"
bitcoin = { version = "0.30.2", default-features = false, features = ["serde"] }
bip21 = "0.3.1"
itertools = "0.12.0"
nostr = { version = "=0.23.0-bitcoin-v0.29", default-features = false, features = ["nip19", "nip47"] }
lnurl-rs = { version = "0.3", default-features = false }
lightning-invoice = { version = "0.26.0", default-features = false }
lightning = { version = "0.0.118", default-features = false }
nostr = { version = "0.26.0", default-features = false, features = ["nip47"] }
lnurl-rs = { version = "0.4.0", default-features = false }
lightning-invoice = { version = "0.27.0", default-features = false }
lightning = { version = "0.0.119", default-features = false }
rgb-std = { version = "0.10.9", optional = true }
rgb-wallet = { version = "0.10.9", optional = true }
url = "2.4.1"
[features]
default = ["std"]
std = ["bitcoin/std", "lightning-invoice/std", "lightning/std"]
no-std = ["bitcoin/no-std", "lightning-invoice/no-std", "lightning/no-std"]
std = ["bitcoin/std", "lightning-invoice/std", "lightning/std", "nostr/std"]
no-std = ["bitcoin/no-std", "lightning-invoice/no-std", "lightning/no-std", "nostr/alloc"]
rgb = ["rgb-std", "rgb-wallet"]
[package.metadata.wasm-pack.profile.release]

View File

@@ -4,11 +4,12 @@ use std::convert::TryFrom;
use ::bip21::de::*;
use ::bip21::*;
use bitcoin::address::NetworkUnchecked;
use lightning_invoice::{Bolt11Invoice, ParseOrSemanticError};
use url::Url;
/// This lets us parse `lightning` and payjoin parameters from a BIP21 URI.
pub type UnifiedUri<'a> = Uri<'a, WailaExtras>;
pub type UnifiedUri<'a> = Uri<'a, NetworkUnchecked, WailaExtras>;
#[derive(Debug, Default, Eq, PartialEq, Clone, Hash)]
pub struct WailaExtras {
@@ -116,9 +117,7 @@ mod test {
use lightning_invoice::Bolt11Invoice;
use crate::bip21::WailaExtras;
type UnifiedUri<'a> = bip21::Uri<'a, WailaExtras>;
use crate::bip21::UnifiedUri;
#[test]
fn test_ln_uri() {

View File

@@ -1,7 +1,9 @@
use bech32::Variant;
use std::convert::TryInto;
use std::str::FromStr;
use bitcoin::blockdata::constants::ChainHash;
use bitcoin::key::XOnlyPublicKey;
use bitcoin::secp256k1::PublicKey;
use bitcoin::{Address, Amount, Network};
use lightning::offers::offer;
@@ -10,11 +12,12 @@ use lightning::offers::refund::Refund;
use lightning_invoice::{Bolt11Invoice, Bolt11InvoiceDescription};
use lnurl::lightning_address::LightningAddress;
use lnurl::lnurl::LnUrl;
use nostr::prelude::*;
use nostr::FromBech32;
#[cfg(feature = "rgb")]
use rgbstd::Chain;
#[cfg(feature = "rgb")]
use rgbwallet::RgbInvoice;
use url::Url;
use crate::bip21::UnifiedUri;
use crate::nwa::NIP49URI;
@@ -92,7 +95,7 @@ impl PaymentParams<'_> {
/// Returns None if the network is unknown
pub fn valid_for_network(&self, network: Network) -> Option<bool> {
match self {
PaymentParams::OnChain(address) => Some(address.is_valid_for_network(network)),
PaymentParams::OnChain(address) => Some(address.network == network),
PaymentParams::Bip21(uri) => Some(uri.address.is_valid_for_network(network)),
PaymentParams::Bolt11(invoice) => Some(Network::from(invoice.currency()) == network),
PaymentParams::Bolt12(offer) => {
@@ -144,7 +147,7 @@ impl PaymentParams<'_> {
pub fn address(&self) -> Option<Address> {
match self {
PaymentParams::OnChain(address) => Some(address.clone()),
PaymentParams::Bip21(uri) => Some(uri.address.clone()),
PaymentParams::Bip21(uri) => Some(uri.address.clone().assume_checked()),
PaymentParams::Bolt11(invoice) => invoice.fallback_addresses().first().cloned(),
PaymentParams::Bolt12(_) => None,
PaymentParams::Bolt12Refund(_) => None,
@@ -410,7 +413,7 @@ impl FromStr for PaymentParams<'_> {
}
Address::from_str(str)
.map(PaymentParams::OnChain)
.map(|a| PaymentParams::OnChain(a.assume_checked()))
.or_else(|_| Bolt11Invoice::from_str(str).map(PaymentParams::Bolt11))
.or_else(|_| UnifiedUri::from_str(str).map(PaymentParams::Bip21))
.or_else(|_| LightningAddress::from_str(str).map(PaymentParams::LightningAddress))
@@ -463,7 +466,9 @@ mod tests {
#[test]
fn parse_address() {
let address = Address::from_str("1andreas3batLhQa2FawWjeyjCqyBzypd").unwrap();
let address = Address::from_str("1andreas3batLhQa2FawWjeyjCqyBzypd")
.unwrap()
.assume_checked();
let parsed = PaymentParams::from_str(&address.to_string()).unwrap();
assert_eq!(parsed.address(), Some(address));
@@ -486,7 +491,11 @@ mod tests {
assert_eq!(parsed.network(), Some(Network::Bitcoin));
assert_eq!(
parsed.address(),
Some(Address::from_str("1RustyRX2oai4EYYDpQGWvEL62BBGqN9T").unwrap())
Some(
Address::from_str("1RustyRX2oai4EYYDpQGWvEL62BBGqN9T")
.unwrap()
.assume_checked()
)
);
assert_eq!(parsed.memo(), None);
assert_eq!(parsed.lnurl(), None);
@@ -527,7 +536,11 @@ mod tests {
assert_eq!(parsed.network(), Some(Network::Bitcoin));
assert_eq!(
parsed.address(),
Some(Address::from_str("1RustyRX2oai4EYYDpQGWvEL62BBGqN9T").unwrap())
Some(
Address::from_str("1RustyRX2oai4EYYDpQGWvEL62BBGqN9T")
.unwrap()
.assume_checked()
)
);
assert_eq!(parsed.memo(), None);
assert_eq!(parsed.lnurl(), None);
@@ -546,7 +559,11 @@ mod tests {
assert_eq!(parsed.network(), Some(Network::Bitcoin));
assert_eq!(
parsed.address(),
Some(Address::from_str("1RustyRX2oai4EYYDpQGWvEL62BBGqN9T").unwrap())
Some(
Address::from_str("1RustyRX2oai4EYYDpQGWvEL62BBGqN9T")
.unwrap()
.assume_checked()
)
);
assert_eq!(parsed.memo(), None);
assert_eq!(parsed.lnurl(), None);
@@ -559,7 +576,11 @@ mod tests {
assert_eq!(parsed.amount(), Some(Amount::from_btc(50_f64).unwrap()));
assert_eq!(
parsed.address(),
Some(Address::from_str("1andreas3batLhQa2FawWjeyjCqyBzypd").unwrap())
Some(
Address::from_str("1andreas3batLhQa2FawWjeyjCqyBzypd")
.unwrap()
.assume_checked()
)
);
assert_eq!(parsed.memo(), Some("Donation for project xyz".to_string()));
assert_eq!(parsed.network(), Some(Network::Bitcoin));
@@ -575,7 +596,11 @@ mod tests {
assert_eq!(parsed.amount(), Some(Amount::from_btc(0.00001).unwrap()));
assert_eq!(
parsed.address(),
Some(Address::from_str("BC1QYLH3U67J673H6Y6ALV70M0PL2YZ53TZHVXGG7U").unwrap())
Some(
Address::from_str("BC1QYLH3U67J673H6Y6ALV70M0PL2YZ53TZHVXGG7U")
.unwrap()
.assume_checked()
)
);
assert_eq!(parsed.memo(), Some("For lunch Tuesday".to_string()));
assert_eq!(parsed.network(), Some(Network::Bitcoin));
@@ -602,6 +627,7 @@ mod tests {
Some(
Address::from_str("tb1p0vztr8q25czuka5u4ta5pqu0h8dxkf72mam89cpg4tg40fm8wgmqp3gv99")
.unwrap()
.assume_checked()
)
);
assert_eq!(parsed.memo(), Some("yooo".to_string()));

View File

@@ -112,26 +112,6 @@ pub struct NIP49URI {
pub identity: Option<XOnlyPublicKey>,
}
fn method_from_str(s: &str) -> Result<Method, Error> {
match s {
"pay_invoice" => Ok(Method::PayInvoice),
"make_invoice" => Ok(Method::MakeInvoice),
"lookup_invoice" => Ok(Method::LookupInvoice),
"get_balance" => Ok(Method::GetBalance),
_ => Err(Error::InvalidURI),
}
}
fn method_to_string(method: &Method) -> String {
match method {
Method::PayInvoice => "pay_invoice",
Method::MakeInvoice => "make_invoice",
Method::LookupInvoice => "lookup_invoice",
Method::GetBalance => "get_balance",
}
.to_string()
}
impl FromStr for NIP49URI {
type Err = Error;
fn from_str(uri: &str) -> Result<Self, Self::Err> {
@@ -162,13 +142,13 @@ impl FromStr for NIP49URI {
Cow::Borrowed("required_commands") => {
required_commands = value
.split(' ')
.map(method_from_str)
.map(Method::from_str)
.collect::<Result<Vec<Method>, Error>>()?;
}
Cow::Borrowed("optional_commands") => {
optional_commands = value
.split(' ')
.map(method_from_str)
.map(Method::from_str)
.collect::<Result<Vec<Method>, Error>>()?;
}
Cow::Borrowed("budget") => {
@@ -213,7 +193,7 @@ impl fmt::Display for NIP49URI {
url_encode(
self.required_commands
.iter()
.map(method_to_string)
.map(|x| x.to_string())
.join(" ")
),
)?;
@@ -224,7 +204,7 @@ impl fmt::Display for NIP49URI {
url_encode(
self.optional_commands
.iter()
.map(method_to_string)
.map(|x| x.to_string())
.join(" ")
)
)?;