Skip to content

Commit 5b0d9df

Browse files
committed
fixup! Add support for sending to human-readable names that resolve to Bolt12 Offers
1 parent c8942c3 commit 5b0d9df

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

src/config.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ impl Default for Config {
191191
}
192192
}
193193

194-
/// Configuration options for Human-readable Names
194+
/// Configuration options for Human-Readable Names ([BIP 353]).
195+
///
196+
/// [BIP 353]: https://github.com/bitcoin/bips/blob/master/bip-0353.mediawiki
195197
#[derive(Debug, Clone)]
196198
pub struct HumanReadableNamesConfig {
197199
/// The DNS resolvers to be used for resolving Human-Readable Names.
@@ -323,6 +325,7 @@ pub(crate) fn default_user_config(config: &Config) -> UserConfig {
323325
let mut user_config = UserConfig::default();
324326
user_config.channel_handshake_limits.force_announced_channel_preference = false;
325327
user_config.manually_accept_inbound_channels = true;
328+
user_config.manually_handle_bolt12_invoices = true;
326329
user_config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx =
327330
config.anchor_channels_config.is_some();
328331

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl fmt::Display for Error {
201201
write!(f, "Failed to parse a human-readable name.")
202202
},
203203
Self::DnsResolversUnavailable => {
204-
write!(f, "The given operation failed due to `dns-resolvers` not being configured in builder.")
204+
write!(f, "The given operation failed due to DNS resolvers not being configured.")
205205
},
206206
}
207207
}

src/event.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ where
14171417
);
14181418
}
14191419
},
1420-
LdkEvent::InvoiceReceived { payment_id, invoice, context: _, responder: _ } => {
1420+
LdkEvent::InvoiceReceived { payment_id, invoice, context, responder: _ } => {
14211421
let update = PaymentDetailsUpdate {
14221422
hash: Some(Some(invoice.payment_hash())),
14231423
quantity: invoice.quantity(),
@@ -1431,6 +1431,8 @@ where
14311431
return Err(ReplayEvent());
14321432
},
14331433
};
1434+
1435+
let _ = self.channel_manager.send_payment_for_bolt12_invoice(&invoice, context.as_ref());
14341436
},
14351437
LdkEvent::ConnectionNeeded { node_id, addresses } => {
14361438
let runtime_lock = self.runtime.read().unwrap();

src/payment/bolt12.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ impl Bolt12Payment {
331331
destinations,
332332
) {
333333
Ok(()) => {
334-
log_info!(self.logger, "Initiated sending {} msats to {:?}", amount_msat, hrn);
334+
log_info!(self.logger, "Initiated sending {} msats to ₿{}@{}", amount_msat, hrn.user(), hrn.domain());
335335
let kind = PaymentKind::Bolt12Offer {
336336
hash: None,
337337
preimage: None,
@@ -352,7 +352,7 @@ impl Bolt12Payment {
352352
Ok(payment_id)
353353
},
354354
Err(()) => {
355-
log_error!(self.logger, "Failed to send payment to {:?}", hrn);
355+
log_error!(self.logger, "Failed to send payment to ₿{}@{}", hrn.user(), hrn.domain());
356356
let kind = PaymentKind::Bolt12Offer {
357357
hash: None,
358358
preimage: None,

src/payment/store.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,10 @@ pub enum PaymentKind {
404404
/// The secret used by the payment.
405405
secret: Option<PaymentSecret>,
406406
/// The ID of the offer this payment is for.
407+
///
408+
/// This will be set to `None` when sending payments to Human-Readable Names ([BIP 353]).
409+
///
410+
/// [BIP 353]: https://github.com/bitcoin/bips/blob/master/bip-0353.mediawiki
407411
offer_id: Option<OfferId>,
408412
/// The payer note for the payment.
409413
///

0 commit comments

Comments
 (0)