Skip to content

Commit 386f95f

Browse files
committed
Add HrnParsingFailed and HrnBolt12Offer enum variants to uniffi bindings
1 parent d939052 commit 386f95f

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

bindings/ldk_node.udl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ enum NodeError {
302302
"InsufficientFunds",
303303
"LiquiditySourceUnavailable",
304304
"LiquidityFeeTooHigh",
305+
"HrnParsingFailed",
305306
};
306307

307308
dictionary NodeStatus {
@@ -405,6 +406,7 @@ interface PaymentKind {
405406
Bolt12Offer(PaymentHash? hash, PaymentPreimage? preimage, PaymentSecret? secret, OfferId offer_id, UntrustedString? payer_note, u64? quantity);
406407
Bolt12Refund(PaymentHash? hash, PaymentPreimage? preimage, PaymentSecret? secret, UntrustedString? payer_note, u64? quantity);
407408
Spontaneous(PaymentHash hash, PaymentPreimage? preimage);
409+
HrnBolt12Offer(HumanReadableName hrn);
408410
};
409411

410412
[Enum]
@@ -763,3 +765,6 @@ typedef string OrderId;
763765

764766
[Custom]
765767
typedef string DateTime;
768+
769+
[Custom]
770+
typedef string HumanReadableName;

src/uniffi_types.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub use lightning_types::payment::{PaymentHash, PaymentPreimage, PaymentSecret};
3535

3636
pub use lightning_invoice::{Bolt11Invoice, Description};
3737

38+
pub use lightning::onion_message::dns_resolution::HumanReadableName;
3839
pub use lightning_liquidity::lsps1::msgs::ChannelInfo as ChannelOrderInfo;
3940
pub use lightning_liquidity::lsps1::msgs::{
4041
Bolt11PaymentInfo, OrderId, OrderParameters, PaymentState,
@@ -429,6 +430,18 @@ impl UniffiCustomTypeConverter for DateTime {
429430
}
430431
}
431432

433+
impl UniffiCustomTypeConverter for HumanReadableName {
434+
type Builtin = String;
435+
436+
fn into_custom(val: Self::Builtin) -> uniffi::Result<Self> {
437+
HumanReadableName::from_encoded(&val).map_err(|_| Error::HrnParsingFailed.into())
438+
}
439+
440+
fn from_custom(obj: Self) -> Self::Builtin {
441+
format!("{}@{}", obj.user(), obj.domain())
442+
}
443+
}
444+
432445
#[cfg(test)]
433446
mod tests {
434447
use super::*;

0 commit comments

Comments
 (0)