-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We generate the scaffolding from an UDL file and include it in `lib.rs`. Furthermore, we add a bindings generation shell script for convenience.
- Loading branch information
Showing
7 changed files
with
213 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
uniffi_build::generate_scaffolding("uniffi/ldk_lite.udl").unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
namespace ldk_lite { | ||
}; | ||
|
||
interface Builder { | ||
constructor(); | ||
LdkLite build(); | ||
}; | ||
|
||
interface LdkLite { | ||
[Throws=Error] | ||
void start(); | ||
[Throws=Error] | ||
void stop(); | ||
Event next_event(); | ||
void event_handled(); | ||
[Throws=Error] | ||
PublicKey my_node_id(); | ||
[Throws=Error] | ||
Address new_funding_address(); | ||
[Throws=Error] | ||
void connect_open_channel([ByRef]string node_pubkey_and_address, u64 channel_amount_sats, boolean announce_channel); | ||
[Throws=Error] | ||
PaymentHash send_payment(Invoice invoice); | ||
[Throws=Error] | ||
PaymentHash send_spontaneous_payment(u64 amount_msat, [ByRef]string node_id); | ||
[Throws=Error] | ||
Invoice receive_payment(u64? amount_msat, [ByRef]string description, u32 expiry_secs); | ||
// TODO: payment_info() | ||
}; | ||
|
||
[Error] | ||
enum Error { | ||
"AlreadyRunning", | ||
"NotRunning", | ||
"FundingTxCreationFailed", | ||
"ConnectionFailed", | ||
"AddressInvalid", | ||
"PublicKeyInvalid", | ||
"PaymentHashInvalid", | ||
"NonUniquePaymentHash", | ||
"InvoiceInvalid", | ||
"InvoiceCreationFailed", | ||
"ChannelIdInvalid", | ||
"RoutingFailed", | ||
"PeerInfoParseFailed", | ||
"ChannelCreationFailed", | ||
"ChannelClosingFailed", | ||
"PersistenceFailed", | ||
"WalletOperationFailed", | ||
"WalletSigningFailed", | ||
"ChainAccessFailed", | ||
}; | ||
|
||
[Enum] | ||
interface Event { | ||
PaymentSuccessful( PaymentHash payment_hash ); | ||
PaymentFailed( PaymentHash payment_hash ); | ||
PaymentReceived( PaymentHash payment_hash, u64 amount_msat); | ||
ChannelClosed ( ChannelId channel_id ); | ||
}; | ||
|
||
[Custom] | ||
typedef string PublicKey; | ||
|
||
[Custom] | ||
typedef string Address; | ||
|
||
[Custom] | ||
typedef string Invoice; | ||
|
||
[Custom] | ||
typedef string PaymentHash; | ||
|
||
[Custom] | ||
typedef string ChannelId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
uniffi-bindgen generate uniffi/ldk_lite.udl --language swift | ||
uniffi-bindgen generate uniffi/ldk_lite.udl --language python | ||
uniffi-bindgen generate uniffi/ldk_lite.udl --language kotlin |