Skip to content

Commit 6f1de4f

Browse files
committed
Migrate complex enums and LSPFeeLimits to UniFFI proc-macro export
Migrate `MaxDustHTLCExposure`, `ConfirmationStatus`, `PaymentKind`, `LightningBalance`, and `PendingSweepBalance` enums, as well as the `LSPFeeLimits` record, from UDL definitions to proc-macro derives. Co-Authored-By: HAL 9000
1 parent 8cb2bd3 commit 6f1de4f

5 files changed

Lines changed: 13 additions & 80 deletions

File tree

bindings/ldk_node.udl

Lines changed: 6 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -406,15 +406,7 @@ enum PaymentFailureReason {
406406
"BlindedPathCreationFailed",
407407
};
408408

409-
[Enum]
410-
interface PaymentKind {
411-
Onchain(Txid txid, ConfirmationStatus status);
412-
Bolt11(PaymentHash hash, PaymentPreimage? preimage, PaymentSecret? secret);
413-
Bolt11Jit(PaymentHash hash, PaymentPreimage? preimage, PaymentSecret? secret, u64? counterparty_skimmed_fee_msat, LSPFeeLimits lsp_fee_limits);
414-
Bolt12Offer(PaymentHash? hash, PaymentPreimage? preimage, PaymentSecret? secret, OfferId offer_id, UntrustedString? payer_note, u64? quantity);
415-
Bolt12Refund(PaymentHash? hash, PaymentPreimage? preimage, PaymentSecret? secret, UntrustedString? payer_note, u64? quantity);
416-
Spontaneous(PaymentHash hash, PaymentPreimage? preimage);
417-
};
409+
typedef enum PaymentKind;
418410

419411
[Enum]
420412
interface UnifiedPaymentResult {
@@ -427,16 +419,9 @@ typedef enum PaymentDirection;
427419

428420
typedef enum PaymentStatus;
429421

430-
dictionary LSPFeeLimits {
431-
u64? max_total_opening_fee_msat;
432-
u64? max_proportional_opening_fee_ppm_msat;
433-
};
422+
typedef dictionary LSPFeeLimits;
434423

435-
[Enum]
436-
interface ConfirmationStatus {
437-
Confirmed (BlockHash block_hash, u32 height, u64 timestamp);
438-
Unconfirmed ();
439-
};
424+
typedef enum ConfirmationStatus;
440425

441426
dictionary PaymentDetails {
442427
PaymentId id;
@@ -574,54 +559,7 @@ dictionary PeerDetails {
574559
boolean is_connected;
575560
};
576561

577-
[Enum]
578-
interface LightningBalance {
579-
ClaimableOnChannelClose (
580-
ChannelId channel_id,
581-
PublicKey counterparty_node_id,
582-
u64 amount_satoshis,
583-
u64 transaction_fee_satoshis,
584-
u64 outbound_payment_htlc_rounded_msat,
585-
u64 outbound_forwarded_htlc_rounded_msat,
586-
u64 inbound_claiming_htlc_rounded_msat,
587-
u64 inbound_htlc_rounded_msat
588-
);
589-
ClaimableAwaitingConfirmations (
590-
ChannelId channel_id,
591-
PublicKey counterparty_node_id,
592-
u64 amount_satoshis,
593-
u32 confirmation_height,
594-
BalanceSource source
595-
);
596-
ContentiousClaimable (
597-
ChannelId channel_id,
598-
PublicKey counterparty_node_id,
599-
u64 amount_satoshis,
600-
u32 timeout_height,
601-
PaymentHash payment_hash,
602-
PaymentPreimage payment_preimage
603-
);
604-
MaybeTimeoutClaimableHTLC (
605-
ChannelId channel_id,
606-
PublicKey counterparty_node_id,
607-
u64 amount_satoshis,
608-
u32 claimable_height,
609-
PaymentHash payment_hash,
610-
boolean outbound_payment
611-
);
612-
MaybePreimageClaimableHTLC (
613-
ChannelId channel_id,
614-
PublicKey counterparty_node_id,
615-
u64 amount_satoshis,
616-
u32 expiry_height,
617-
PaymentHash payment_hash
618-
);
619-
CounterpartyRevokedOutputClaimable (
620-
ChannelId channel_id,
621-
PublicKey counterparty_node_id,
622-
u64 amount_satoshis
623-
);
624-
};
562+
typedef enum LightningBalance;
625563

626564
[Remote]
627565
enum BalanceSource {
@@ -631,12 +569,7 @@ enum BalanceSource {
631569
"Htlc",
632570
};
633571

634-
[Enum]
635-
interface PendingSweepBalance {
636-
PendingBroadcast ( ChannelId? channel_id, u64 amount_satoshis );
637-
BroadcastAwaitingConfirmation ( ChannelId? channel_id, u32 latest_broadcast_height, Txid latest_spending_txid, u64 amount_satoshis );
638-
AwaitingThresholdConfirmations ( ChannelId? channel_id, Txid latest_spending_txid, BlockHash confirmation_hash, u32 confirmation_height, u64 amount_satoshis);
639-
};
572+
typedef enum PendingSweepBalance;
640573

641574
dictionary BalanceDetails {
642575
u64 total_onchain_balance_sats;
@@ -656,11 +589,7 @@ dictionary ChannelConfig {
656589
boolean accept_underpaying_htlcs;
657590
};
658591

659-
[Enum]
660-
interface MaxDustHTLCExposure {
661-
FixedLimit ( u64 limit_msat );
662-
FeeRateMultiplier ( u64 multiplier );
663-
};
592+
typedef enum MaxDustHTLCExposure;
664593

665594
interface NetworkGraph {
666595
sequence<u64> list_channels();

src/balance.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub struct BalanceDetails {
6767

6868
/// Details about the status of a known Lightning balance.
6969
#[derive(Debug, Clone)]
70+
#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
7071
pub enum LightningBalance {
7172
/// The channel is not yet closed (or the commitment or closing transaction has not yet
7273
/// appeared in a block). The given balance is claimable (less on-chain fees) if the channel is
@@ -304,6 +305,7 @@ impl LightningBalance {
304305

305306
/// Details about the status of a known balance currently being swept to our on-chain wallet.
306307
#[derive(Debug, Clone)]
308+
#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
307309
pub enum PendingSweepBalance {
308310
/// The spendable output is about to be swept, but a spending transaction has yet to be generated and
309311
/// broadcast.

src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ impl Default for ChannelConfig {
555555
///
556556
/// See [`LdkChannelConfig::max_dust_htlc_exposure`] for details.
557557
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
558+
#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
558559
pub enum MaxDustHTLCExposure {
559560
/// This sets a fixed limit on the total dust exposure in millisatoshis.
560561
///

src/ffi/types.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ use crate::error::Error;
147147
pub use crate::graph::{ChannelInfo, ChannelUpdateInfo, NodeAnnouncementInfo, NodeInfo};
148148
pub use crate::liquidity::{LSPS1OrderStatus, LSPS2ServiceConfig};
149149
pub use crate::logger::{LogLevel, LogRecord, LogWriter};
150-
pub use crate::payment::store::{
151-
ConfirmationStatus, LSPFeeLimits, PaymentDirection, PaymentKind, PaymentStatus,
152-
};
150+
pub use crate::payment::store::{PaymentDirection, PaymentKind, PaymentStatus};
153151
pub use crate::payment::UnifiedPaymentResult;
154152
use crate::{hex_utils, SocketAddress, UserChannelId};
155153

src/payment/store.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ impl_writeable_tlv_based_enum!(PaymentStatus,
350350

351351
/// Represents the kind of a payment.
352352
#[derive(Clone, Debug, PartialEq, Eq)]
353+
#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
353354
pub enum PaymentKind {
354355
/// An on-chain payment.
355356
///
@@ -496,6 +497,7 @@ impl_writeable_tlv_based_enum!(PaymentKind,
496497

497498
/// Represents the confirmation status of a transaction.
498499
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
500+
#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]
499501
pub enum ConfirmationStatus {
500502
/// The transaction is confirmed in the best chain.
501503
Confirmed {
@@ -525,6 +527,7 @@ impl_writeable_tlv_based_enum!(ConfirmationStatus,
525527
///
526528
/// [`LdkChannelConfig::accept_underpaying_htlcs`]: lightning::util::config::ChannelConfig::accept_underpaying_htlcs
527529
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
530+
#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
528531
pub struct LSPFeeLimits {
529532
/// The maximal total amount we allow any configured LSP withhold from us when forwarding the
530533
/// payment.

0 commit comments

Comments
 (0)