Skip to content

Commit cdf253d

Browse files
authored
Fix react native (#8)
* rm rn * fix react native * update uniffi react package to github * unffi feature * move uniffi to lni crate * test tokio::task::spawn_blocking * staticlib * lnd test blocking tokio * blocking * fix NodeInfo annotation * try record * impl record * fix defaults * . * socks5 empty string by default * fix napi_rs * . * fix crate-type * . * update docs * rm bindings/lni_uniffi * add dotenv * fix workspace * dot env * sync lnd and uniffi::Record * phoenixd uniffi * cln uniffi * update nodejs
1 parent 584cdce commit cdf253d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1871
-34098
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,6 @@ xcuserdata/
122122
**test.json**
123123

124124
bindings/lni_react_native/src/generated/**
125-
bindings/lni_react_native/cpp/generated/**
125+
bindings/lni_react_native/cpp/generated/**
126+
127+
**/lni_react_native_old/**

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[workspace]
22
members = [
33
"crates/lni",
4-
"bindings/lni_uniffi",
54
"bindings/lni_nodejs",
65
]

bindings/lni_nodejs/index.d.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -234,41 +234,41 @@ export declare class PhoenixdNode {
234234
getUrl(): string
235235
getPassword(): string
236236
getConfig(): PhoenixdConfig
237-
getInfo(): Promise<NodeInfo>
238-
createInvoice(params: CreateInvoiceParams): Promise<Transaction>
239-
payInvoice(params: PayInvoiceParams): Promise<PayInvoiceResponse>
240-
getOffer(): Promise<PayCode>
241-
lookupInvoice(paymentHash: string): Promise<Transaction>
242-
payOffer(offer: string, amountMsats: number, payerNote?: string | undefined | null): Promise<PayInvoiceResponse>
243-
listTransactions(params: ListTransactionsParams): Promise<Array<Transaction>>
237+
getInfo(): NodeInfo
238+
createInvoice(params: CreateInvoiceParams): Transaction
239+
payInvoice(params: PayInvoiceParams): PayInvoiceResponse
240+
getOffer(): PayCode
241+
lookupInvoice(paymentHash: string): Transaction
242+
payOffer(offer: string, amountMsats: number, payerNote?: string | undefined | null): PayInvoiceResponse
243+
listTransactions(params: ListTransactionsParams): Array<Transaction>
244244
}
245245
export declare class ClnNode {
246246
constructor(config: ClnConfig)
247247
getUrl(): string
248248
getRune(): string
249249
getConfig(): ClnConfig
250-
getInfo(): Promise<NodeInfo>
251-
createInvoice(params: CreateInvoiceParams): Promise<Transaction>
252-
payInvoice(params: PayInvoiceParams): Promise<PayInvoiceResponse>
253-
getOffer(search?: string | undefined | null): Promise<PayCode>
254-
listOffers(search?: string | undefined | null): Promise<Array<PayCode>>
255-
payOffer(offer: string, amountMsats: number, payerNote?: string | undefined | null): Promise<PayInvoiceResponse>
256-
lookupInvoice(paymentHash: string): Promise<Transaction>
257-
listTransactions(params: ListTransactionsParams): Promise<Array<Transaction>>
258-
decode(str: string): Promise<string>
250+
getInfo(): NodeInfo
251+
createInvoice(params: CreateInvoiceParams): Transaction
252+
payInvoice(params: PayInvoiceParams): PayInvoiceResponse
253+
getOffer(search?: string | undefined | null): PayCode
254+
listOffers(search?: string | undefined | null): Array<PayCode>
255+
payOffer(offer: string, amountMsats: number, payerNote?: string | undefined | null): PayInvoiceResponse
256+
lookupInvoice(paymentHash: string): Transaction
257+
listTransactions(params: ListTransactionsParams): Array<Transaction>
258+
decode(str: string): string
259259
}
260260
export declare class LndNode {
261261
constructor(config: LndConfig)
262262
getUrl(): string
263263
getMacaroon(): string
264264
getConfig(): LndConfig
265-
getInfo(): Promise<NodeInfo>
266-
createInvoice(params: CreateInvoiceParams): Promise<Transaction>
267-
payInvoice(params: PayInvoiceParams): Promise<PayInvoiceResponse>
268-
getOffer(search?: string | undefined | null): Promise<PayCode>
269-
listOffers(search?: string | undefined | null): Promise<Array<PayCode>>
270-
payOffer(offer: string, amountMsats: number, payerNote?: string | undefined | null): Promise<PayInvoiceResponse>
271-
lookupInvoice(paymentHash: string): Promise<Transaction>
272-
listTransactions(params: ListTransactionsParams): Promise<Array<Transaction>>
273-
decode(str: string): Promise<string>
265+
getInfo(): NodeInfo
266+
createInvoice(params: CreateInvoiceParams): Transaction
267+
payInvoice(params: PayInvoiceParams): PayInvoiceResponse
268+
getOffer(search?: string | undefined | null): PayCode
269+
listOffers(search?: string | undefined | null): Array<PayCode>
270+
payOffer(offer: string, amountMsats: number, payerNote?: string | undefined | null): PayInvoiceResponse
271+
lookupInvoice(paymentHash: string): Transaction
272+
listTransactions(params: ListTransactionsParams): Array<Transaction>
273+
decode(str: string): string
274274
}

bindings/lni_nodejs/src/cln.rs

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,14 @@ impl ClnNode {
2929
}
3030

3131
#[napi]
32-
pub async fn get_info(&self) -> napi::Result<lni::NodeInfo> {
33-
let info = lni::cln::api::get_info(&self.inner)
34-
.await
35-
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
32+
pub fn get_info(&self) -> napi::Result<lni::NodeInfo> {
33+
let info =
34+
lni::cln::api::get_info(&self.inner).map_err(|e| napi::Error::from_reason(e.to_string()))?;
3635
Ok(info)
3736
}
3837

3938
#[napi]
40-
pub async fn create_invoice(
41-
&self,
42-
params: CreateInvoiceParams,
43-
) -> napi::Result<lni::Transaction> {
39+
pub fn create_invoice(&self, params: CreateInvoiceParams) -> napi::Result<lni::Transaction> {
4440
let txn = lni::cln::api::create_invoice(
4541
&self.inner,
4642
params.invoice_type,
@@ -50,74 +46,63 @@ impl ClnNode {
5046
params.description_hash,
5147
params.expiry,
5248
)
53-
.await
5449
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
5550
Ok(txn)
5651
}
5752

5853
#[napi]
59-
pub async fn pay_invoice(
60-
&self,
61-
params: PayInvoiceParams,
62-
) -> Result<lni::types::PayInvoiceResponse> {
54+
pub fn pay_invoice(&self, params: PayInvoiceParams) -> Result<lni::types::PayInvoiceResponse> {
6355
let invoice = lni::cln::api::pay_invoice(&self.inner, params)
64-
.await
6556
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
6657
Ok(invoice)
6758
}
6859

6960
#[napi]
70-
pub async fn get_offer(&self, search: Option<String>) -> Result<lni::types::PayCode> {
61+
pub fn get_offer(&self, search: Option<String>) -> Result<lni::types::PayCode> {
7162
let offer = lni::cln::api::get_offer(&self.inner, search)
72-
.await
7363
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
7464
Ok(offer)
7565
}
7666

7767
#[napi]
78-
pub async fn list_offers(&self, search: Option<String>) -> Result<Vec<lni::types::PayCode>> {
68+
pub fn list_offers(&self, search: Option<String>) -> Result<Vec<lni::types::PayCode>> {
7969
let offers = lni::cln::api::list_offers(&self.inner, search)
80-
.await
8170
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
8271
Ok(offers)
8372
}
8473

8574
#[napi]
86-
pub async fn pay_offer(
75+
pub fn pay_offer(
8776
&self,
8877
offer: String,
8978
amount_msats: i64,
9079
payer_note: Option<String>,
9180
) -> napi::Result<lni::PayInvoiceResponse> {
9281
let offer = lni::cln::api::pay_offer(&self.inner, offer, amount_msats, payer_note)
93-
.await
9482
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
9583
Ok(offer)
9684
}
9785

9886
#[napi]
99-
pub async fn lookup_invoice(&self, payment_hash: String) -> napi::Result<lni::Transaction> {
87+
pub fn lookup_invoice(&self, payment_hash: String) -> napi::Result<lni::Transaction> {
10088
let txn = lni::cln::api::lookup_invoice(&self.inner, Some(payment_hash), None, None)
101-
.await
10289
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
10390
Ok(txn)
10491
}
10592

10693
#[napi]
107-
pub async fn list_transactions(
94+
pub fn list_transactions(
10895
&self,
10996
params: lni::types::ListTransactionsParams,
11097
) -> napi::Result<Vec<lni::Transaction>> {
11198
let txns = lni::cln::api::list_transactions(&self.inner, params.from, params.limit)
112-
.await
11399
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
114100
Ok(txns)
115101
}
116102

117103
#[napi]
118-
pub async fn decode(&self, str: String) -> Result<String> {
104+
pub fn decode(&self, str: String) -> Result<String> {
119105
let decoded = lni::cln::api::decode(&self.inner, str)
120-
.await
121106
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
122107
Ok(decoded)
123108
}
@@ -149,8 +134,8 @@ impl ClnNode {
149134
// }
150135

151136
// #[test]
152-
// async fn test_get_info() {
153-
// match NODE.get_info().await {
137+
// fn test_get_info() {
138+
// match NODE.get_info() {
154139
// Ok(info) => {
155140
// println!("info: {:?}", info.pubkey);
156141
// assert!(!info.pubkey.is_empty(), "Node pubkey should not be empty");

bindings/lni_nodejs/src/lnd.rs

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,87 +35,72 @@ impl LndNode {
3535
}
3636

3737
#[napi]
38-
pub async fn get_info(&self) -> napi::Result<lni::NodeInfo> {
39-
let info = lni::lnd::api::get_info(&self.inner)
40-
.await
41-
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
38+
pub fn get_info(&self) -> napi::Result<lni::NodeInfo> {
39+
let info =
40+
lni::lnd::api::get_info(&self.inner).map_err(|e| napi::Error::from_reason(e.to_string()))?;
4241
Ok(info)
4342
}
4443

4544
#[napi]
46-
pub async fn create_invoice(
47-
&self,
48-
params: CreateInvoiceParams,
49-
) -> napi::Result<lni::Transaction> {
45+
pub fn create_invoice(&self, params: CreateInvoiceParams) -> napi::Result<lni::Transaction> {
5046
let txn = lni::lnd::api::create_invoice(&self.inner, params)
51-
.await
5247
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
5348
Ok(txn)
5449
}
5550

5651
#[napi]
57-
pub async fn pay_invoice(
58-
&self,
59-
params: PayInvoiceParams,
60-
) -> Result<lni::types::PayInvoiceResponse> {
52+
pub fn pay_invoice(&self, params: PayInvoiceParams) -> Result<lni::types::PayInvoiceResponse> {
6153
let invoice = lni::lnd::api::pay_invoice(&self.inner, params)
62-
.await
6354
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
6455
Ok(invoice)
6556
}
6657

6758
#[napi]
68-
pub async fn get_offer(&self, search: Option<String>) -> Result<lni::types::PayCode> {
59+
pub fn get_offer(&self, search: Option<String>) -> Result<lni::types::PayCode> {
6960
let offer = lni::lnd::api::get_offer(&self.inner, search)
70-
.await
7161
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
7262
Ok(offer)
7363
}
7464

7565
#[napi]
76-
pub async fn list_offers(&self, search: Option<String>) -> Result<Vec<lni::types::PayCode>> {
66+
pub fn list_offers(&self, search: Option<String>) -> Result<Vec<lni::types::PayCode>> {
7767
let offers = lni::lnd::api::list_offers(&self.inner, search)
78-
.await
7968
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
8069
Ok(offers)
8170
}
8271

8372
#[napi]
84-
pub async fn pay_offer(
73+
pub fn pay_offer(
8574
&self,
8675
offer: String,
8776
amount_msats: i64,
8877
payer_note: Option<String>,
8978
) -> napi::Result<lni::PayInvoiceResponse> {
9079
let offer = lni::lnd::api::pay_offer(&self.inner, offer, amount_msats, payer_note)
91-
.await
9280
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
9381
Ok(offer)
9482
}
9583

9684
#[napi]
97-
pub async fn lookup_invoice(&self, payment_hash: String) -> napi::Result<lni::Transaction> {
85+
pub fn lookup_invoice(&self, payment_hash: String) -> napi::Result<lni::Transaction> {
9886
let txn = lni::lnd::api::lookup_invoice(&self.inner, Some(payment_hash))
99-
.await
10087
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
10188
Ok(txn)
10289
}
10390

10491
#[napi]
105-
pub async fn list_transactions(
92+
pub fn list_transactions(
10693
&self,
10794
params: lni::types::ListTransactionsParams,
10895
) -> napi::Result<Vec<lni::Transaction>> {
10996
let txns = lni::lnd::api::list_transactions(&self.inner, params.from, params.limit)
110-
.await
11197
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
11298
Ok(txns)
11399
}
114100

115101
#[napi]
116-
pub async fn decode(&self, str: String) -> Result<String> {
102+
pub fn decode(&self, str: String) -> Result<String> {
117103
let decoded = lni::lnd::api::decode(&self.inner, str)
118-
.await
119104
.map_err(|e| napi::Error::from_reason(e.to_string()))?;
120105
Ok(decoded)
121106
}

0 commit comments

Comments
 (0)