Skip to content

Commit c8b57fe

Browse files
feat: Add Bolt11Invoice interface and wrapper implementation for FFI bindings
- Convert Bolt11Invoice from string type to full interface in UDL - Define required Bolt11Invoice methods in the UDL interface (expiry_time_seconds, min_final_cltv_expiry_delta, amount_milli_satoshis, is_expired, etc.) - Create Bolt11Invoice struct in uniffi_types.rs to wrap LdkBolt11Invoice - Implement methods required by the UDL interface - Add From/Into implementations for conversion between wrapper and LDK types - Add tests for the wrapper struct
1 parent 1525255 commit c8b57fe

File tree

2 files changed

+354
-26
lines changed

2 files changed

+354
-26
lines changed

bindings/ldk_node.udl

+39-3
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,45 @@ dictionary NodeAnnouncementInfo {
698698
sequence<SocketAddress> addresses;
699699
};
700700

701+
enum Currency {
702+
"Bitcoin",
703+
"BitcoinTestnet",
704+
"Regtest",
705+
"Simnet",
706+
"Signet",
707+
};
708+
709+
dictionary RouteHintHop {
710+
PublicKey src_node_id;
711+
u64 short_channel_id;
712+
u16 cltv_expiry_delta;
713+
u64? htlc_minimum_msat;
714+
u64? htlc_maximum_msat;
715+
RoutingFees fees;
716+
};
717+
718+
interface Bolt11Invoice {
719+
[Throws=NodeError, Name=from_str]
720+
constructor([ByRef] string invoice_str);
721+
sequence<u8> signable_hash();
722+
u64 expiry_time_seconds();
723+
u64 min_final_cltv_expiry_delta();
724+
u64? amount_milli_satoshis();
725+
boolean is_expired();
726+
u64 seconds_since_epoch();
727+
boolean would_expire(u64 at_time_seconds);
728+
u64 seconds_until_expiry();
729+
PaymentHash payment_hash();
730+
u64 timestamp_seconds();
731+
Currency currency();
732+
PaymentSecret payment_secret();
733+
Bolt11InvoiceDescription description();
734+
sequence<Address> fallback_addresses();
735+
sequence<sequence<RouteHintHop>> route_hints();
736+
PublicKey recover_payee_pub_key();
737+
Network network();
738+
};
739+
701740
[Custom]
702741
typedef string Txid;
703742

@@ -716,9 +755,6 @@ typedef string NodeId;
716755
[Custom]
717756
typedef string Address;
718757

719-
[Custom]
720-
typedef string Bolt11Invoice;
721-
722758
[Custom]
723759
typedef string Offer;
724760

0 commit comments

Comments
 (0)