Skip to content

Commit 18d8d9d

Browse files
committed
f Expose ChannelPending
1 parent 9b555a8 commit 18d8d9d

File tree

4 files changed

+30
-8
lines changed

4 files changed

+30
-8
lines changed

bindings/ldk_node.udl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ interface Event {
8686
PaymentSuccessful( PaymentHash payment_hash );
8787
PaymentFailed( PaymentHash payment_hash );
8888
PaymentReceived( PaymentHash payment_hash, u64 amount_msat);
89+
ChannelPending ( ChannelId channel_id, UserChannelId user_channel_id, ChannelId former_temporary_channel_id, PublicKey counterparty_node_id, OutPoint funding_txo );
8990
ChannelReady ( ChannelId channel_id, UserChannelId user_channel_id );
9091
ChannelClosed ( ChannelId channel_id, UserChannelId user_channel_id );
9192
};
@@ -110,6 +111,14 @@ dictionary PaymentDetails {
110111
PaymentStatus status;
111112
};
112113

114+
dictionary OutPoint {
115+
Txid txid;
116+
u32 vout;
117+
};
118+
119+
[Custom]
120+
typedef string Txid;
121+
113122
[Custom]
114123
typedef string SocketAddr;
115124

src/event.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ pub enum Event {
5555
/// A channel has been created and is pending confirmation on-chain.
5656
ChannelPending {
5757
/// The `channel_id` of the channel.
58-
channel_id: [u8; 32],
58+
channel_id: ChannelId,
5959
/// The `user_channel_id` of the channel.
60-
user_channel_id: u128,
60+
user_channel_id: UserChannelId,
6161
/// The `temporary_channel_id` this channel used to be known by during channel establishment.
62-
former_temporary_channel_id: [u8; 32],
62+
former_temporary_channel_id: ChannelId,
6363
/// The `node_id` of the channel counterparty.
6464
counterparty_node_id: PublicKey,
6565
/// The outpoint of the channel's funding transaction.
@@ -645,9 +645,11 @@ where
645645
);
646646
self.event_queue
647647
.add_event(Event::ChannelPending {
648-
channel_id,
649-
user_channel_id,
650-
former_temporary_channel_id: former_temporary_channel_id.unwrap(),
648+
channel_id: ChannelId(channel_id),
649+
user_channel_id: UserChannelId(user_channel_id),
650+
former_temporary_channel_id: ChannelId(
651+
former_temporary_channel_id.unwrap(),
652+
),
651653
counterparty_node_id,
652654
funding_txo,
653655
})

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ use bdk::template::Bip84;
140140
use bitcoin::hashes::sha256::Hash as Sha256;
141141
use bitcoin::hashes::Hash;
142142
use bitcoin::secp256k1::PublicKey;
143-
use bitcoin::{Address, BlockHash};
143+
use bitcoin::{Address, BlockHash, OutPoint, Txid};
144144

145145
use rand::Rng;
146146

src/types.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use lightning_transaction_sync::EsploraSyncClient;
2222
use bitcoin::hashes::sha256::Hash as Sha256;
2323
use bitcoin::hashes::Hash;
2424
use bitcoin::secp256k1::PublicKey;
25-
use bitcoin::Address;
25+
use bitcoin::{Address, Txid};
2626

2727
use std::convert::TryInto;
2828
use std::default::Default;
@@ -339,3 +339,14 @@ impl UniffiCustomTypeConverter for Network {
339339
obj.0.to_string()
340340
}
341341
}
342+
343+
impl UniffiCustomTypeConverter for Txid {
344+
type Builtin = String;
345+
fn into_custom(val: Self::Builtin) -> uniffi::Result<Self> {
346+
Ok(Txid::from_str(&val).unwrap())
347+
}
348+
349+
fn from_custom(obj: Self) -> Self::Builtin {
350+
obj.to_string()
351+
}
352+
}

0 commit comments

Comments
 (0)