@@ -23,11 +23,8 @@ use lightning::{
2323pub mod primitives;
2424use primitives:: * ;
2525use std:: sync:: Arc ;
26- use lightning:: util:: ser:: Readable ;
27- use std:: io:: Read ;
28- use lightning:: ln:: msgs:: DecodeError ;
2926
30- type cstr = NonNull < i8 > ;
27+ type Cstr = NonNull < i8 > ;
3128
3229#[ derive( PartialOrd , PartialEq , Eq , Ord , Debug , Copy , Clone ) ]
3330#[ repr( u8 ) ]
@@ -158,11 +155,11 @@ pub struct FFILogRecord {
158155 /// The verbosity level of the message.
159156 pub level : FFILogLevel ,
160157 /// The message body.
161- pub args : cstr ,
158+ pub args : Cstr ,
162159 /// The module path of the message.
163- pub module_path : cstr ,
160+ pub module_path : Cstr ,
164161 /// The source file containing the message.
165- pub file : cstr ,
162+ pub file : Cstr ,
166163 /// The line containing the message.
167164 pub line : u32 ,
168165}
@@ -196,10 +193,10 @@ impl Logger for FFILogger {
196193
197194pub mod chain_watch_interface_fn {
198195 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 ) ;
200197 pub type InstallWatchOutpointPtr = extern "cdecl" fn ( outpoint : * const FFIOutPoint , out_script : * const FFIScript ) ;
201198 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 ) ;
203200}
204201
205202#[ repr( C ) ]
@@ -217,7 +214,7 @@ impl FFIChainWatchInterface {
217214 watch_all_txn : chain_watch_interface_fn:: WatchAllTxnPtr ,
218215 get_chain_utxo : chain_watch_interface_fn:: GetChainUtxoPtr ,
219216 network : Network ,
220- logger : Arc < Logger >
217+ logger : Arc < dyn Logger >
221218 ) -> FFIChainWatchInterface {
222219 FFIChainWatchInterface {
223220 install_watch_tx_ptr : install_watch_tx,
@@ -234,11 +231,12 @@ impl ChainWatchInterface for FFIChainWatchInterface {
234231 self . util . install_watch_tx ( txid, script_pub_key) ;
235232 let spk_vec = bitcoin_serialize ( script_pub_key) ;
236233 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 _ )
238236 }
239237 fn install_watch_outpoint ( & self , outpoint : ( Txid , u32 ) , out_script : & Script ) {
240238 self . util . install_watch_outpoint ( outpoint, out_script) ;
241- let txid: FFISha256dHash = outpoint. 0 . into ( ) ;
239+ let txid: Bytes32 = outpoint. 0 . into ( ) ;
242240 let ffi_outpoint = FFIOutPoint { txid : txid, index : outpoint. 1 as u16 } ;
243241 let out_script_vec = bitcoin_serialize ( out_script) ;
244242 let ffi_outscript = FFIScript :: from ( out_script_vec. as_slice ( ) ) ;
@@ -320,7 +318,7 @@ pub enum FFIErrorActionType {
320318#[ derive( Debug , Clone ) ]
321319pub struct FFIErrorMsg {
322320 pub channel_id : [ u8 ; 32 ] ,
323- pub data : cstr ,
321+ pub data : Cstr ,
324322}
325323
326324impl From < FFIErrorMsg > for ErrorMessage {
@@ -370,7 +368,7 @@ impl From<FFIErrorAction> for ErrorAction {
370368#[ repr( C ) ]
371369pub struct FFILightningError {
372370 /// A human-readable message describing the error
373- pub err : cstr ,
371+ pub err : Cstr ,
374372 /// The action which should be taken against the offending peer.
375373 pub action : FFIErrorAction ,
376374}
@@ -387,7 +385,7 @@ impl From<FFILightningError> for LightningError {
387385
388386pub mod routing_msg_descriptor_fn {
389387 use super :: * ;
390- use crate :: adaptors:: primitives:: PublicKey ;
388+ use crate :: adaptors:: primitives:: Bytes33 ;
391389
392390 /// Handle an incoming node_announcement message, returning true if it should be forwarded on,
393391 /// false or returning an Err otherwise.
@@ -410,9 +408,9 @@ pub mod routing_msg_descriptor_fn {
410408 /// immediately higher (as defined by <PublicKey as Ord>::cmp) than starting_point.
411409 /// If None is provided for starting_point, we start at the first node.
412410 /// 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 ;
414412 /// 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 ;
416414}
417415
418416pub struct FFIRoutingMsgHandler {
@@ -439,17 +437,7 @@ impl Writer for VecWriter {
439437
440438impl RoutingMessageHandler for FFIRoutingMsgHandler {
441439 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 ! ( )
453441 }
454442
455443 fn handle_channel_announcement ( & self , msg : & ChannelAnnouncement ) -> Result < bool , LightningError > {
0 commit comments