Skip to content

Commit 18699d3

Browse files
committed
Migrate payment interfaces to UniFFI proc-macro export
Migrate `Bolt11Payment`, `Bolt12Payment`, `SpontaneousPayment`, `OnchainPayment`, and `UnifiedPayment` from UDL interface definitions to UniFFI proc-macro export. For each payment struct, split the impl block so that `pub(crate)` and private helper methods remain in a plain impl block while all `pub fn` methods are placed in a `#[cfg_attr(feature = "uniffi", uniffi::export)]` impl block. For `Bolt12Payment`, the cfg-gated `set_paths_to_static_invoice_server` and `blinded_paths_for_async_recipient` methods are placed in separate `#[cfg(not(feature = "uniffi"))]` and `#[cfg(feature = "uniffi")] #[uniffi::export]` impl blocks to avoid proc-macro conflicts. Replace the full interface definitions in the UDL with `typedef interface` one-liners and remove the now-unused `UnifiedPaymentResult` re-export from `ffi/types.rs`. This commit was made with assistance from an AI tool (Claude Code). Co-Authored-By: HAL 9000
1 parent d022459 commit 18699d3

File tree

7 files changed

+345
-412
lines changed

7 files changed

+345
-412
lines changed

bindings/ldk_node.udl

Lines changed: 5 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -138,81 +138,13 @@ interface Node {
138138

139139
typedef enum Bolt11InvoiceDescription;
140140

141-
interface Bolt11Payment {
142-
[Throws=NodeError]
143-
PaymentId send([ByRef]Bolt11Invoice invoice, RouteParametersConfig? route_parameters);
144-
[Throws=NodeError]
145-
PaymentId send_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat, RouteParametersConfig? route_parameters);
146-
[Throws=NodeError]
147-
void send_probes([ByRef]Bolt11Invoice invoice, RouteParametersConfig? route_parameters);
148-
[Throws=NodeError]
149-
void send_probes_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat, RouteParametersConfig? route_parameters);
150-
[Throws=NodeError]
151-
void claim_for_hash(PaymentHash payment_hash, u64 claimable_amount_msat, PaymentPreimage preimage);
152-
[Throws=NodeError]
153-
void fail_for_hash(PaymentHash payment_hash);
154-
[Throws=NodeError]
155-
Bolt11Invoice receive(u64 amount_msat, [ByRef]Bolt11InvoiceDescription description, u32 expiry_secs);
156-
[Throws=NodeError]
157-
Bolt11Invoice receive_for_hash(u64 amount_msat, [ByRef]Bolt11InvoiceDescription description, u32 expiry_secs, PaymentHash payment_hash);
158-
[Throws=NodeError]
159-
Bolt11Invoice receive_variable_amount([ByRef]Bolt11InvoiceDescription description, u32 expiry_secs);
160-
[Throws=NodeError]
161-
Bolt11Invoice receive_variable_amount_for_hash([ByRef]Bolt11InvoiceDescription description, u32 expiry_secs, PaymentHash payment_hash);
162-
[Throws=NodeError]
163-
Bolt11Invoice receive_via_jit_channel(u64 amount_msat, [ByRef]Bolt11InvoiceDescription description, u32 expiry_secs, u64? max_lsp_fee_limit_msat);
164-
[Throws=NodeError]
165-
Bolt11Invoice receive_via_jit_channel_for_hash(u64 amount_msat, [ByRef]Bolt11InvoiceDescription description, u32 expiry_secs, u64? max_lsp_fee_limit_msat, PaymentHash payment_hash);
166-
[Throws=NodeError]
167-
Bolt11Invoice receive_variable_amount_via_jit_channel([ByRef]Bolt11InvoiceDescription description, u32 expiry_secs, u64? max_proportional_lsp_fee_limit_ppm_msat);
168-
[Throws=NodeError]
169-
Bolt11Invoice receive_variable_amount_via_jit_channel_for_hash([ByRef]Bolt11InvoiceDescription description, u32 expiry_secs, u64? max_proportional_lsp_fee_limit_ppm_msat, PaymentHash payment_hash);
170-
};
141+
typedef interface Bolt11Payment;
171142

172-
interface Bolt12Payment {
173-
[Throws=NodeError]
174-
PaymentId send([ByRef]Offer offer, u64? quantity, string? payer_note, RouteParametersConfig? route_parameters);
175-
[Throws=NodeError]
176-
PaymentId send_using_amount([ByRef]Offer offer, u64 amount_msat, u64? quantity, string? payer_note, RouteParametersConfig? route_parameters);
177-
[Throws=NodeError]
178-
Offer receive(u64 amount_msat, [ByRef]string description, u32? expiry_secs, u64? quantity);
179-
[Throws=NodeError]
180-
Offer receive_variable_amount([ByRef]string description, u32? expiry_secs);
181-
[Throws=NodeError]
182-
Bolt12Invoice request_refund_payment([ByRef]Refund refund);
183-
[Throws=NodeError]
184-
Refund initiate_refund(u64 amount_msat, u32 expiry_secs, u64? quantity, string? payer_note, RouteParametersConfig? route_parameters);
185-
[Throws=NodeError]
186-
Offer receive_async();
187-
[Throws=NodeError]
188-
void set_paths_to_static_invoice_server(bytes paths);
189-
[Throws=NodeError]
190-
bytes blinded_paths_for_async_recipient(bytes recipient_id);
191-
};
143+
typedef interface Bolt12Payment;
192144

193-
interface SpontaneousPayment {
194-
[Throws=NodeError]
195-
PaymentId send(u64 amount_msat, PublicKey node_id, RouteParametersConfig? route_parameters);
196-
[Throws=NodeError]
197-
PaymentId send_with_custom_tlvs(u64 amount_msat, PublicKey node_id, RouteParametersConfig? route_parameters, sequence<CustomTlvRecord> custom_tlvs);
198-
[Throws=NodeError]
199-
PaymentId send_with_preimage(u64 amount_msat, PublicKey node_id, PaymentPreimage preimage, RouteParametersConfig? route_parameters);
200-
[Throws=NodeError]
201-
PaymentId send_with_preimage_and_custom_tlvs(u64 amount_msat, PublicKey node_id, sequence<CustomTlvRecord> custom_tlvs, PaymentPreimage preimage, RouteParametersConfig? route_parameters);
202-
[Throws=NodeError]
203-
void send_probes(u64 amount_msat, PublicKey node_id);
204-
};
145+
typedef interface SpontaneousPayment;
205146

206-
interface OnchainPayment {
207-
[Throws=NodeError]
208-
Address new_address();
209-
[Throws=NodeError]
210-
Txid send_to_address([ByRef]Address address, u64 amount_sats, FeeRate? fee_rate);
211-
[Throws=NodeError]
212-
Txid send_all_to_address([ByRef]Address address, boolean retain_reserve, FeeRate? fee_rate);
213-
[Throws=NodeError]
214-
Txid bump_fee_rbf(PaymentId payment_id, FeeRate? fee_rate);
215-
};
147+
typedef interface OnchainPayment;
216148

217149
[Remote]
218150
interface FeeRate {
@@ -225,12 +157,7 @@ interface FeeRate {
225157
u64 to_sat_per_vb_ceil();
226158
};
227159

228-
interface UnifiedPayment {
229-
[Throws=NodeError]
230-
string receive(u64 amount_sats, [ByRef]string message, u32 expiry_sec);
231-
[Throws=NodeError, Async]
232-
UnifiedPaymentResult send([ByRef]string uri_str, u64? amount_msat, RouteParametersConfig? route_parameters);
233-
};
160+
typedef interface UnifiedPayment;
234161

235162
typedef interface LSPS1Liquidity;
236163

src/ffi/types.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ pub use crate::entropy::{generate_entropy_mnemonic, NodeEntropy, WordCount};
143143
use crate::error::Error;
144144
pub use crate::liquidity::LSPS1OrderStatus;
145145
pub use crate::logger::{LogLevel, LogRecord, LogWriter};
146-
pub use crate::payment::UnifiedPaymentResult;
147146
use crate::{hex_utils, SocketAddress, UserChannelId};
148147

149148
uniffi::custom_type!(PublicKey, String, {

0 commit comments

Comments
 (0)