name_resolver = ["dnssec-prover/validation", "lightning/no-std", "hex-conservative/alloc"]
[dependencies]
-lightning = { version = "0.0.121", default-features = false }
-dnssec-prover = { version = "0.3", default-features = false }
+lightning = { version = "0.0.123", default-features = false }
+dnssec-prover = { version = "0.6", default-features = false }
tokio = { version = "1.0", default-features = false, optional = true }
hex-conservative = { version = "0.1", default-features = false, optional = true }
extern crate alloc;
extern crate core;
+#[cfg(feature = "name_resolver")]
use core::str::FromStr;
#[cfg(feature = "domain_resolver")]
use lightning::onion_message::packet::OnionMessageContents;
use lightning::util::ser::{Readable, Writeable, Writer};
use lightning::ln::msgs::DecodeError;
+#[cfg(feature = "name_resolver")]
use lightning::offers::offer::Offer;
#[cfg(any(feature = "domain_resolver", feature = "name_resolver"))]
{
const URI_PREFIX: &str = "bitcoin:";
let mut candidate_records = resolved_rrs.iter()
- .filter_map(|rr| if let RR::Txt(txt) = rr { Some(&txt.data) } else { None })
- .filter_map(|data| if let Ok(s) = core::str::from_utf8(data) { Some(s) } else { None })
+ .filter_map(|rr| if let RR::Txt(txt) = rr { Some(txt.data.as_vec()) } else { None })
+ .filter_map(|data| if let Ok(s) = String::from_utf8(data) { Some(s) } else { None })
.filter(|data_string| data_string.len() > URI_PREFIX.len())
.filter(|data_string| data_string[..URI_PREFIX.len()].eq_ignore_ascii_case(URI_PREFIX));
let txt_record =
assert!(payer.handle_custom_message(response).is_none());
offer_ref.lock().unwrap().take().unwrap();
}
+
+ #[test]
+ fn bast() {
+ let secp_ctx = Secp256k1::new();
+ let dummy_pk = PublicKey::from_slice(&[2; 33]).unwrap();
+
+ let resolver = OMDomainResolver::new("1.1.1.1:53".parse().unwrap());
+
+ let resolver_keys = KeysManager::new(&[0; 32], 42, 43);
+ let resolver_dest = Destination::Node(dummy_pk);
+ let payer_path =
+ BlindedPath::one_hop_for_message(dummy_pk, &resolver_keys, &secp_ctx).unwrap();
+ let now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs();
+ let payer = OMNameResolver::new(resolver_dest.clone(), payer_path.clone(), now as u32, 1);
+
+ let resolved_offer = Arc::new(Mutex::new(None));
+ let offer_ref = Arc::clone(&resolved_offer);
+ let resolve_offer = Box::new(move |offer| *resolved_offer.lock().unwrap() = offer);
+ payer.resolve_name("me@t-bast.xyz".to_owned(), resolve_offer).unwrap();
+ let mut msgs = payer.release_pending_custom_messages();
+ assert_eq!(msgs.len(), 1);
+
+ let msg = msgs.pop().unwrap();
+ assert_eq!(msg.destination, resolver_dest);
+ assert_eq!(msg.reply_path, Some(payer_path));
+ let response = resolver.handle_custom_message(msg.contents).unwrap();
+
+ assert!(payer.handle_custom_message(response).is_none());
+ offer_ref.lock().unwrap().take().unwrap();
+ }
}