@@ -123,7 +123,8 @@ impl TxCreationKeys {
123
123
impl Clone for TxCreationKeys {
124
124
fn clone ( & self ) -> Self {
125
125
Self {
126
- inner : Box :: into_raw ( Box :: new ( unsafe { & * self . inner } . clone ( ) ) ) ,
126
+ inner : if self . inner . is_null ( ) { std:: ptr:: null_mut ( ) } else {
127
+ Box :: into_raw ( Box :: new ( unsafe { & * self . inner } . clone ( ) ) ) } ,
127
128
is_owned : true ,
128
129
}
129
130
}
@@ -135,7 +136,7 @@ pub(crate) extern "C" fn TxCreationKeys_clone_void(this_ptr: *const c_void) -> *
135
136
}
136
137
#[ no_mangle]
137
138
pub extern "C" fn TxCreationKeys_clone ( orig : & TxCreationKeys ) -> TxCreationKeys {
138
- TxCreationKeys { inner : Box :: into_raw ( Box :: new ( unsafe { & * orig. inner } . clone ( ) ) ) , is_owned : true }
139
+ orig. clone ( )
139
140
}
140
141
/// The broadcaster's per-commitment public key which was used to derive the other keys.
141
142
#[ no_mangle]
@@ -264,7 +265,8 @@ impl ChannelPublicKeys {
264
265
impl Clone for ChannelPublicKeys {
265
266
fn clone ( & self ) -> Self {
266
267
Self {
267
- inner : Box :: into_raw ( Box :: new ( unsafe { & * self . inner } . clone ( ) ) ) ,
268
+ inner : if self . inner . is_null ( ) { std:: ptr:: null_mut ( ) } else {
269
+ Box :: into_raw ( Box :: new ( unsafe { & * self . inner } . clone ( ) ) ) } ,
268
270
is_owned : true ,
269
271
}
270
272
}
@@ -276,7 +278,7 @@ pub(crate) extern "C" fn ChannelPublicKeys_clone_void(this_ptr: *const c_void) -
276
278
}
277
279
#[ no_mangle]
278
280
pub extern "C" fn ChannelPublicKeys_clone ( orig : & ChannelPublicKeys ) -> ChannelPublicKeys {
279
- ChannelPublicKeys { inner : Box :: into_raw ( Box :: new ( unsafe { & * orig. inner } . clone ( ) ) ) , is_owned : true }
281
+ orig. clone ( )
280
282
}
281
283
/// The public key which is used to sign all commitment transactions, as it appears in the
282
284
/// on-chain channel lock-in 2-of-2 multisig output.
@@ -448,7 +450,8 @@ impl HTLCOutputInCommitment {
448
450
impl Clone for HTLCOutputInCommitment {
449
451
fn clone ( & self ) -> Self {
450
452
Self {
451
- inner : Box :: into_raw ( Box :: new ( unsafe { & * self . inner } . clone ( ) ) ) ,
453
+ inner : if self . inner . is_null ( ) { std:: ptr:: null_mut ( ) } else {
454
+ Box :: into_raw ( Box :: new ( unsafe { & * self . inner } . clone ( ) ) ) } ,
452
455
is_owned : true ,
453
456
}
454
457
}
@@ -460,7 +463,7 @@ pub(crate) extern "C" fn HTLCOutputInCommitment_clone_void(this_ptr: *const c_vo
460
463
}
461
464
#[ no_mangle]
462
465
pub extern "C" fn HTLCOutputInCommitment_clone ( orig : & HTLCOutputInCommitment ) -> HTLCOutputInCommitment {
463
- HTLCOutputInCommitment { inner : Box :: into_raw ( Box :: new ( unsafe { & * orig. inner } . clone ( ) ) ) , is_owned : true }
466
+ orig. clone ( )
464
467
}
465
468
/// Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction).
466
469
/// Note that this is not the same as whether it is ountbound *from us*. To determine that you
@@ -599,7 +602,8 @@ impl ChannelTransactionParameters {
599
602
impl Clone for ChannelTransactionParameters {
600
603
fn clone ( & self ) -> Self {
601
604
Self {
602
- inner : Box :: into_raw ( Box :: new ( unsafe { & * self . inner } . clone ( ) ) ) ,
605
+ inner : if self . inner . is_null ( ) { std:: ptr:: null_mut ( ) } else {
606
+ Box :: into_raw ( Box :: new ( unsafe { & * self . inner } . clone ( ) ) ) } ,
603
607
is_owned : true ,
604
608
}
605
609
}
@@ -611,7 +615,7 @@ pub(crate) extern "C" fn ChannelTransactionParameters_clone_void(this_ptr: *cons
611
615
}
612
616
#[ no_mangle]
613
617
pub extern "C" fn ChannelTransactionParameters_clone ( orig : & ChannelTransactionParameters ) -> ChannelTransactionParameters {
614
- ChannelTransactionParameters { inner : Box :: into_raw ( Box :: new ( unsafe { & * orig. inner } . clone ( ) ) ) , is_owned : true }
618
+ orig. clone ( )
615
619
}
616
620
/// Holder public keys
617
621
#[ no_mangle]
@@ -730,7 +734,8 @@ impl CounterpartyChannelTransactionParameters {
730
734
impl Clone for CounterpartyChannelTransactionParameters {
731
735
fn clone ( & self ) -> Self {
732
736
Self {
733
- inner : Box :: into_raw ( Box :: new ( unsafe { & * self . inner } . clone ( ) ) ) ,
737
+ inner : if self . inner . is_null ( ) { std:: ptr:: null_mut ( ) } else {
738
+ Box :: into_raw ( Box :: new ( unsafe { & * self . inner } . clone ( ) ) ) } ,
734
739
is_owned : true ,
735
740
}
736
741
}
@@ -742,7 +747,7 @@ pub(crate) extern "C" fn CounterpartyChannelTransactionParameters_clone_void(thi
742
747
}
743
748
#[ no_mangle]
744
749
pub extern "C" fn CounterpartyChannelTransactionParameters_clone ( orig : & CounterpartyChannelTransactionParameters ) -> CounterpartyChannelTransactionParameters {
745
- CounterpartyChannelTransactionParameters { inner : Box :: into_raw ( Box :: new ( unsafe { & * orig. inner } . clone ( ) ) ) , is_owned : true }
750
+ orig. clone ( )
746
751
}
747
752
/// Counter-party public keys
748
753
#[ no_mangle]
@@ -965,7 +970,8 @@ impl HolderCommitmentTransaction {
965
970
impl Clone for HolderCommitmentTransaction {
966
971
fn clone ( & self ) -> Self {
967
972
Self {
968
- inner : Box :: into_raw ( Box :: new ( unsafe { & * self . inner } . clone ( ) ) ) ,
973
+ inner : if self . inner . is_null ( ) { std:: ptr:: null_mut ( ) } else {
974
+ Box :: into_raw ( Box :: new ( unsafe { & * self . inner } . clone ( ) ) ) } ,
969
975
is_owned : true ,
970
976
}
971
977
}
@@ -977,7 +983,7 @@ pub(crate) extern "C" fn HolderCommitmentTransaction_clone_void(this_ptr: *const
977
983
}
978
984
#[ no_mangle]
979
985
pub extern "C" fn HolderCommitmentTransaction_clone ( orig : & HolderCommitmentTransaction ) -> HolderCommitmentTransaction {
980
- HolderCommitmentTransaction { inner : Box :: into_raw ( Box :: new ( unsafe { & * orig. inner } . clone ( ) ) ) , is_owned : true }
986
+ orig. clone ( )
981
987
}
982
988
/// Our counterparty's signature for the transaction
983
989
#[ no_mangle]
@@ -1063,7 +1069,8 @@ impl BuiltCommitmentTransaction {
1063
1069
impl Clone for BuiltCommitmentTransaction {
1064
1070
fn clone ( & self ) -> Self {
1065
1071
Self {
1066
- inner : Box :: into_raw ( Box :: new ( unsafe { & * self . inner } . clone ( ) ) ) ,
1072
+ inner : if self . inner . is_null ( ) { std:: ptr:: null_mut ( ) } else {
1073
+ Box :: into_raw ( Box :: new ( unsafe { & * self . inner } . clone ( ) ) ) } ,
1067
1074
is_owned : true ,
1068
1075
}
1069
1076
}
@@ -1075,7 +1082,7 @@ pub(crate) extern "C" fn BuiltCommitmentTransaction_clone_void(this_ptr: *const
1075
1082
}
1076
1083
#[ no_mangle]
1077
1084
pub extern "C" fn BuiltCommitmentTransaction_clone ( orig : & BuiltCommitmentTransaction ) -> BuiltCommitmentTransaction {
1078
- BuiltCommitmentTransaction { inner : Box :: into_raw ( Box :: new ( unsafe { & * orig. inner } . clone ( ) ) ) , is_owned : true }
1085
+ orig. clone ( )
1079
1086
}
1080
1087
/// The commitment transaction
1081
1088
#[ no_mangle]
@@ -1195,7 +1202,8 @@ impl CommitmentTransaction {
1195
1202
impl Clone for CommitmentTransaction {
1196
1203
fn clone ( & self ) -> Self {
1197
1204
Self {
1198
- inner : Box :: into_raw ( Box :: new ( unsafe { & * self . inner } . clone ( ) ) ) ,
1205
+ inner : if self . inner . is_null ( ) { std:: ptr:: null_mut ( ) } else {
1206
+ Box :: into_raw ( Box :: new ( unsafe { & * self . inner } . clone ( ) ) ) } ,
1199
1207
is_owned : true ,
1200
1208
}
1201
1209
}
@@ -1207,7 +1215,7 @@ pub(crate) extern "C" fn CommitmentTransaction_clone_void(this_ptr: *const c_voi
1207
1215
}
1208
1216
#[ no_mangle]
1209
1217
pub extern "C" fn CommitmentTransaction_clone ( orig : & CommitmentTransaction ) -> CommitmentTransaction {
1210
- CommitmentTransaction { inner : Box :: into_raw ( Box :: new ( unsafe { & * orig. inner } . clone ( ) ) ) , is_owned : true }
1218
+ orig. clone ( )
1211
1219
}
1212
1220
#[ no_mangle]
1213
1221
pub extern "C" fn CommitmentTransaction_write ( obj : & CommitmentTransaction ) -> crate :: c_types:: derived:: CVec_u8Z {
0 commit comments