@@ -23,11 +23,8 @@ use lightning::{
23
23
pub mod primitives;
24
24
use primitives:: * ;
25
25
use std:: sync:: Arc ;
26
- use lightning:: util:: ser:: Readable ;
27
- use std:: io:: Read ;
28
- use lightning:: ln:: msgs:: DecodeError ;
29
26
30
- type cstr = NonNull < i8 > ;
27
+ type Cstr = NonNull < i8 > ;
31
28
32
29
#[ derive( PartialOrd , PartialEq , Eq , Ord , Debug , Copy , Clone ) ]
33
30
#[ repr( u8 ) ]
@@ -158,11 +155,11 @@ pub struct FFILogRecord {
158
155
/// The verbosity level of the message.
159
156
pub level : FFILogLevel ,
160
157
/// The message body.
161
- pub args : cstr ,
158
+ pub args : Cstr ,
162
159
/// The module path of the message.
163
- pub module_path : cstr ,
160
+ pub module_path : Cstr ,
164
161
/// The source file containing the message.
165
- pub file : cstr ,
162
+ pub file : Cstr ,
166
163
/// The line containing the message.
167
164
pub line : u32 ,
168
165
}
@@ -196,10 +193,10 @@ impl Logger for FFILogger {
196
193
197
194
pub mod chain_watch_interface_fn {
198
195
use super :: * ;
199
- pub type InstallWatchTxPtr = extern "cdecl" fn ( * const FFISha256dHash , script_pub_key : * const FFIScript ) ;
196
+ pub type InstallWatchTxPtr = extern "cdecl" fn ( * const Bytes32 , script_pub_key : * const FFIScript ) ;
200
197
pub type InstallWatchOutpointPtr = extern "cdecl" fn ( outpoint : * const FFIOutPoint , out_script : * const FFIScript ) ;
201
198
pub type WatchAllTxnPtr = extern "cdecl" fn ( ) ;
202
- pub type GetChainUtxoPtr = extern "cdecl" fn ( genesis_hash : * const FFISha256dHash , unspent_tx_output_identifier : u64 , err : * mut FFIChainError , script : * mut FFITxOut ) ;
199
+ pub type GetChainUtxoPtr = extern "cdecl" fn ( genesis_hash : * const Bytes32 , unspent_tx_output_identifier : u64 , err : * mut FFIChainError , script : * mut FFITxOut ) ;
203
200
}
204
201
205
202
#[ repr( C ) ]
@@ -217,7 +214,7 @@ impl FFIChainWatchInterface {
217
214
watch_all_txn : chain_watch_interface_fn:: WatchAllTxnPtr ,
218
215
get_chain_utxo : chain_watch_interface_fn:: GetChainUtxoPtr ,
219
216
network : Network ,
220
- logger : Arc < Logger >
217
+ logger : Arc < dyn Logger >
221
218
) -> FFIChainWatchInterface {
222
219
FFIChainWatchInterface {
223
220
install_watch_tx_ptr : install_watch_tx,
@@ -234,11 +231,12 @@ impl ChainWatchInterface for FFIChainWatchInterface {
234
231
self . util . install_watch_tx ( txid, script_pub_key) ;
235
232
let spk_vec = bitcoin_serialize ( script_pub_key) ;
236
233
let ffi_spk = FFIScript :: from ( spk_vec. as_slice ( ) ) ;
237
- ( self . install_watch_tx_ptr ) ( & txid. into ( ) as * const _ , & ffi_spk as * const _ )
234
+ let txid: Bytes32 = txid. clone ( ) . into ( ) ;
235
+ ( self . install_watch_tx_ptr ) ( & txid as * const _ , & ffi_spk as * const _ )
238
236
}
239
237
fn install_watch_outpoint ( & self , outpoint : ( Txid , u32 ) , out_script : & Script ) {
240
238
self . util . install_watch_outpoint ( outpoint, out_script) ;
241
- let txid: FFISha256dHash = outpoint. 0 . into ( ) ;
239
+ let txid: Bytes32 = outpoint. 0 . into ( ) ;
242
240
let ffi_outpoint = FFIOutPoint { txid : txid, index : outpoint. 1 as u16 } ;
243
241
let out_script_vec = bitcoin_serialize ( out_script) ;
244
242
let ffi_outscript = FFIScript :: from ( out_script_vec. as_slice ( ) ) ;
@@ -320,7 +318,7 @@ pub enum FFIErrorActionType {
320
318
#[ derive( Debug , Clone ) ]
321
319
pub struct FFIErrorMsg {
322
320
pub channel_id : [ u8 ; 32 ] ,
323
- pub data : cstr ,
321
+ pub data : Cstr ,
324
322
}
325
323
326
324
impl From < FFIErrorMsg > for ErrorMessage {
@@ -370,7 +368,7 @@ impl From<FFIErrorAction> for ErrorAction {
370
368
#[ repr( C ) ]
371
369
pub struct FFILightningError {
372
370
/// A human-readable message describing the error
373
- pub err : cstr ,
371
+ pub err : Cstr ,
374
372
/// The action which should be taken against the offending peer.
375
373
pub action : FFIErrorAction ,
376
374
}
@@ -387,7 +385,7 @@ impl From<FFILightningError> for LightningError {
387
385
388
386
pub mod routing_msg_descriptor_fn {
389
387
use super :: * ;
390
- use crate :: adaptors:: primitives:: PublicKey ;
388
+ use crate :: adaptors:: primitives:: Bytes33 ;
391
389
392
390
/// Handle an incoming node_announcement message, returning true if it should be forwarded on,
393
391
/// false or returning an Err otherwise.
@@ -410,9 +408,9 @@ pub mod routing_msg_descriptor_fn {
410
408
/// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
411
409
/// If None is provided for starting_point, we start at the first node.
412
410
/// Return type is binary serialized `Vec<NodeAnnouncement>` .
413
- pub type GetNextNodeAnnouncements = extern "cdecl" fn ( starting_point : Option < * const PublicKey > , batch_amount : u8 ) -> FFIBytes ;
411
+ pub type GetNextNodeAnnouncements = extern "cdecl" fn ( starting_point : Option < * const Bytes33 > , batch_amount : u8 ) -> FFIBytes ;
414
412
/// Returns whether a full sync should be requested from a peer.
415
- pub type ShouldRequestFullSync = extern "cdecl" fn ( node_id : NonNull < PublicKey > ) -> Bool ;
413
+ pub type ShouldRequestFullSync = extern "cdecl" fn ( node_id : Bytes33 ) -> Bool ;
416
414
}
417
415
418
416
pub struct FFIRoutingMsgHandler {
@@ -439,17 +437,7 @@ impl Writer for VecWriter {
439
437
440
438
impl RoutingMessageHandler for FFIRoutingMsgHandler {
441
439
fn handle_node_announcement ( & self , msg : & NodeAnnouncement ) -> Result < bool , LightningError > {
442
- let mut w = VecWriter ( Vec :: new ( ) ) ;
443
- msg. write ( & mut w) ;
444
- let bytes = FFIBytes :: from ( w. 0 . into_boxed_slice ( ) ) ;
445
- let e = std:: ptr:: null_mut ( ) ;
446
- let is_success = ( self . handle_node_announcement_ptr ) ( & bytes as * const _ , e) ;
447
- if e. is_null ( ) {
448
- Ok ( is_success. to_bool ( ) )
449
- } else {
450
- let e = unsafe_block ! ( "we know the error is not a null pointer" => ( * e) . clone( ) ) ;
451
- Err ( e. into ( ) )
452
- }
440
+ unimplemented ! ( )
453
441
}
454
442
455
443
fn handle_channel_announcement ( & self , msg : & ChannelAnnouncement ) -> Result < bool , LightningError > {
0 commit comments