//! raw socket events into your non-internet-facing system and then send routing events back to
//! track the network on the less-secure system.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
use lightning::ln::msgs::DecodeError as nativeDecodeErrorImport;
pub(crate) fn take_inner(mut self) -> *mut nativeDecodeError {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for DecodeError {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeDecodeError>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeDecodeError>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeInit {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for Init {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeInit>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
-/// The channel ID involved in the error
+/// The channel ID involved in the error.
+///
+/// All-0s indicates a general error unrelated to a specific channel, after which all channels
+/// with the sending peer should be closed.
#[no_mangle]
pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] {
let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
inner_val
}
-/// The channel ID involved in the error
+/// The channel ID involved in the error.
+///
+/// All-0s indicates a general error unrelated to a specific channel, after which all channels
+/// with the sending peer should be closed.
#[no_mangle]
pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) {
unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
}
/// A possibly human-readable error description.
-/// The string should be sanitized before it is used (e.g. emitted to logs
-/// or printed to stdout). Otherwise, a well crafted error message may trigger a security
-/// vulnerability in the terminal emulator or the logging subsystem.
+/// The string should be sanitized before it is used (e.g. emitted to logs or printed to
+/// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
+/// the terminal emulator or the logging subsystem.
#[no_mangle]
pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str {
let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
inner_val.as_str().into()
}
/// A possibly human-readable error description.
-/// The string should be sanitized before it is used (e.g. emitted to logs
-/// or printed to stdout). Otherwise, a well crafted error message may trigger a security
-/// vulnerability in the terminal emulator or the logging subsystem.
+/// The string should be sanitized before it is used (e.g. emitted to logs or printed to
+/// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
+/// the terminal emulator or the logging subsystem.
#[no_mangle]
pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) {
unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
impl Clone for ErrorMessage {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeErrorMessage>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
orig.clone()
}
+use lightning::ln::msgs::WarningMessage as nativeWarningMessageImport;
+pub(crate) type nativeWarningMessage = nativeWarningMessageImport;
+
+/// A warning message to be sent or received from a peer
+#[must_use]
+#[repr(C)]
+pub struct WarningMessage {
+ /// A pointer to the opaque Rust object.
+
+ /// Nearly everywhere, inner must be non-null, however in places where
+ /// the Rust equivalent takes an Option, it may be set to null to indicate None.
+ pub inner: *mut nativeWarningMessage,
+ /// Indicates that this is the only struct which contains the same pointer.
+
+ /// Rust functions which take ownership of an object provided via an argument require
+ /// this to be true and invalidate the object pointed to by inner.
+ pub is_owned: bool,
+}
+
+impl Drop for WarningMessage {
+ fn drop(&mut self) {
+ if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) {
+ let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+ }
+ }
+}
+/// Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn WarningMessage_free(this_obj: WarningMessage) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn WarningMessage_free_void(this_ptr: *mut c_void) {
+ unsafe { let _ = Box::from_raw(this_ptr as *mut nativeWarningMessage); }
+}
+#[allow(unused)]
+impl WarningMessage {
+ pub(crate) fn get_native_ref(&self) -> &'static nativeWarningMessage {
+ unsafe { &*ObjOps::untweak_ptr(self.inner) }
+ }
+ pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeWarningMessage {
+ unsafe { &mut *ObjOps::untweak_ptr(self.inner) }
+ }
+ /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+ pub(crate) fn take_inner(mut self) -> *mut nativeWarningMessage {
+ assert!(self.is_owned);
+ let ret = ObjOps::untweak_ptr(self.inner);
+ self.inner = core::ptr::null_mut();
+ ret
+ }
+}
+/// The channel ID involved in the warning.
+///
+/// All-0s indicates a warning unrelated to a specific channel.
+#[no_mangle]
+pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> *const [u8; 32] {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id;
+ inner_val
+}
+/// The channel ID involved in the warning.
+///
+/// All-0s indicates a warning unrelated to a specific channel.
+#[no_mangle]
+pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::c_types::ThirtyTwoBytes) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = val.data;
+}
+/// A possibly human-readable warning description.
+/// The string should be sanitized before it is used (e.g. emitted to logs or printed to
+/// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
+/// the terminal emulator or the logging subsystem.
+#[no_mangle]
+pub extern "C" fn WarningMessage_get_data(this_ptr: &WarningMessage) -> crate::c_types::Str {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().data;
+ inner_val.as_str().into()
+}
+/// A possibly human-readable warning description.
+/// The string should be sanitized before it is used (e.g. emitted to logs or printed to
+/// stdout). Otherwise, a well crafted error message may trigger a security vulnerability in
+/// the terminal emulator or the logging subsystem.
+#[no_mangle]
+pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val: crate::c_types::Str) {
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.data = val.into_string();
+}
+/// Constructs a new WarningMessage given each field
+#[must_use]
+#[no_mangle]
+pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> WarningMessage {
+ WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage {
+ channel_id: channel_id_arg.data,
+ data: data_arg.into_string(),
+ }), is_owned: true }
+}
+impl Clone for WarningMessage {
+ fn clone(&self) -> Self {
+ Self {
+ inner: if <*mut nativeWarningMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
+ ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
+ is_owned: true,
+ }
+ }
+}
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+pub(crate) extern "C" fn WarningMessage_clone_void(this_ptr: *const c_void) -> *mut c_void {
+ Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeWarningMessage)).clone() })) as *mut c_void
+}
+#[no_mangle]
+/// Creates a copy of the WarningMessage
+pub extern "C" fn WarningMessage_clone(orig: &WarningMessage) -> WarningMessage {
+ orig.clone()
+}
+
use lightning::ln::msgs::Ping as nativePingImport;
pub(crate) type nativePing = nativePingImport;
pub(crate) fn take_inner(mut self) -> *mut nativePing {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for Ping {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativePing>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativePong {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for Pong {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativePong>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) {
unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val;
}
+/// The channel type that this channel will represent. If none is set, we derive the channel
+/// type from the intersection of our feature bits with our counterparty's feature bits from
+/// the Init message.
+///
+/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
+ let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// The channel type that this channel will represent. If none is set, we derive the channel
+/// type from the intersection of our feature bits with our counterparty's feature bits from
+/// the Init message.
+///
+/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
+}
impl Clone for OpenChannel {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeOpenChannel>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) {
unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust();
}
+/// The channel type that this channel will represent. If none is set, we derive the channel
+/// type from the intersection of our feature bits with our counterparty's feature bits from
+/// the Init message.
+///
+/// This is required to match the equivalent field in [`OpenChannel::channel_type`].
+///
+/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn AcceptChannel_get_channel_type(this_ptr: &AcceptChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
+ let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
+ let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
+ local_inner_val
+}
+/// The channel type that this channel will represent. If none is set, we derive the channel
+/// type from the intersection of our feature bits with our counterparty's feature bits from
+/// the Init message.
+///
+/// This is required to match the equivalent field in [`OpenChannel::channel_type`].
+///
+/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
+#[no_mangle]
+pub extern "C" fn AcceptChannel_set_channel_type(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) {
+ let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) };
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val;
+}
impl Clone for AcceptChannel {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for FundingCreated {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeFundingCreated>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for FundingSigned {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeFundingSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeFundingLocked {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for FundingLocked {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeFundingLocked>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeFundingLocked>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for Shutdown {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeShutdown>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ClosingSignedFeeRange {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
#[no_mangle]
pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
- let mut local_inner_val = crate::lightning::ln::msgs::ClosingSignedFeeRange { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::ClosingSignedFeeRange<>) as *mut _ }, is_owned: false };
+ let mut local_inner_val = crate::lightning::ln::msgs::ClosingSignedFeeRange { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::ClosingSignedFeeRange<>) as *mut _ }, is_owned: false };
local_inner_val
}
/// The minimum and maximum fees which the sender is willing to accept, provided only by new
impl Clone for ClosingSigned {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeClosingSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for UpdateAddHTLC {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for UpdateFulfillHTLC {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for UpdateFailHTLC {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for UpdateFailMalformedHTLC {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for CommitmentSigned {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for RevokeAndACK {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for UpdateFee {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeUpdateFee>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for DataLossProtect {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ChannelReestablish {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for AnnouncementSignatures {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
port: u16,
},
/// An old-style Tor onion address/port on which the peer is listening.
- OnionV2 {
- /// The bytes (usually encoded in base32 with \".onion\" appended)
- addr: crate::c_types::TenBytes,
- /// The port on which the node is listening
- port: u16,
- },
+ ///
+ /// This field is deprecated and the Tor network generally no longer supports V2 Onion
+ /// addresses. Thus, the details are not parsed here.
+ OnionV2(crate::c_types::TwelveBytes),
/// A new-style Tor onion address/port on which the peer is listening.
/// To create the human-readable \"hostname\", concatenate ed25519_pubkey, checksum, and version,
/// wrap as base32 and append \".onion\".
port: port_nonref,
}
},
- NetAddress::OnionV2 {ref addr, ref port, } => {
- let mut addr_nonref = (*addr).clone();
- let mut port_nonref = (*port).clone();
- nativeNetAddress::OnionV2 {
- addr: addr_nonref.data,
- port: port_nonref,
- }
+ NetAddress::OnionV2 (ref a, ) => {
+ let mut a_nonref = (*a).clone();
+ nativeNetAddress::OnionV2 (
+ a_nonref.data,
+ )
},
NetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
port: port,
}
},
- NetAddress::OnionV2 {mut addr, mut port, } => {
- nativeNetAddress::OnionV2 {
- addr: addr.data,
- port: port,
- }
+ NetAddress::OnionV2 (mut a, ) => {
+ nativeNetAddress::OnionV2 (
+ a.data,
+ )
},
NetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
nativeNetAddress::OnionV3 {
port: port_nonref,
}
},
- nativeNetAddress::OnionV2 {ref addr, ref port, } => {
- let mut addr_nonref = (*addr).clone();
- let mut port_nonref = (*port).clone();
- NetAddress::OnionV2 {
- addr: crate::c_types::TenBytes { data: addr_nonref },
- port: port_nonref,
- }
+ nativeNetAddress::OnionV2 (ref a, ) => {
+ let mut a_nonref = (*a).clone();
+ NetAddress::OnionV2 (
+ crate::c_types::TwelveBytes { data: a_nonref },
+ )
},
nativeNetAddress::OnionV3 {ref ed25519_pubkey, ref checksum, ref version, ref port, } => {
let mut ed25519_pubkey_nonref = (*ed25519_pubkey).clone();
port: port,
}
},
- nativeNetAddress::OnionV2 {mut addr, mut port, } => {
- NetAddress::OnionV2 {
- addr: crate::c_types::TenBytes { data: addr },
- port: port,
- }
+ nativeNetAddress::OnionV2 (mut a, ) => {
+ NetAddress::OnionV2 (
+ crate::c_types::TwelveBytes { data: a },
+ )
},
nativeNetAddress::OnionV3 {mut ed25519_pubkey, mut checksum, mut version, mut port, } => {
NetAddress::OnionV3 {
}
#[no_mangle]
/// Utility method to constructs a new OnionV2-variant NetAddress
-pub extern "C" fn NetAddress_onion_v2(addr: crate::c_types::TenBytes, port: u16) -> NetAddress {
- NetAddress::OnionV2 {
- addr,
- port,
- }
+pub extern "C" fn NetAddress_onion_v2(a: crate::c_types::TwelveBytes) -> NetAddress {
+ NetAddress::OnionV2(a, )
}
#[no_mangle]
/// Utility method to constructs a new OnionV3-variant NetAddress
pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for UnsignedNodeAnnouncement {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for NodeAnnouncement {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for UnsignedChannelAnnouncement {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ChannelAnnouncement {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for UnsignedChannelUpdate {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ChannelUpdate {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for QueryChannelRange {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ReplyChannelRange {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for QueryShortChannelIds {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ReplyShortChannelIdsEnd {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for GossipTimestampFilter {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
/// The peer did something harmless that we weren't able to meaningfully process.
/// If the error is logged, log it at the given level.
IgnoreAndLog(crate::lightning::util::logger::Level),
+ /// The peer provided us with a gossip message which we'd already seen. In most cases this
+ /// should be ignored, but it may result in the message being forwarded if it is a duplicate of
+ /// our own channel announcements.
+ IgnoreDuplicateGossip,
/// The peer did something incorrect. Tell them.
SendErrorMessage {
/// The message to send.
msg: crate::lightning::ln::msgs::ErrorMessage,
},
+ /// The peer did something incorrect. Tell them without closing any channels.
+ SendWarningMessage {
+ /// The message to send.
+ msg: crate::lightning::ln::msgs::WarningMessage,
+ /// The peer may have done something harmless that we weren't able to meaningfully process,
+ /// though we should still tell them about it.
+ /// If this event is logged, log it at the given level.
+ log_level: crate::lightning::util::logger::Level,
+ },
}
use lightning::ln::msgs::ErrorAction as nativeErrorAction;
impl ErrorAction {
a_nonref.into_native(),
)
},
+ ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
ErrorAction::SendErrorMessage {ref msg, } => {
let mut msg_nonref = (*msg).clone();
nativeErrorAction::SendErrorMessage {
msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
}
},
+ ErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
+ let mut msg_nonref = (*msg).clone();
+ let mut log_level_nonref = (*log_level).clone();
+ nativeErrorAction::SendWarningMessage {
+ msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
+ log_level: log_level_nonref.into_native(),
+ }
+ },
}
}
#[allow(unused)]
a.into_native(),
)
},
+ ErrorAction::IgnoreDuplicateGossip => nativeErrorAction::IgnoreDuplicateGossip,
ErrorAction::SendErrorMessage {mut msg, } => {
nativeErrorAction::SendErrorMessage {
msg: *unsafe { Box::from_raw(msg.take_inner()) },
}
},
+ ErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
+ nativeErrorAction::SendWarningMessage {
+ msg: *unsafe { Box::from_raw(msg.take_inner()) },
+ log_level: log_level.into_native(),
+ }
+ },
}
}
#[allow(unused)]
match native {
nativeErrorAction::DisconnectPeer {ref msg, } => {
let mut msg_nonref = (*msg).clone();
- let mut local_msg_nonref = crate::lightning::ln::msgs::ErrorMessage { inner: if msg_nonref.is_none() { std::ptr::null_mut() } else { { ObjOps::heap_alloc((msg_nonref.unwrap())) } }, is_owned: true };
+ let mut local_msg_nonref = crate::lightning::ln::msgs::ErrorMessage { inner: if msg_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((msg_nonref.unwrap())) } }, is_owned: true };
ErrorAction::DisconnectPeer {
msg: local_msg_nonref,
}
crate::lightning::util::logger::Level::native_into(a_nonref),
)
},
+ nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
nativeErrorAction::SendErrorMessage {ref msg, } => {
let mut msg_nonref = (*msg).clone();
ErrorAction::SendErrorMessage {
msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
}
},
+ nativeErrorAction::SendWarningMessage {ref msg, ref log_level, } => {
+ let mut msg_nonref = (*msg).clone();
+ let mut log_level_nonref = (*log_level).clone();
+ ErrorAction::SendWarningMessage {
+ msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
+ log_level: crate::lightning::util::logger::Level::native_into(log_level_nonref),
+ }
+ },
}
}
#[allow(unused)]
pub(crate) fn native_into(native: nativeErrorAction) -> Self {
match native {
nativeErrorAction::DisconnectPeer {mut msg, } => {
- let mut local_msg = crate::lightning::ln::msgs::ErrorMessage { inner: if msg.is_none() { std::ptr::null_mut() } else { { ObjOps::heap_alloc((msg.unwrap())) } }, is_owned: true };
+ let mut local_msg = crate::lightning::ln::msgs::ErrorMessage { inner: if msg.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((msg.unwrap())) } }, is_owned: true };
ErrorAction::DisconnectPeer {
msg: local_msg,
}
crate::lightning::util::logger::Level::native_into(a),
)
},
+ nativeErrorAction::IgnoreDuplicateGossip => ErrorAction::IgnoreDuplicateGossip,
nativeErrorAction::SendErrorMessage {mut msg, } => {
ErrorAction::SendErrorMessage {
msg: crate::lightning::ln::msgs::ErrorMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
}
},
+ nativeErrorAction::SendWarningMessage {mut msg, mut log_level, } => {
+ ErrorAction::SendWarningMessage {
+ msg: crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(msg), is_owned: true },
+ log_level: crate::lightning::util::logger::Level::native_into(log_level),
+ }
+ },
}
}
}
ErrorAction::IgnoreAndLog(a, )
}
#[no_mangle]
+/// Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
+pub extern "C" fn ErrorAction_ignore_duplicate_gossip() -> ErrorAction {
+ ErrorAction::IgnoreDuplicateGossip}
+#[no_mangle]
/// Utility method to constructs a new SendErrorMessage-variant ErrorAction
pub extern "C" fn ErrorAction_send_error_message(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction {
ErrorAction::SendErrorMessage {
msg,
}
}
+#[no_mangle]
+/// Utility method to constructs a new SendWarningMessage-variant ErrorAction
+pub extern "C" fn ErrorAction_send_warning_message(msg: crate::lightning::ln::msgs::WarningMessage, log_level: crate::lightning::util::logger::Level) -> ErrorAction {
+ ErrorAction::SendWarningMessage {
+ msg,
+ log_level,
+ }
+}
use lightning::ln::msgs::LightningError as nativeLightningErrorImport;
pub(crate) type nativeLightningError = nativeLightningErrorImport;
pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for LightningError {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeLightningError>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
#[no_mangle]
pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
- let mut local_inner_val = crate::lightning::ln::msgs::UpdateFee { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::UpdateFee<>) as *mut _ }, is_owned: false };
+ let mut local_inner_val = crate::lightning::ln::msgs::UpdateFee { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::UpdateFee<>) as *mut _ }, is_owned: false };
local_inner_val
}
/// An update_fee message which should be sent
impl Clone for CommitmentUpdate {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for ChannelMessageHandler {
+impl core::ops::Deref for ChannelMessageHandler {
type Target = Self;
fn deref(&self) -> &Self {
self
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for RoutingMessageHandler {
+impl core::ops::Deref for RoutingMessageHandler {
type Target = Self;
fn deref(&self) -> &Self {
self
}
mod fuzzy_internal_msgs {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
#[no_mangle]
local_res
}
#[no_mangle]
+/// Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read
+pub extern "C" fn WarningMessage_write(obj: &WarningMessage) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
+}
+#[no_mangle]
+pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {
+ crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) })
+}
+#[no_mangle]
+/// Read a WarningMessage from a byte array, created by WarningMessage_write
+pub extern "C" fn WarningMessage_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WarningMessageDecodeErrorZ {
+ let res: Result<lightning::ln::msgs::WarningMessage, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj(ser);
+ let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::WarningMessage { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+ local_res
+}
+#[no_mangle]
/// Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read
pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z {
crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())