@@ -49,7 +49,7 @@ extern "C" fn ChannelMonitorUpdate_free_void(this_ptr: *mut c_void) {
49
49
#[ allow( unused) ]
50
50
/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
51
51
impl ChannelMonitorUpdate {
52
- pub ( crate ) fn take_ptr ( mut self ) -> * mut nativeChannelMonitorUpdate {
52
+ pub ( crate ) fn take_inner ( mut self ) -> * mut nativeChannelMonitorUpdate {
53
53
assert ! ( self . is_owned) ;
54
54
let ret = self . inner ;
55
55
self . inner = std:: ptr:: null_mut ( ) ;
@@ -116,6 +116,10 @@ pub extern "C" fn ChannelMonitorUpdate_write(obj: *const ChannelMonitorUpdate) -
116
116
crate :: c_types:: serialize_obj ( unsafe { & ( * ( * obj) . inner ) } )
117
117
}
118
118
#[ no_mangle]
119
+ pub ( crate ) extern "C" fn ChannelMonitorUpdate_write_void ( obj : * const c_void ) -> crate :: c_types:: derived:: CVec_u8Z {
120
+ crate :: c_types:: serialize_obj ( unsafe { & * ( obj as * const nativeChannelMonitorUpdate ) } )
121
+ }
122
+ #[ no_mangle]
119
123
pub extern "C" fn ChannelMonitorUpdate_read ( ser : crate :: c_types:: u8slice ) -> ChannelMonitorUpdate {
120
124
if let Ok ( res) = crate :: c_types:: deserialize_obj ( ser) {
121
125
ChannelMonitorUpdate { inner : Box :: into_raw ( Box :: new ( res) ) , is_owned : true }
@@ -255,7 +259,7 @@ extern "C" fn MonitorUpdateError_free_void(this_ptr: *mut c_void) {
255
259
#[ allow( unused) ]
256
260
/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
257
261
impl MonitorUpdateError {
258
- pub ( crate ) fn take_ptr ( mut self ) -> * mut nativeMonitorUpdateError {
262
+ pub ( crate ) fn take_inner ( mut self ) -> * mut nativeMonitorUpdateError {
259
263
assert ! ( self . is_owned) ;
260
264
let ret = self . inner ;
261
265
self . inner = std:: ptr:: null_mut ( ) ;
@@ -293,7 +297,7 @@ extern "C" fn MonitorEvent_free_void(this_ptr: *mut c_void) {
293
297
#[ allow( unused) ]
294
298
/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
295
299
impl MonitorEvent {
296
- pub ( crate ) fn take_ptr ( mut self ) -> * mut nativeMonitorEvent {
300
+ pub ( crate ) fn take_inner ( mut self ) -> * mut nativeMonitorEvent {
297
301
assert ! ( self . is_owned) ;
298
302
let ret = self . inner ;
299
303
self . inner = std:: ptr:: null_mut ( ) ;
@@ -352,7 +356,7 @@ extern "C" fn HTLCUpdate_free_void(this_ptr: *mut c_void) {
352
356
#[ allow( unused) ]
353
357
/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
354
358
impl HTLCUpdate {
355
- pub ( crate ) fn take_ptr ( mut self ) -> * mut nativeHTLCUpdate {
359
+ pub ( crate ) fn take_inner ( mut self ) -> * mut nativeHTLCUpdate {
356
360
assert ! ( self . is_owned) ;
357
361
let ret = self . inner ;
358
362
self . inner = std:: ptr:: null_mut ( ) ;
@@ -381,6 +385,10 @@ pub extern "C" fn HTLCUpdate_write(obj: *const HTLCUpdate) -> crate::c_types::de
381
385
crate :: c_types:: serialize_obj ( unsafe { & ( * ( * obj) . inner ) } )
382
386
}
383
387
#[ no_mangle]
388
+ pub ( crate ) extern "C" fn HTLCUpdate_write_void ( obj : * const c_void ) -> crate :: c_types:: derived:: CVec_u8Z {
389
+ crate :: c_types:: serialize_obj ( unsafe { & * ( obj as * const nativeHTLCUpdate ) } )
390
+ }
391
+ #[ no_mangle]
384
392
pub extern "C" fn HTLCUpdate_read ( ser : crate :: c_types:: u8slice ) -> HTLCUpdate {
385
393
if let Ok ( res) = crate :: c_types:: deserialize_obj ( ser) {
386
394
HTLCUpdate { inner : Box :: into_raw ( Box :: new ( res) ) , is_owned : true }
@@ -402,6 +410,12 @@ type nativeChannelMonitor = nativeChannelMonitorImport<crate::chain::keysinterfa
402
410
/// get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and
403
411
/// reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events
404
412
/// gotten are fully handled before re-serializing the new state.
413
+ ///
414
+ /// Note that the deserializer is only implemented for (Sha256dHash, ChannelMonitor), which
415
+ /// tells you the last block hash which was block_connect()ed. You MUST rescan any blocks along
416
+ /// the \"reorg path\" (ie disconnecting blocks until you find a common ancestor from both the
417
+ /// returned block hash and the the current chain and then reconnecting blocks to get to the
418
+ /// best chain) upon deserializing the object!
405
419
#[ must_use]
406
420
#[ repr( C ) ]
407
421
pub struct ChannelMonitor {
@@ -428,7 +442,7 @@ extern "C" fn ChannelMonitor_free_void(this_ptr: *mut c_void) {
428
442
#[ allow( unused) ]
429
443
/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
430
444
impl ChannelMonitor {
431
- pub ( crate ) fn take_ptr ( mut self ) -> * mut nativeChannelMonitor {
445
+ pub ( crate ) fn take_inner ( mut self ) -> * mut nativeChannelMonitor {
432
446
assert ! ( self . is_owned) ;
433
447
let ret = self . inner ;
434
448
self . inner = std:: ptr:: null_mut ( ) ;
@@ -600,12 +614,12 @@ use lightning::chain::channelmonitor::Persist as rustPersist;
600
614
impl rustPersist < crate :: chain:: keysinterface:: ChannelKeys > for Persist {
601
615
fn persist_new_channel ( & self , id : lightning:: chain:: transaction:: OutPoint , data : & lightning:: chain:: channelmonitor:: ChannelMonitor < crate :: chain:: keysinterface:: ChannelKeys > ) -> Result < ( ) , lightning:: chain:: channelmonitor:: ChannelMonitorUpdateErr > {
602
616
let mut ret = ( self . persist_new_channel ) ( self . this_arg , crate :: chain:: transaction:: OutPoint { inner : Box :: into_raw ( Box :: new ( id) ) , is_owned : true } , & crate :: chain:: channelmonitor:: ChannelMonitor { inner : unsafe { ( data as * const _ ) as * mut _ } , is_owned : false } ) ;
603
- let mut local_ret = match ret. result_ok { true => Ok ( { ( ) /*(*unsafe { Box::from_raw(ret.contents.result.take_ptr( )) })*/ } ) , false => Err ( { ( * unsafe { Box :: from_raw ( ret. contents . err . take_ptr ( ) ) } ) . into_native ( ) } ) } ;
617
+ let mut local_ret = match ret. result_ok { true => Ok ( { ( ) /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ } ) , false => Err ( { ( * unsafe { Box :: from_raw ( < * mut _ > :: take_ptr ( & mut ret. contents . err ) ) } ) . into_native ( ) } ) } ;
604
618
local_ret
605
619
}
606
620
fn update_persisted_channel ( & self , id : lightning:: chain:: transaction:: OutPoint , update : & lightning:: chain:: channelmonitor:: ChannelMonitorUpdate , data : & lightning:: chain:: channelmonitor:: ChannelMonitor < crate :: chain:: keysinterface:: ChannelKeys > ) -> Result < ( ) , lightning:: chain:: channelmonitor:: ChannelMonitorUpdateErr > {
607
621
let mut ret = ( self . update_persisted_channel ) ( self . this_arg , crate :: chain:: transaction:: OutPoint { inner : Box :: into_raw ( Box :: new ( id) ) , is_owned : true } , & crate :: chain:: channelmonitor:: ChannelMonitorUpdate { inner : unsafe { ( update as * const _ ) as * mut _ } , is_owned : false } , & crate :: chain:: channelmonitor:: ChannelMonitor { inner : unsafe { ( data as * const _ ) as * mut _ } , is_owned : false } ) ;
608
- let mut local_ret = match ret. result_ok { true => Ok ( { ( ) /*(*unsafe { Box::from_raw(ret.contents.result.take_ptr( )) })*/ } ) , false => Err ( { ( * unsafe { Box :: from_raw ( ret. contents . err . take_ptr ( ) ) } ) . into_native ( ) } ) } ;
622
+ let mut local_ret = match ret. result_ok { true => Ok ( { ( ) /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ } ) , false => Err ( { ( * unsafe { Box :: from_raw ( < * mut _ > :: take_ptr ( & mut ret. contents . err ) ) } ) . into_native ( ) } ) } ;
609
623
local_ret
610
624
}
611
625
}
0 commit comments