.build().unwrap();
assert_eq!(refund.amount_msats(), 10_000_000);
assert_eq!(refund.absolute_expiry(), Some(absolute_expiry));
- assert_ne!(refund.payer_id(), david_id);
+ assert_ne!(refund.payer_signing_pubkey(), david_id);
assert!(!refund.paths().is_empty());
for path in refund.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
.build().unwrap();
assert_eq!(refund.amount_msats(), 10_000_000);
assert_eq!(refund.absolute_expiry(), Some(absolute_expiry));
- assert_ne!(refund.payer_id(), bob_id);
+ assert_ne!(refund.payer_signing_pubkey(), bob_id);
assert!(!refund.paths().is_empty());
for path in refund.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
.unwrap()
.clear_paths()
.build().unwrap();
- assert_eq!(refund.payer_id(), bob_id);
+ assert_eq!(refund.payer_signing_pubkey(), bob_id);
assert!(refund.paths().is_empty());
expect_recent_payment!(bob, RecentPaymentDetails::AwaitingInvoice, payment_id);
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
.unwrap()
.build().unwrap();
- assert_ne!(refund.payer_id(), alice_id);
+ assert_ne!(refund.payer_signing_pubkey(), alice_id);
for path in refund.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
}
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
.unwrap()
.build().unwrap();
- assert_ne!(refund.payer_id(), bob_id);
+ assert_ne!(refund.payer_signing_pubkey(), bob_id);
assert!(!refund.paths().is_empty());
for path in refund.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(alice_id));
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
.unwrap()
.build().unwrap();
- assert_ne!(refund.payer_id(), david_id);
+ assert_ne!(refund.payer_signing_pubkey(), david_id);
assert!(!refund.paths().is_empty());
for path in refund.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
.create_refund_builder(10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
.unwrap()
.build().unwrap();
- assert_ne!(refund.payer_id(), david_id);
+ assert_ne!(refund.payer_signing_pubkey(), david_id);
assert!(!refund.paths().is_empty());
for path in refund.paths() {
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(charlie_id));
}
macro_rules! refund_explicit_metadata_builder_methods { () => {
- /// Creates a new builder for a refund using the [`Refund::payer_id`] for the public node id to
- /// send to if no [`Refund::paths`] are set. Otherwise, it may be a transient pubkey.
+ /// Creates a new builder for a refund using the `signing_pubkey` for the public node id to send
+ /// to if no [`Refund::paths`] are set. Otherwise, `signing_pubkey` may be a transient pubkey.
///
/// Additionally, sets the required (empty) [`Refund::description`], [`Refund::payer_metadata`],
/// and [`Refund::amount_msats`].
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
/// [`ChannelManager::create_refund_builder`]: crate::ln::channelmanager::ChannelManager::create_refund_builder
pub fn new(
- metadata: Vec<u8>, payer_id: PublicKey, amount_msats: u64
+ metadata: Vec<u8>, signing_pubkey: PublicKey, amount_msats: u64
) -> Result<Self, Bolt12SemanticError> {
if amount_msats > MAX_VALUE_MSAT {
return Err(Bolt12SemanticError::InvalidAmount);
refund: RefundContents {
payer: PayerContents(metadata), description: String::new(), absolute_expiry: None,
issuer: None, chain: None, amount_msats, features: InvoiceRequestFeatures::empty(),
- quantity: None, payer_id, payer_note: None, paths: None,
+ quantity: None, payer_signing_pubkey: signing_pubkey, payer_note: None, paths: None,
},
secp_ctx: None,
})
/// [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata
/// [`Bolt12Invoice::verify_using_payer_data`]: crate::offers::invoice::Bolt12Invoice::verify_using_payer_data
/// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
- pub fn deriving_payer_id(
+ pub fn deriving_signing_pubkey(
node_id: PublicKey, expanded_key: &ExpandedKey, nonce: Nonce,
secp_ctx: &'a Secp256k1<$secp_context>, amount_msats: u64, payment_id: PaymentId
) -> Result<Self, Bolt12SemanticError> {
refund: RefundContents {
payer: PayerContents(metadata), description: String::new(), absolute_expiry: None,
issuer: None, chain: None, amount_msats, features: InvoiceRequestFeatures::empty(),
- quantity: None, payer_id: node_id, payer_note: None, paths: None,
+ quantity: None, payer_signing_pubkey: node_id, payer_note: None, paths: None,
},
secp_ctx: Some(secp_ctx),
})
}
/// Adds a blinded path to [`Refund::paths`]. Must include at least one path if only connected
- /// by private channels or if [`Refund::payer_id`] is not a public node id.
+ /// by private channels or if [`Refund::payer_signing_pubkey`] is not a public node id.
///
/// Successive calls to this method will add another blinded path. Caller is responsible for not
/// adding duplicate paths.
metadata.derive_from(iv_bytes, tlv_stream, $self.secp_ctx);
metadata = derived_metadata;
if let Some(keys) = keys {
- $self.refund.payer_id = keys.public_key();
+ $self.refund.payer_signing_pubkey = keys.public_key();
}
$self.refund.payer.0 = metadata;
amount_msats: u64,
features: InvoiceRequestFeatures,
quantity: Option<u64>,
- payer_id: PublicKey,
+ payer_signing_pubkey: PublicKey,
payer_note: Option<String>,
paths: Option<Vec<BlindedMessagePath>>,
}
}
/// An unpredictable series of bytes, typically containing information about the derivation of
- /// [`payer_id`].
+ /// [`payer_signing_pubkey`].
///
- /// [`payer_id`]: Self::payer_id
+ /// [`payer_signing_pubkey`]: Self::payer_signing_pubkey
pub fn payer_metadata(&self) -> &[u8] {
self.contents.metadata()
}
/// transient pubkey.
///
/// [`paths`]: Self::paths
- pub fn payer_id(&self) -> PublicKey {
- self.contents.payer_id()
+ pub fn payer_signing_pubkey(&self) -> PublicKey {
+ self.contents.payer_signing_pubkey()
}
/// Payer provided note to include in the invoice.
/// transient pubkey.
///
/// [`paths`]: Self::paths
- pub fn payer_id(&self) -> PublicKey {
- self.payer_id
+ pub fn payer_signing_pubkey(&self) -> PublicKey {
+ self.payer_signing_pubkey
}
/// Payer provided note to include in the invoice.
amount: Some(self.amount_msats),
features,
quantity: self.quantity,
- payer_id: Some(&self.payer_id),
+ payer_id: Some(&self.payer_signing_pubkey),
payer_note: self.payer_note.as_ref(),
paths: self.paths.as_ref(),
};
let features = features.unwrap_or_else(InvoiceRequestFeatures::empty);
- let payer_id = match payer_id {
+ let payer_signing_pubkey = match payer_id {
None => return Err(Bolt12SemanticError::MissingPayerSigningPubkey),
Some(payer_id) => payer_id,
};
Ok(RefundContents {
payer, description, absolute_expiry, issuer, chain, amount_msats, features, quantity,
- payer_id, payer_note, paths,
+ payer_signing_pubkey, payer_note, paths,
})
}
}
assert_eq!(refund.chain(), ChainHash::using_genesis_block(Network::Bitcoin));
assert_eq!(refund.amount_msats(), 1000);
assert_eq!(refund.features(), &InvoiceRequestFeatures::empty());
- assert_eq!(refund.payer_id(), payer_pubkey());
+ assert_eq!(refund.payer_signing_pubkey(), payer_pubkey());
assert_eq!(refund.payer_note(), None);
assert_eq!(
let payment_id = PaymentId([1; 32]);
let refund = RefundBuilder
- ::deriving_payer_id(node_id, &expanded_key, nonce, &secp_ctx, 1000, payment_id)
+ ::deriving_signing_pubkey(node_id, &expanded_key, nonce, &secp_ctx, 1000, payment_id)
.unwrap()
.build().unwrap();
- assert_eq!(refund.payer_id(), node_id);
+ assert_eq!(refund.payer_signing_pubkey(), node_id);
// Fails verification with altered fields
let invoice = refund
}
#[test]
- fn builds_refund_with_derived_payer_id() {
+ fn builds_refund_with_derived_signing_pubkey() {
let node_id = payer_pubkey();
let expanded_key = ExpandedKey::new(&KeyMaterial([42; 32]));
let entropy = FixedEntropy {};
);
let refund = RefundBuilder
- ::deriving_payer_id(node_id, &expanded_key, nonce, &secp_ctx, 1000, payment_id)
+ ::deriving_signing_pubkey(node_id, &expanded_key, nonce, &secp_ctx, 1000, payment_id)
.unwrap()
.path(blinded_path)
.build().unwrap();
- assert_ne!(refund.payer_id(), node_id);
+ assert_ne!(refund.payer_signing_pubkey(), node_id);
let invoice = refund
.respond_with_no_std(payment_paths(), payment_hash(), recipient_pubkey(), now())
.build()
.unwrap();
let (_, _, invoice_request_tlv_stream) = refund.as_tlv_stream();
- assert_eq!(refund.payer_id(), pubkey(42));
+ assert_eq!(refund.payer_signing_pubkey(), pubkey(42));
assert_eq!(refund.paths(), paths.as_slice());
assert_ne!(pubkey(42), pubkey(44));
assert_eq!(invoice_request_tlv_stream.payer_id, Some(&pubkey(42)));