//! Nodes without channels are disconnected and connected as needed to ensure that deterministic
//! blinded paths are used.
-use bitcoin::network::constants::Network;
+use bitcoin::network::Network;
+use bitcoin::secp256k1::PublicKey;
use core::time::Duration;
use crate::blinded_path::{BlindedPath, IntroductionNode};
use crate::blinded_path::payment::{Bolt12OfferContext, Bolt12RefundContext, PaymentContext};
}
}
+fn resolve_introduction_node<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, path: &BlindedPath) -> PublicKey {
+ path.public_introduction_node_id(&node.network_graph.read_only())
+ .and_then(|node_id| node_id.as_pubkey().ok())
+ .unwrap()
+}
+
fn route_bolt12_payment<'a, 'b, 'c>(
node: &Node<'a, 'b, 'c>, path: &[&Node<'a, 'b, 'c>], invoice: &Bolt12Invoice
) {
assert_ne!(offer.signing_pubkey(), Some(bob_id));
assert!(!offer.paths().is_empty());
for path in offer.paths() {
- assert_ne!(path.introduction_node, IntroductionNode::NodeId(bob_id));
- assert_ne!(path.introduction_node, IntroductionNode::NodeId(charlie_id));
+ let introduction_node_id = resolve_introduction_node(david, &path);
+ assert_ne!(introduction_node_id, bob_id);
+ assert_ne!(introduction_node_id, charlie_id);
}
// Use a one-hop blinded path when Bob is announced and all his peers are Tor-only.
assert_ne!(offer.signing_pubkey(), Some(bob_id));
assert!(!offer.paths().is_empty());
for path in offer.paths() {
- assert_eq!(path.introduction_node, IntroductionNode::NodeId(bob_id));
+ let introduction_node_id = resolve_introduction_node(david, &path);
+ assert_eq!(introduction_node_id, bob_id);
}
}
assert_ne!(offer.signing_pubkey(), Some(bob_id));
assert!(!offer.paths().is_empty());
for path in offer.paths() {
- assert_eq!(path.introduction_node, IntroductionNode::NodeId(nodes[4].node.get_our_node_id()));
+ let introduction_node_id = resolve_introduction_node(david, &path);
+ assert_eq!(introduction_node_id, nodes[4].node.get_our_node_id());
}
}
assert_ne!(offer.signing_pubkey(), Some(alice_id));
assert!(!offer.paths().is_empty());
for path in offer.paths() {
- assert_eq!(path.introduction_node, IntroductionNode::NodeId(bob_id));
+ let introduction_node_id = resolve_introduction_node(david, &path);
+ assert_eq!(introduction_node_id, bob_id);
+ assert!(matches!(path.introduction_node, IntroductionNode::DirectedShortChannelId(..)));
}
let payment_id = PaymentId([1; 32]);
assert_ne!(refund.payer_id(), david_id);
assert!(!refund.paths().is_empty());
for path in refund.paths() {
- assert_eq!(path.introduction_node, IntroductionNode::NodeId(charlie_id));
+ let introduction_node_id = resolve_introduction_node(alice, &path);
+ assert_eq!(introduction_node_id, charlie_id);
+ assert!(matches!(path.introduction_node, IntroductionNode::DirectedShortChannelId(..)));
}
expect_recent_payment!(david, RecentPaymentDetails::AwaitingInvoice, payment_id);
assert_ne!(offer.signing_pubkey(), Some(alice_id));
assert!(!offer.paths().is_empty());
for path in offer.paths() {
- assert_eq!(path.introduction_node, IntroductionNode::NodeId(alice_id));
+ let introduction_node_id = resolve_introduction_node(bob, &path);
+ assert_eq!(introduction_node_id, alice_id);
+ assert!(matches!(path.introduction_node, IntroductionNode::DirectedShortChannelId(..)));
}
let payment_id = PaymentId([1; 32]);
assert_ne!(refund.payer_id(), bob_id);
assert!(!refund.paths().is_empty());
for path in refund.paths() {
- assert_eq!(path.introduction_node, IntroductionNode::NodeId(bob_id));
+ let introduction_node_id = resolve_introduction_node(alice, &path);
+ assert_eq!(introduction_node_id, bob_id);
+ assert!(matches!(path.introduction_node, IntroductionNode::DirectedShortChannelId(..)));
}
expect_recent_payment!(bob, RecentPaymentDetails::AwaitingInvoice, payment_id);