X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Fln%2Fmsgs.rs;h=619a41d2bca98b6bcc5a95cd5f7491ac568a7a2a;hp=a005cf49b5ee769d9371091014e161f816953e66;hb=a82e075188fc15a103234832686915c196bfe240;hpb=d9866e870bbe080412dc70b1421e28a756e4407e diff --git a/lightning-c-bindings/src/lightning/ln/msgs.rs b/lightning-c-bindings/src/lightning/ln/msgs.rs index a005cf4..619a41d 100644 --- a/lightning-c-bindings/src/lightning/ln/msgs.rs +++ b/lightning-c-bindings/src/lightning/ln/msgs.rs @@ -23,6 +23,7 @@ //! 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 bitcoin::hashes::Hash; use crate::c_types::*; @@ -140,7 +141,7 @@ impl Init { #[no_mangle] pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features; - crate::lightning::ln::features::InitFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::features::InitFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// The relevant features which the sender supports #[no_mangle] @@ -223,7 +224,7 @@ impl ErrorMessage { #[no_mangle] pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID involved in the error #[no_mangle] @@ -237,23 +238,23 @@ pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut v #[no_mangle] pub extern "C" fn ErrorMessage_get_data(this_ptr: &ErrorMessage) -> crate::c_types::Str { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.data; - (*inner_val).as_str().into() + 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. #[no_mangle] -pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::derived::CVec_u8Z) { - unsafe { &mut *this_ptr.inner }.data = String::from_utf8(val.into_rust()).unwrap(); +pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: crate::c_types::Str) { + unsafe { &mut *this_ptr.inner }.data = val.into_string(); } /// Constructs a new ErrorMessage given each field #[must_use] #[no_mangle] -pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::derived::CVec_u8Z) -> ErrorMessage { +pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> ErrorMessage { ErrorMessage { inner: Box::into_raw(Box::new(nativeErrorMessage { channel_id: channel_id_arg.data, - data: String::from_utf8(data_arg.into_rust()).unwrap(), + data: data_arg.into_string(), })), is_owned: true } } impl Clone for ErrorMessage { @@ -324,7 +325,7 @@ impl Ping { #[no_mangle] pub extern "C" fn Ping_get_ponglen(this_ptr: &Ping) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.ponglen; - (*inner_val) + *inner_val } /// The desired response length #[no_mangle] @@ -336,7 +337,7 @@ pub extern "C" fn Ping_set_ponglen(this_ptr: &mut Ping, mut val: u16) { #[no_mangle] pub extern "C" fn Ping_get_byteslen(this_ptr: &Ping) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.byteslen; - (*inner_val) + *inner_val } /// The ping packet size. /// This field is not sent on the wire. byteslen zeros are sent. @@ -422,7 +423,7 @@ impl Pong { #[no_mangle] pub extern "C" fn Pong_get_byteslen(this_ptr: &Pong) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.byteslen; - (*inner_val) + *inner_val } /// The pong packet size. /// This field is not sent on the wire. byteslen zeros are sent. @@ -506,7 +507,7 @@ impl OpenChannel { #[no_mangle] pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; - (*inner_val).as_inner() + inner_val.as_inner() } /// The genesis hash of the blockchain where the channel is to be opened #[no_mangle] @@ -517,7 +518,7 @@ pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val #[no_mangle] pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id; - &(*inner_val) + inner_val } /// A temporary channel ID, until the funding outpoint is announced #[no_mangle] @@ -528,7 +529,7 @@ pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChanne #[no_mangle] pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_satoshis; - (*inner_val) + *inner_val } /// The channel value #[no_mangle] @@ -539,7 +540,7 @@ pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, m #[no_mangle] pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.push_msat; - (*inner_val) + *inner_val } /// The amount to push to the counterparty as part of the open, in milli-satoshi #[no_mangle] @@ -550,7 +551,7 @@ pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: #[no_mangle] pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.dust_limit_satoshis; - (*inner_val) + *inner_val } /// The threshold below which outputs on transactions broadcast by sender will be omitted #[no_mangle] @@ -561,7 +562,7 @@ pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel #[no_mangle] pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat; - (*inner_val) + *inner_val } /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi #[no_mangle] @@ -572,7 +573,7 @@ pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut O #[no_mangle] pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis; - (*inner_val) + *inner_val } /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel #[no_mangle] @@ -583,7 +584,7 @@ pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenCh #[no_mangle] pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat; - (*inner_val) + *inner_val } /// The minimum HTLC size incoming to sender, in milli-satoshi #[no_mangle] @@ -594,7 +595,7 @@ pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, #[no_mangle] pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw; - (*inner_val) + *inner_val } /// The feerate per 1000-weight of sender generated transactions, until updated by update_fee #[no_mangle] @@ -605,7 +606,7 @@ pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut #[no_mangle] pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay; - (*inner_val) + *inner_val } /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction #[no_mangle] @@ -616,7 +617,7 @@ pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut #[no_mangle] pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_accepted_htlcs; - (*inner_val) + *inner_val } /// The maximum number of inbound HTLCs towards sender #[no_mangle] @@ -627,7 +628,7 @@ pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, #[no_mangle] pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The sender's key controlling the funding transaction #[no_mangle] @@ -638,7 +639,7 @@ pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut #[no_mangle] pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// Used to derive a revocation key for transactions broadcast by counterparty #[no_mangle] @@ -649,7 +650,7 @@ pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChanne #[no_mangle] pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// A payment key to sender for transactions broadcast by counterparty #[no_mangle] @@ -660,7 +661,7 @@ pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut #[no_mangle] pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// Used to derive a payment key to sender for transactions broadcast by sender #[no_mangle] @@ -671,7 +672,7 @@ pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenC #[no_mangle] pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// Used to derive an HTLC payment key to sender #[no_mangle] @@ -682,7 +683,7 @@ pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut #[no_mangle] pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_per_commitment_point; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The first to-be-broadcast-by-sender transaction's per commitment point #[no_mangle] @@ -693,7 +694,7 @@ pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut Open #[no_mangle] pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_flags; - (*inner_val) + *inner_val } /// Channel flags #[no_mangle] @@ -768,7 +769,7 @@ impl AcceptChannel { #[no_mangle] pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id; - &(*inner_val) + inner_val } /// A temporary channel ID, until the funding outpoint is announced #[no_mangle] @@ -779,7 +780,7 @@ pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptCh #[no_mangle] pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.dust_limit_satoshis; - (*inner_val) + *inner_val } /// The threshold below which outputs on transactions broadcast by sender will be omitted #[no_mangle] @@ -790,7 +791,7 @@ pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptCha #[no_mangle] pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_htlc_value_in_flight_msat; - (*inner_val) + *inner_val } /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi #[no_mangle] @@ -801,7 +802,7 @@ pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut #[no_mangle] pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_reserve_satoshis; - (*inner_val) + *inner_val } /// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel #[no_mangle] @@ -812,7 +813,7 @@ pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut Acce #[no_mangle] pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat; - (*inner_val) + *inner_val } /// The minimum HTLC size incoming to sender, in milli-satoshi #[no_mangle] @@ -823,7 +824,7 @@ pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChann #[no_mangle] pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.minimum_depth; - (*inner_val) + *inner_val } /// Minimum depth of the funding transaction before the channel is considered open #[no_mangle] @@ -834,7 +835,7 @@ pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, #[no_mangle] pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay; - (*inner_val) + *inner_val } /// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction #[no_mangle] @@ -845,7 +846,7 @@ pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, #[no_mangle] pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.max_accepted_htlcs; - (*inner_val) + *inner_val } /// The maximum number of inbound HTLCs towards sender #[no_mangle] @@ -856,7 +857,7 @@ pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChan #[no_mangle] pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_pubkey; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The sender's key controlling the funding transaction #[no_mangle] @@ -867,7 +868,7 @@ pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, #[no_mangle] pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_basepoint; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// Used to derive a revocation key for transactions broadcast by counterparty #[no_mangle] @@ -878,7 +879,7 @@ pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptCh #[no_mangle] pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_point; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// A payment key to sender for transactions broadcast by counterparty #[no_mangle] @@ -889,7 +890,7 @@ pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, #[no_mangle] pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.delayed_payment_basepoint; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// Used to derive a payment key to sender for transactions broadcast by sender #[no_mangle] @@ -900,7 +901,7 @@ pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut Acc #[no_mangle] pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_basepoint; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty #[no_mangle] @@ -911,7 +912,7 @@ pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, #[no_mangle] pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_per_commitment_point; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The first to-be-broadcast-by-sender transaction's per commitment point #[no_mangle] @@ -986,7 +987,7 @@ impl FundingCreated { #[no_mangle] pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.temporary_channel_id; - &(*inner_val) + inner_val } /// A temporary channel ID, until the funding is established #[no_mangle] @@ -997,7 +998,7 @@ pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut Funding #[no_mangle] pub extern "C" fn FundingCreated_get_funding_txid(this_ptr: &FundingCreated) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_txid; - (*inner_val).as_inner() + inner_val.as_inner() } /// The funding transaction ID #[no_mangle] @@ -1008,7 +1009,7 @@ pub extern "C" fn FundingCreated_set_funding_txid(this_ptr: &mut FundingCreated, #[no_mangle] pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCreated) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.funding_output_index; - (*inner_val) + *inner_val } /// The specific output index funding this channel #[no_mangle] @@ -1019,7 +1020,7 @@ pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut Funding #[no_mangle] pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// The signature of the channel initiator (funder) on the funding transaction #[no_mangle] @@ -1105,7 +1106,7 @@ impl FundingSigned { #[no_mangle] pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -1116,7 +1117,7 @@ pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut #[no_mangle] pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// The signature of the channel acceptor (fundee) on the funding transaction #[no_mangle] @@ -1200,7 +1201,7 @@ impl FundingLocked { #[no_mangle] pub extern "C" fn FundingLocked_get_channel_id(this_ptr: &FundingLocked) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -1211,7 +1212,7 @@ pub extern "C" fn FundingLocked_set_channel_id(this_ptr: &mut FundingLocked, mut #[no_mangle] pub extern "C" fn FundingLocked_get_next_per_commitment_point(this_ptr: &FundingLocked) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_per_commitment_point; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The per-commitment point of the second commitment transaction #[no_mangle] @@ -1295,7 +1296,7 @@ impl Shutdown { #[no_mangle] pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -1307,7 +1308,7 @@ pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crat #[no_mangle] pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_types::u8slice { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.scriptpubkey; - crate::c_types::u8slice::from_slice(&(*inner_val)[..]) + crate::c_types::u8slice::from_slice(&inner_val[..]) } /// The destination of this peer's funds on closing. /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh. @@ -1392,7 +1393,7 @@ impl ClosingSigned { #[no_mangle] pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -1403,7 +1404,7 @@ pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut #[no_mangle] pub extern "C" fn ClosingSigned_get_fee_satoshis(this_ptr: &ClosingSigned) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_satoshis; - (*inner_val) + *inner_val } /// The proposed total fee for the closing transaction #[no_mangle] @@ -1414,7 +1415,7 @@ pub extern "C" fn ClosingSigned_set_fee_satoshis(this_ptr: &mut ClosingSigned, m #[no_mangle] pub extern "C" fn ClosingSigned_get_signature(this_ptr: &ClosingSigned) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// A signature on the closing transaction #[no_mangle] @@ -1499,7 +1500,7 @@ impl UpdateAddHTLC { #[no_mangle] pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -1510,7 +1511,7 @@ pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut #[no_mangle] pub extern "C" fn UpdateAddHTLC_get_htlc_id(this_ptr: &UpdateAddHTLC) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id; - (*inner_val) + *inner_val } /// The HTLC ID #[no_mangle] @@ -1521,7 +1522,7 @@ pub extern "C" fn UpdateAddHTLC_set_htlc_id(this_ptr: &mut UpdateAddHTLC, mut va #[no_mangle] pub extern "C" fn UpdateAddHTLC_get_amount_msat(this_ptr: &UpdateAddHTLC) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.amount_msat; - (*inner_val) + *inner_val } /// The HTLC value in milli-satoshi #[no_mangle] @@ -1532,18 +1533,18 @@ pub extern "C" fn UpdateAddHTLC_set_amount_msat(this_ptr: &mut UpdateAddHTLC, mu #[no_mangle] pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_hash; - &(*inner_val).0 + &inner_val.0 } /// The payment hash, the pre-image of which controls HTLC redemption #[no_mangle] pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *this_ptr.inner }.payment_hash = ::lightning::ln::channelmanager::PaymentHash(val.data); + unsafe { &mut *this_ptr.inner }.payment_hash = ::lightning::ln::PaymentHash(val.data); } /// The expiry height of the HTLC #[no_mangle] pub extern "C" fn UpdateAddHTLC_get_cltv_expiry(this_ptr: &UpdateAddHTLC) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry; - (*inner_val) + *inner_val } /// The expiry height of the HTLC #[no_mangle] @@ -1618,7 +1619,7 @@ impl UpdateFulfillHTLC { #[no_mangle] pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -1629,7 +1630,7 @@ pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillH #[no_mangle] pub extern "C" fn UpdateFulfillHTLC_get_htlc_id(this_ptr: &UpdateFulfillHTLC) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id; - (*inner_val) + *inner_val } /// The HTLC ID #[no_mangle] @@ -1640,12 +1641,12 @@ pub extern "C" fn UpdateFulfillHTLC_set_htlc_id(this_ptr: &mut UpdateFulfillHTLC #[no_mangle] pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.payment_preimage; - &(*inner_val).0 + &inner_val.0 } /// The pre-image of the payment hash, allowing HTLC redemption #[no_mangle] pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *this_ptr.inner }.payment_preimage = ::lightning::ln::channelmanager::PaymentPreimage(val.data); + unsafe { &mut *this_ptr.inner }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data); } /// Constructs a new UpdateFulfillHTLC given each field #[must_use] @@ -1654,7 +1655,7 @@ pub extern "C" fn UpdateFulfillHTLC_new(mut channel_id_arg: crate::c_types::Thir UpdateFulfillHTLC { inner: Box::into_raw(Box::new(nativeUpdateFulfillHTLC { channel_id: channel_id_arg.data, htlc_id: htlc_id_arg, - payment_preimage: ::lightning::ln::channelmanager::PaymentPreimage(payment_preimage_arg.data), + payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data), })), is_owned: true } } impl Clone for UpdateFulfillHTLC { @@ -1725,7 +1726,7 @@ impl UpdateFailHTLC { #[no_mangle] pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -1736,7 +1737,7 @@ pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, m #[no_mangle] pub extern "C" fn UpdateFailHTLC_get_htlc_id(this_ptr: &UpdateFailHTLC) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id; - (*inner_val) + *inner_val } /// The HTLC ID #[no_mangle] @@ -1811,7 +1812,7 @@ impl UpdateFailMalformedHTLC { #[no_mangle] pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -1822,7 +1823,7 @@ pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFa #[no_mangle] pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_id; - (*inner_val) + *inner_val } /// The HTLC ID #[no_mangle] @@ -1833,7 +1834,7 @@ pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailM #[no_mangle] pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.failure_code; - (*inner_val) + *inner_val } /// The failure code #[no_mangle] @@ -1908,7 +1909,7 @@ impl CommitmentSigned { #[no_mangle] pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -1919,7 +1920,7 @@ pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigne #[no_mangle] pub extern "C" fn CommitmentSigned_get_signature(this_ptr: &CommitmentSigned) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// A signature on the commitment transaction #[no_mangle] @@ -2011,7 +2012,7 @@ impl RevokeAndACK { #[no_mangle] pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -2022,7 +2023,7 @@ pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut v #[no_mangle] pub extern "C" fn RevokeAndACK_get_per_commitment_secret(this_ptr: &RevokeAndACK) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.per_commitment_secret; - &(*inner_val) + inner_val } /// The secret corresponding to the per-commitment point #[no_mangle] @@ -2033,7 +2034,7 @@ pub extern "C" fn RevokeAndACK_set_per_commitment_secret(this_ptr: &mut RevokeAn #[no_mangle] pub extern "C" fn RevokeAndACK_get_next_per_commitment_point(this_ptr: &RevokeAndACK) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_per_commitment_point; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The next sender-broadcast commitment transaction's per-commitment point #[no_mangle] @@ -2118,7 +2119,7 @@ impl UpdateFee { #[no_mangle] pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -2129,7 +2130,7 @@ pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: cr #[no_mangle] pub extern "C" fn UpdateFee_get_feerate_per_kw(this_ptr: &UpdateFee) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.feerate_per_kw; - (*inner_val) + *inner_val } /// Fee rate per 1000-weight of the transaction #[no_mangle] @@ -2217,7 +2218,7 @@ impl DataLossProtect { #[no_mangle] pub extern "C" fn DataLossProtect_get_your_last_per_commitment_secret(this_ptr: &DataLossProtect) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.your_last_per_commitment_secret; - &(*inner_val) + inner_val } /// Proof that the sender knows the per-commitment secret of a specific commitment transaction /// belonging to the recipient @@ -2229,7 +2230,7 @@ pub extern "C" fn DataLossProtect_set_your_last_per_commitment_secret(this_ptr: #[no_mangle] pub extern "C" fn DataLossProtect_get_my_current_per_commitment_point(this_ptr: &DataLossProtect) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.my_current_per_commitment_point; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The sender's per-commitment point for their current commitment transaction #[no_mangle] @@ -2313,7 +2314,7 @@ impl ChannelReestablish { #[no_mangle] pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -2324,7 +2325,7 @@ pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReesta #[no_mangle] pub extern "C" fn ChannelReestablish_get_next_local_commitment_number(this_ptr: &ChannelReestablish) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_local_commitment_number; - (*inner_val) + *inner_val } /// The next commitment number for the sender #[no_mangle] @@ -2335,7 +2336,7 @@ pub extern "C" fn ChannelReestablish_set_next_local_commitment_number(this_ptr: #[no_mangle] pub extern "C" fn ChannelReestablish_get_next_remote_commitment_number(this_ptr: &ChannelReestablish) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.next_remote_commitment_number; - (*inner_val) + *inner_val } /// The next commitment number for the recipient #[no_mangle] @@ -2410,7 +2411,7 @@ impl AnnouncementSignatures { #[no_mangle] pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_id; - &(*inner_val) + inner_val } /// The channel ID #[no_mangle] @@ -2421,7 +2422,7 @@ pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut Announcem #[no_mangle] pub extern "C" fn AnnouncementSignatures_get_short_channel_id(this_ptr: &AnnouncementSignatures) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id; - (*inner_val) + *inner_val } /// The short channel ID #[no_mangle] @@ -2432,7 +2433,7 @@ pub extern "C" fn AnnouncementSignatures_set_short_channel_id(this_ptr: &mut Ann #[no_mangle] pub extern "C" fn AnnouncementSignatures_get_node_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// A signature by the node key #[no_mangle] @@ -2443,7 +2444,7 @@ pub extern "C" fn AnnouncementSignatures_set_node_signature(this_ptr: &mut Annou #[no_mangle] pub extern "C" fn AnnouncementSignatures_get_bitcoin_signature(this_ptr: &AnnouncementSignatures) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// A signature by the funding key #[no_mangle] @@ -2676,6 +2677,40 @@ pub extern "C" fn NetAddress_clone(orig: &NetAddress) -> NetAddress { orig.clone() } #[no_mangle] +/// Utility method to constructs a new IPv4-variant NetAddress +pub extern "C" fn NetAddress_ipv4(addr: crate::c_types::FourBytes, port: u16) -> NetAddress { + NetAddress::IPv4 { + addr, + port, + } +} +#[no_mangle] +/// Utility method to constructs a new IPv6-variant NetAddress +pub extern "C" fn NetAddress_ipv6(addr: crate::c_types::SixteenBytes, port: u16) -> NetAddress { + NetAddress::IPv6 { + addr, + port, + } +} +#[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, + } +} +#[no_mangle] +/// Utility method to constructs a new OnionV3-variant NetAddress +pub extern "C" fn NetAddress_onion_v3(ed25519_pubkey: crate::c_types::ThirtyTwoBytes, checksum: u16, version: u8, port: u16) -> NetAddress { + NetAddress::OnionV3 { + ed25519_pubkey, + checksum, + version, + port, + } +} +#[no_mangle] /// Serialize the NetAddress object into a byte array which can be read by NetAddress_read pub extern "C" fn NetAddress_write(obj: &NetAddress) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) @@ -2687,6 +2722,13 @@ pub extern "C" fn Result_read(ser: crate::c_types::u8slice) -> crate::c_types::d let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = match o { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::NetAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { e }).into() }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; local_res } +#[no_mangle] +/// Read a NetAddress from a byte array, created by NetAddress_write +pub extern "C" fn NetAddress_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NetAddressDecodeErrorZ { + let res = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::NetAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() }; + local_res +} use lightning::ln::msgs::UnsignedNodeAnnouncement as nativeUnsignedNodeAnnouncementImport; type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport; @@ -2736,7 +2778,7 @@ impl UnsignedNodeAnnouncement { #[no_mangle] pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features; - crate::lightning::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::features::NodeFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// The advertised features #[no_mangle] @@ -2747,7 +2789,7 @@ pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedN #[no_mangle] pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp; - (*inner_val) + *inner_val } /// A strictly monotonic announcement counter, with gaps allowed #[no_mangle] @@ -2759,7 +2801,7 @@ pub extern "C" fn UnsignedNodeAnnouncement_set_timestamp(this_ptr: &mut Unsigned #[no_mangle] pub extern "C" fn UnsignedNodeAnnouncement_get_node_id(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The node_id this announcement originated from (don't rebroadcast the node_announcement back /// to this node). @@ -2771,7 +2813,7 @@ pub extern "C" fn UnsignedNodeAnnouncement_set_node_id(this_ptr: &mut UnsignedNo #[no_mangle] pub extern "C" fn UnsignedNodeAnnouncement_get_rgb(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 3] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.rgb; - &(*inner_val) + inner_val } /// An RGB color for UI purposes #[no_mangle] @@ -2783,7 +2825,7 @@ pub extern "C" fn UnsignedNodeAnnouncement_set_rgb(this_ptr: &mut UnsignedNodeAn #[no_mangle] pub extern "C" fn UnsignedNodeAnnouncement_get_alias(this_ptr: &UnsignedNodeAnnouncement) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.alias; - &(*inner_val) + inner_val } /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee /// of uniqueness. @@ -2865,7 +2907,7 @@ impl NodeAnnouncement { #[no_mangle] pub extern "C" fn NodeAnnouncement_get_signature(this_ptr: &NodeAnnouncement) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// The signature by the node key #[no_mangle] @@ -2876,7 +2918,7 @@ pub extern "C" fn NodeAnnouncement_set_signature(this_ptr: &mut NodeAnnouncement #[no_mangle] pub extern "C" fn NodeAnnouncement_get_contents(this_ptr: &NodeAnnouncement) -> crate::lightning::ln::msgs::UnsignedNodeAnnouncement { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents; - crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::msgs::UnsignedNodeAnnouncement { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// The actual content of the announcement #[no_mangle] @@ -2960,7 +3002,7 @@ impl UnsignedChannelAnnouncement { #[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features; - crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// The advertised channel features #[no_mangle] @@ -2971,7 +3013,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut Unsign #[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; - (*inner_val).as_inner() + inner_val.as_inner() } /// The genesis hash of the blockchain where the channel is to be opened #[no_mangle] @@ -2982,7 +3024,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut Unsi #[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_get_short_channel_id(this_ptr: &UnsignedChannelAnnouncement) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id; - (*inner_val) + *inner_val } /// The short channel ID #[no_mangle] @@ -2993,7 +3035,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_set_short_channel_id(this_ptr: &mu #[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_1; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// One of the two node_ids which are endpoints of this channel #[no_mangle] @@ -3004,7 +3046,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_1(this_ptr: &mut Unsig #[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_get_node_id_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_id_2; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The other of the two node_ids which are endpoints of this channel #[no_mangle] @@ -3015,7 +3057,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_set_node_id_2(this_ptr: &mut Unsig #[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_1(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_1; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The funding key for the first node #[no_mangle] @@ -3026,7 +3068,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_set_bitcoin_key_1(this_ptr: &mut U #[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_get_bitcoin_key_2(this_ptr: &UnsignedChannelAnnouncement) -> crate::c_types::PublicKey { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_key_2; - crate::c_types::PublicKey::from_rust(&(*inner_val)) + crate::c_types::PublicKey::from_rust(&inner_val) } /// The funding key for the second node #[no_mangle] @@ -3101,7 +3143,7 @@ impl ChannelAnnouncement { #[no_mangle] pub extern "C" fn ChannelAnnouncement_get_node_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_1; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// Authentication of the announcement by the first public node #[no_mangle] @@ -3112,7 +3154,7 @@ pub extern "C" fn ChannelAnnouncement_set_node_signature_1(this_ptr: &mut Channe #[no_mangle] pub extern "C" fn ChannelAnnouncement_get_node_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_signature_2; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// Authentication of the announcement by the second public node #[no_mangle] @@ -3123,7 +3165,7 @@ pub extern "C" fn ChannelAnnouncement_set_node_signature_2(this_ptr: &mut Channe #[no_mangle] pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_1(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_1; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// Proof of funding UTXO ownership by the first public node #[no_mangle] @@ -3134,7 +3176,7 @@ pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_1(this_ptr: &mut Cha #[no_mangle] pub extern "C" fn ChannelAnnouncement_get_bitcoin_signature_2(this_ptr: &ChannelAnnouncement) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.bitcoin_signature_2; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// Proof of funding UTXO ownership by the second public node #[no_mangle] @@ -3145,7 +3187,7 @@ pub extern "C" fn ChannelAnnouncement_set_bitcoin_signature_2(this_ptr: &mut Cha #[no_mangle] pub extern "C" fn ChannelAnnouncement_get_contents(this_ptr: &ChannelAnnouncement) -> crate::lightning::ln::msgs::UnsignedChannelAnnouncement { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents; - crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// The actual announcement #[no_mangle] @@ -3232,7 +3274,7 @@ impl UnsignedChannelUpdate { #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChannelUpdate) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; - (*inner_val).as_inner() + inner_val.as_inner() } /// The genesis hash of the blockchain where the channel is to be opened #[no_mangle] @@ -3243,7 +3285,7 @@ pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedCh #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_get_short_channel_id(this_ptr: &UnsignedChannelUpdate) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.short_channel_id; - (*inner_val) + *inner_val } /// The short channel ID #[no_mangle] @@ -3254,7 +3296,7 @@ pub extern "C" fn UnsignedChannelUpdate_set_short_channel_id(this_ptr: &mut Unsi #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannelUpdate) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp; - (*inner_val) + *inner_val } /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel #[no_mangle] @@ -3265,7 +3307,7 @@ pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedCha #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.flags; - (*inner_val) + *inner_val } /// Channel flags #[no_mangle] @@ -3283,7 +3325,7 @@ pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannel #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_get_cltv_expiry_delta(this_ptr: &UnsignedChannelUpdate) -> u16 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.cltv_expiry_delta; - (*inner_val) + *inner_val } /// The number of blocks such that if: /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` @@ -3301,7 +3343,7 @@ pub extern "C" fn UnsignedChannelUpdate_set_cltv_expiry_delta(this_ptr: &mut Uns #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_get_htlc_minimum_msat(this_ptr: &UnsignedChannelUpdate) -> u64 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.htlc_minimum_msat; - (*inner_val) + *inner_val } /// The minimum HTLC size incoming to sender, in milli-satoshi #[no_mangle] @@ -3312,7 +3354,7 @@ pub extern "C" fn UnsignedChannelUpdate_set_htlc_minimum_msat(this_ptr: &mut Uns #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_get_fee_base_msat(this_ptr: &UnsignedChannelUpdate) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_base_msat; - (*inner_val) + *inner_val } /// The base HTLC fee charged by sender, in milli-satoshi #[no_mangle] @@ -3323,7 +3365,7 @@ pub extern "C" fn UnsignedChannelUpdate_set_fee_base_msat(this_ptr: &mut Unsigne #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_get_fee_proportional_millionths(this_ptr: &UnsignedChannelUpdate) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.fee_proportional_millionths; - (*inner_val) + *inner_val } /// The amount to fee multiplier, in micro-satoshi #[no_mangle] @@ -3398,7 +3440,7 @@ impl ChannelUpdate { #[no_mangle] pub extern "C" fn ChannelUpdate_get_signature(this_ptr: &ChannelUpdate) -> crate::c_types::Signature { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.signature; - crate::c_types::Signature::from_rust(&(*inner_val)) + crate::c_types::Signature::from_rust(&inner_val) } /// A signature of the channel update #[no_mangle] @@ -3409,7 +3451,7 @@ pub extern "C" fn ChannelUpdate_set_signature(this_ptr: &mut ChannelUpdate, mut #[no_mangle] pub extern "C" fn ChannelUpdate_get_contents(this_ptr: &ChannelUpdate) -> crate::lightning::ln::msgs::UnsignedChannelUpdate { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.contents; - crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::msgs::UnsignedChannelUpdate { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// The actual channel update #[no_mangle] @@ -3496,7 +3538,7 @@ impl QueryChannelRange { #[no_mangle] pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; - (*inner_val).as_inner() + inner_val.as_inner() } /// The genesis hash of the blockchain being queried #[no_mangle] @@ -3507,7 +3549,7 @@ pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRa #[no_mangle] pub extern "C" fn QueryChannelRange_get_first_blocknum(this_ptr: &QueryChannelRange) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum; - (*inner_val) + *inner_val } /// The height of the first block for the channel UTXOs being queried #[no_mangle] @@ -3518,7 +3560,7 @@ pub extern "C" fn QueryChannelRange_set_first_blocknum(this_ptr: &mut QueryChann #[no_mangle] pub extern "C" fn QueryChannelRange_get_number_of_blocks(this_ptr: &QueryChannelRange) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks; - (*inner_val) + *inner_val } /// The number of blocks to include in the query results #[no_mangle] @@ -3609,7 +3651,7 @@ impl ReplyChannelRange { #[no_mangle] pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; - (*inner_val).as_inner() + inner_val.as_inner() } /// The genesis hash of the blockchain being queried #[no_mangle] @@ -3620,7 +3662,7 @@ pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRa #[no_mangle] pub extern "C" fn ReplyChannelRange_get_first_blocknum(this_ptr: &ReplyChannelRange) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_blocknum; - (*inner_val) + *inner_val } /// The height of the first block in the range of the reply #[no_mangle] @@ -3631,7 +3673,7 @@ pub extern "C" fn ReplyChannelRange_set_first_blocknum(this_ptr: &mut ReplyChann #[no_mangle] pub extern "C" fn ReplyChannelRange_get_number_of_blocks(this_ptr: &ReplyChannelRange) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.number_of_blocks; - (*inner_val) + *inner_val } /// The number of blocks included in the range of the reply #[no_mangle] @@ -3642,7 +3684,7 @@ pub extern "C" fn ReplyChannelRange_set_number_of_blocks(this_ptr: &mut ReplyCha #[no_mangle] pub extern "C" fn ReplyChannelRange_get_sync_complete(this_ptr: &ReplyChannelRange) -> bool { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.sync_complete; - (*inner_val) + *inner_val } /// True when this is the final reply for a query #[no_mangle] @@ -3743,7 +3785,7 @@ impl QueryShortChannelIds { #[no_mangle] pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChannelIds) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; - (*inner_val).as_inner() + inner_val.as_inner() } /// The genesis hash of the blockchain being queried #[no_mangle] @@ -3837,7 +3879,7 @@ impl ReplyShortChannelIdsEnd { #[no_mangle] pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortChannelIdsEnd) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; - (*inner_val).as_inner() + inner_val.as_inner() } /// The genesis hash of the blockchain that was queried #[no_mangle] @@ -3849,7 +3891,7 @@ pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplySho #[no_mangle] pub extern "C" fn ReplyShortChannelIdsEnd_get_full_information(this_ptr: &ReplyShortChannelIdsEnd) -> bool { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.full_information; - (*inner_val) + *inner_val } /// Indicates if the query recipient maintains up-to-date channel /// information for the chain_hash @@ -3936,7 +3978,7 @@ impl GossipTimestampFilter { #[no_mangle] pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestampFilter) -> *const [u8; 32] { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_hash; - (*inner_val).as_inner() + inner_val.as_inner() } /// The genesis hash of the blockchain for channel and node information #[no_mangle] @@ -3947,7 +3989,7 @@ pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTime #[no_mangle] pub extern "C" fn GossipTimestampFilter_get_first_timestamp(this_ptr: &GossipTimestampFilter) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.first_timestamp; - (*inner_val) + *inner_val } /// The starting unix timestamp #[no_mangle] @@ -3958,7 +4000,7 @@ pub extern "C" fn GossipTimestampFilter_set_first_timestamp(this_ptr: &mut Gossi #[no_mangle] pub extern "C" fn GossipTimestampFilter_get_timestamp_range(this_ptr: &GossipTimestampFilter) -> u32 { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.timestamp_range; - (*inner_val) + *inner_val } /// The range of information in seconds #[no_mangle] @@ -4002,10 +4044,15 @@ pub enum ErrorAction { /// The peer took some action which made us think they were useless. Disconnect them. DisconnectPeer { /// An error message which we should make an effort to send before we disconnect. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None msg: crate::lightning::ln::msgs::ErrorMessage, }, /// The peer did something harmless that we weren't able to process, just log and ignore IgnoreError, + /// 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 did something incorrect. Tell them. SendErrorMessage { /// The message to send. @@ -4025,6 +4072,12 @@ impl ErrorAction { } }, ErrorAction::IgnoreError => nativeErrorAction::IgnoreError, + ErrorAction::IgnoreAndLog (ref a, ) => { + let mut a_nonref = (*a).clone(); + nativeErrorAction::IgnoreAndLog ( + a_nonref.into_native(), + ) + }, ErrorAction::SendErrorMessage {ref msg, } => { let mut msg_nonref = (*msg).clone(); nativeErrorAction::SendErrorMessage { @@ -4043,6 +4096,11 @@ impl ErrorAction { } }, ErrorAction::IgnoreError => nativeErrorAction::IgnoreError, + ErrorAction::IgnoreAndLog (mut a, ) => { + nativeErrorAction::IgnoreAndLog ( + a.into_native(), + ) + }, ErrorAction::SendErrorMessage {mut msg, } => { nativeErrorAction::SendErrorMessage { msg: *unsafe { Box::from_raw(msg.take_inner()) }, @@ -4061,6 +4119,12 @@ impl ErrorAction { } }, nativeErrorAction::IgnoreError => ErrorAction::IgnoreError, + nativeErrorAction::IgnoreAndLog (ref a, ) => { + let mut a_nonref = (*a).clone(); + ErrorAction::IgnoreAndLog ( + crate::lightning::util::logger::Level::native_into(a_nonref), + ) + }, nativeErrorAction::SendErrorMessage {ref msg, } => { let mut msg_nonref = (*msg).clone(); ErrorAction::SendErrorMessage { @@ -4079,6 +4143,11 @@ impl ErrorAction { } }, nativeErrorAction::IgnoreError => ErrorAction::IgnoreError, + nativeErrorAction::IgnoreAndLog (mut a, ) => { + ErrorAction::IgnoreAndLog ( + crate::lightning::util::logger::Level::native_into(a), + ) + }, nativeErrorAction::SendErrorMessage {mut msg, } => { ErrorAction::SendErrorMessage { msg: crate::lightning::ln::msgs::ErrorMessage { inner: Box::into_raw(Box::new(msg)), is_owned: true }, @@ -4095,6 +4164,29 @@ pub extern "C" fn ErrorAction_free(this_ptr: ErrorAction) { } pub extern "C" fn ErrorAction_clone(orig: &ErrorAction) -> ErrorAction { orig.clone() } +#[no_mangle] +/// Utility method to constructs a new DisconnectPeer-variant ErrorAction +pub extern "C" fn ErrorAction_disconnect_peer(msg: crate::lightning::ln::msgs::ErrorMessage) -> ErrorAction { + ErrorAction::DisconnectPeer { + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new IgnoreError-variant ErrorAction +pub extern "C" fn ErrorAction_ignore_error() -> ErrorAction { + ErrorAction::IgnoreError} +#[no_mangle] +/// Utility method to constructs a new IgnoreAndLog-variant ErrorAction +pub extern "C" fn ErrorAction_ignore_and_log(a: crate::lightning::util::logger::Level) -> ErrorAction { + ErrorAction::IgnoreAndLog(a, ) +} +#[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, + } +} use lightning::ln::msgs::LightningError as nativeLightningErrorImport; type nativeLightningError = nativeLightningErrorImport; @@ -4144,18 +4236,18 @@ impl LightningError { #[no_mangle] pub extern "C" fn LightningError_get_err(this_ptr: &LightningError) -> crate::c_types::Str { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.err; - (*inner_val).as_str().into() + inner_val.as_str().into() } /// A human-readable message describing the error #[no_mangle] -pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::derived::CVec_u8Z) { - unsafe { &mut *this_ptr.inner }.err = String::from_utf8(val.into_rust()).unwrap(); +pub extern "C" fn LightningError_set_err(this_ptr: &mut LightningError, mut val: crate::c_types::Str) { + unsafe { &mut *this_ptr.inner }.err = val.into_string(); } /// The action which should be taken against the offending peer. #[no_mangle] pub extern "C" fn LightningError_get_action(this_ptr: &LightningError) -> crate::lightning::ln::msgs::ErrorAction { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.action; - crate::lightning::ln::msgs::ErrorAction::from_native(&(*inner_val)) + crate::lightning::ln::msgs::ErrorAction::from_native(inner_val) } /// The action which should be taken against the offending peer. #[no_mangle] @@ -4165,9 +4257,9 @@ pub extern "C" fn LightningError_set_action(this_ptr: &mut LightningError, mut v /// Constructs a new LightningError given each field #[must_use] #[no_mangle] -pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::derived::CVec_u8Z, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError { +pub extern "C" fn LightningError_new(mut err_arg: crate::c_types::Str, mut action_arg: crate::lightning::ln::msgs::ErrorAction) -> LightningError { LightningError { inner: Box::into_raw(Box::new(nativeLightningError { - err: String::from_utf8(err_arg.into_rust()).unwrap(), + err: err_arg.into_string(), action: action_arg.into_native(), })), is_owned: true } } @@ -4261,6 +4353,8 @@ pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mu unsafe { &mut *this_ptr.inner }.update_fail_malformed_htlcs = local_val; } /// An update_fee message which should be sent +/// +/// 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 CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_fee; @@ -4268,6 +4362,8 @@ pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) - local_inner_val } /// An update_fee message which should be sent +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdate, mut val: crate::lightning::ln::msgs::UpdateFee) { let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; @@ -4277,7 +4373,7 @@ pub extern "C" fn CommitmentUpdate_set_update_fee(this_ptr: &mut CommitmentUpdat #[no_mangle] pub extern "C" fn CommitmentUpdate_get_commitment_signed(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::CommitmentSigned { let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.commitment_signed; - crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false } + crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ( (&(*inner_val) as *const _) as *mut _) }, is_owned: false } } /// Finally, the commitment_signed message which should be sent #[no_mangle] @@ -4460,6 +4556,29 @@ pub extern "C" fn HTLCFailChannelUpdate_free(this_ptr: HTLCFailChannelUpdate) { pub extern "C" fn HTLCFailChannelUpdate_clone(orig: &HTLCFailChannelUpdate) -> HTLCFailChannelUpdate { orig.clone() } +#[no_mangle] +/// Utility method to constructs a new ChannelUpdateMessage-variant HTLCFailChannelUpdate +pub extern "C" fn HTLCFailChannelUpdate_channel_update_message(msg: crate::lightning::ln::msgs::ChannelUpdate) -> HTLCFailChannelUpdate { + HTLCFailChannelUpdate::ChannelUpdateMessage { + msg, + } +} +#[no_mangle] +/// Utility method to constructs a new ChannelClosed-variant HTLCFailChannelUpdate +pub extern "C" fn HTLCFailChannelUpdate_channel_closed(short_channel_id: u64, is_permanent: bool) -> HTLCFailChannelUpdate { + HTLCFailChannelUpdate::ChannelClosed { + short_channel_id, + is_permanent, + } +} +#[no_mangle] +/// Utility method to constructs a new NodeFailure-variant HTLCFailChannelUpdate +pub extern "C" fn HTLCFailChannelUpdate_node_failure(node_id: crate::c_types::PublicKey, is_permanent: bool) -> HTLCFailChannelUpdate { + HTLCFailChannelUpdate::NodeFailure { + node_id, + is_permanent, + } +} /// A trait to describe an object which can receive channel messages. /// /// Messages MAY be called in parallel when they originate from different their_node_ids, however @@ -4518,76 +4637,104 @@ pub struct ChannelMessageHandler { /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, } +unsafe impl Send for ChannelMessageHandler {} +unsafe impl Sync for ChannelMessageHandler {} +#[no_mangle] +pub(crate) extern "C" fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) -> ChannelMessageHandler { + ChannelMessageHandler { + this_arg: orig.this_arg, + handle_open_channel: Clone::clone(&orig.handle_open_channel), + handle_accept_channel: Clone::clone(&orig.handle_accept_channel), + handle_funding_created: Clone::clone(&orig.handle_funding_created), + handle_funding_signed: Clone::clone(&orig.handle_funding_signed), + handle_funding_locked: Clone::clone(&orig.handle_funding_locked), + handle_shutdown: Clone::clone(&orig.handle_shutdown), + handle_closing_signed: Clone::clone(&orig.handle_closing_signed), + handle_update_add_htlc: Clone::clone(&orig.handle_update_add_htlc), + handle_update_fulfill_htlc: Clone::clone(&orig.handle_update_fulfill_htlc), + handle_update_fail_htlc: Clone::clone(&orig.handle_update_fail_htlc), + handle_update_fail_malformed_htlc: Clone::clone(&orig.handle_update_fail_malformed_htlc), + handle_commitment_signed: Clone::clone(&orig.handle_commitment_signed), + handle_revoke_and_ack: Clone::clone(&orig.handle_revoke_and_ack), + handle_update_fee: Clone::clone(&orig.handle_update_fee), + handle_announcement_signatures: Clone::clone(&orig.handle_announcement_signatures), + peer_disconnected: Clone::clone(&orig.peer_disconnected), + peer_connected: Clone::clone(&orig.peer_connected), + handle_channel_reestablish: Clone::clone(&orig.handle_channel_reestablish), + handle_channel_update: Clone::clone(&orig.handle_channel_update), + handle_error: Clone::clone(&orig.handle_error), + MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider), + free: Clone::clone(&orig.free), + } +} impl lightning::util::events::MessageSendEventsProvider for ChannelMessageHandler { fn get_and_clear_pending_msg_events(&self) -> Vec { - let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.this_arg); + let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg); let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); }; local_ret } } -unsafe impl Send for ChannelMessageHandler {} -unsafe impl Sync for ChannelMessageHandler {} use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler; impl rustChannelMessageHandler for ChannelMessageHandler { - fn handle_open_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::OpenChannel) { + fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut their_features: lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::OpenChannel) { (self.handle_open_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::features::InitFeatures { inner: Box::into_raw(Box::new(their_features)), is_owned: true }, &crate::lightning::ln::msgs::OpenChannel { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } - fn handle_accept_channel(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::AcceptChannel) { + fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut their_features: lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::AcceptChannel) { (self.handle_accept_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::features::InitFeatures { inner: Box::into_raw(Box::new(their_features)), is_owned: true }, &crate::lightning::ln::msgs::AcceptChannel { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } - fn handle_funding_created(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingCreated) { + fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) { (self.handle_funding_created)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingCreated { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } - fn handle_funding_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingSigned) { + fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) { (self.handle_funding_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingSigned { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } - fn handle_funding_locked(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::FundingLocked) { + fn handle_funding_locked(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::FundingLocked) { (self.handle_funding_locked)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingLocked { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } - fn handle_shutdown(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, their_features: &lightning::ln::features::InitFeatures, msg: &lightning::ln::msgs::Shutdown) { + fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut their_features: &lightning::ln::features::InitFeatures, mut msg: &lightning::ln::msgs::Shutdown) { (self.handle_shutdown)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::features::InitFeatures { inner: unsafe { (their_features as *const _) as *mut _ }, is_owned: false }, &crate::lightning::ln::msgs::Shutdown { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } - fn handle_closing_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ClosingSigned) { + fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) { (self.handle_closing_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ClosingSigned { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } - fn handle_update_add_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateAddHTLC) { + fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) { (self.handle_update_add_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateAddHTLC { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } - fn handle_update_fulfill_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFulfillHTLC) { + fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) { (self.handle_update_fulfill_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } - fn handle_update_fail_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailHTLC) { + fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) { (self.handle_update_fail_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailHTLC { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } - fn handle_update_fail_malformed_htlc(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) { + fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) { (self.handle_update_fail_malformed_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } - fn handle_commitment_signed(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::CommitmentSigned) { + fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) { (self.handle_commitment_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } - fn handle_revoke_and_ack(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::RevokeAndACK) { + fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) { (self.handle_revoke_and_ack)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::RevokeAndACK { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } - fn handle_update_fee(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::UpdateFee) { + fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) { (self.handle_update_fee)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFee { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } - fn handle_announcement_signatures(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::AnnouncementSignatures) { + fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) { (self.handle_announcement_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AnnouncementSignatures { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } - fn peer_disconnected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, no_connection_possible: bool) { + fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut no_connection_possible: bool) { (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), no_connection_possible) } - fn peer_connected(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::Init) { + fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::Init) { (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } - fn handle_channel_reestablish(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ChannelReestablish) { + fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) { (self.handle_channel_reestablish)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReestablish { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } - fn handle_channel_update(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ChannelUpdate) { + fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) { (self.handle_channel_update)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } - fn handle_error(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: &lightning::ln::msgs::ErrorMessage) { + fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) { (self.handle_error)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ErrorMessage { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }) } } @@ -4645,6 +4792,8 @@ pub struct RoutingMessageHandler { /// starting at the node *after* the provided publickey and including batch_amount entries /// immediately higher (as defined by ::cmp) than starting_point. /// If None is provided for starting_point, we start at the first node. + /// + /// Note that starting_point (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] pub get_next_node_announcements: extern "C" fn (this_arg: *const c_void, starting_point: crate::c_types::PublicKey, batch_amount: u8) -> crate::c_types::derived::CVec_NodeAnnouncementZ, /// Called when a connection is established with a peer. This can be used to @@ -4678,9 +4827,28 @@ pub struct RoutingMessageHandler { } unsafe impl Send for RoutingMessageHandler {} unsafe impl Sync for RoutingMessageHandler {} +#[no_mangle] +pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessageHandler) -> RoutingMessageHandler { + RoutingMessageHandler { + this_arg: orig.this_arg, + handle_node_announcement: Clone::clone(&orig.handle_node_announcement), + handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement), + handle_channel_update: Clone::clone(&orig.handle_channel_update), + handle_htlc_fail_channel_update: Clone::clone(&orig.handle_htlc_fail_channel_update), + get_next_channel_announcements: Clone::clone(&orig.get_next_channel_announcements), + get_next_node_announcements: Clone::clone(&orig.get_next_node_announcements), + sync_routing_table: Clone::clone(&orig.sync_routing_table), + handle_reply_channel_range: Clone::clone(&orig.handle_reply_channel_range), + handle_reply_short_channel_ids_end: Clone::clone(&orig.handle_reply_short_channel_ids_end), + handle_query_channel_range: Clone::clone(&orig.handle_query_channel_range), + handle_query_short_channel_ids: Clone::clone(&orig.handle_query_short_channel_ids), + MessageSendEventsProvider: crate::lightning::util::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider), + free: Clone::clone(&orig.free), + } +} impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandler { fn get_and_clear_pending_msg_events(&self) -> Vec { - let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.this_arg); + let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg); let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); }; local_ret } @@ -4688,54 +4856,54 @@ impl lightning::util::events::MessageSendEventsProvider for RoutingMessageHandle use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler; impl rustRoutingMessageHandler for RoutingMessageHandler { - fn handle_node_announcement(&self, msg: &lightning::ln::msgs::NodeAnnouncement) -> Result { + fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result { let mut ret = (self.handle_node_announcement)(self.this_arg, &crate::lightning::ln::msgs::NodeAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }); 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((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; local_ret } - fn handle_channel_announcement(&self, msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result { + fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result { let mut ret = (self.handle_channel_announcement)(self.this_arg, &crate::lightning::ln::msgs::ChannelAnnouncement { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }); 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((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; local_ret } - fn handle_channel_update(&self, msg: &lightning::ln::msgs::ChannelUpdate) -> Result { + fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result { let mut ret = (self.handle_channel_update)(self.this_arg, &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { (msg as *const _) as *mut _ }, is_owned: false }); 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((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; local_ret } - fn handle_htlc_fail_channel_update(&self, update: &lightning::ln::msgs::HTLCFailChannelUpdate) { - (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::lightning::ln::msgs::HTLCFailChannelUpdate::from_native(&update)) + fn handle_htlc_fail_channel_update(&self, mut update: &lightning::ln::msgs::HTLCFailChannelUpdate) { + (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::lightning::ln::msgs::HTLCFailChannelUpdate::from_native(update)) } - fn get_next_channel_announcements(&self, starting_point: u64, batch_amount: u8) -> Vec<(lightning::ln::msgs::ChannelAnnouncement, Option, Option)> { + fn get_next_channel_announcements(&self, mut starting_point: u64, mut batch_amount: u8) -> Vec<(lightning::ln::msgs::ChannelAnnouncement, Option, Option)> { let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount); let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item.to_rust(); let mut local_orig_ret_0_1 = if orig_ret_0_1.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) } }) }; let mut local_orig_ret_0_2 = if orig_ret_0_2.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_2.take_inner()) } }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, local_orig_ret_0_1, local_orig_ret_0_2); local_ret_0 }); }; local_ret } - fn get_next_node_announcements(&self, starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, batch_amount: u8) -> Vec { + fn get_next_node_announcements(&self, mut starting_point: Option<&bitcoin::secp256k1::key::PublicKey>, mut batch_amount: u8) -> Vec { let mut local_starting_point = if starting_point.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(starting_point.unwrap())) } }; let mut ret = (self.get_next_node_announcements)(self.this_arg, local_starting_point, batch_amount); let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_ret } - fn sync_routing_table(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, init: &lightning::ln::msgs::Init) { + fn sync_routing_table(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut init: &lightning::ln::msgs::Init) { (self.sync_routing_table)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { (init as *const _) as *mut _ }, is_owned: false }) } - fn handle_reply_channel_range(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> { + fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> { let mut ret = (self.handle_reply_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::ReplyChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true }); 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((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; local_ret } - fn handle_reply_short_channel_ids_end(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::ReplyShortChannelIdsEnd) -> Result<(), lightning::ln::msgs::LightningError> { + fn handle_reply_short_channel_ids_end(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: lightning::ln::msgs::ReplyShortChannelIdsEnd) -> Result<(), lightning::ln::msgs::LightningError> { let mut ret = (self.handle_reply_short_channel_ids_end)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::ReplyShortChannelIdsEnd { inner: Box::into_raw(Box::new(msg)), is_owned: true }); 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((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; local_ret } - fn handle_query_channel_range(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> { + fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> { let mut ret = (self.handle_query_channel_range)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::QueryChannelRange { inner: Box::into_raw(Box::new(msg)), is_owned: true }); 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((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; local_ret } - fn handle_query_short_channel_ids(&self, their_node_id: &bitcoin::secp256k1::key::PublicKey, msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> { + fn handle_query_short_channel_ids(&self, mut their_node_id: &bitcoin::secp256k1::key::PublicKey, mut msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> { let mut ret = (self.handle_query_short_channel_ids)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::QueryShortChannelIds { inner: Box::into_raw(Box::new(msg)), is_owned: true }); 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((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; local_ret @@ -4759,6 +4927,14 @@ impl Drop for RoutingMessageHandler { f(self.this_arg); } } +} +mod fuzzy_internal_msgs { + +use std::str::FromStr; +use std::ffi::c_void; +use bitcoin::hashes::Hash; +use crate::c_types::*; + } #[no_mangle] /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read