mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-25 07:17:40 +01:00
Merge pull request #801 from TheBlueMatt/2021-02-789-bindings
Bindings updates for 789
This commit is contained in:
commit
ee68ffa5fd
20 changed files with 2307 additions and 1170 deletions
|
@ -1076,6 +1076,17 @@ fn writeln_enum<'a, 'b, W: std::io::Write>(w: &mut W, e: &'a syn::ItemEnum, type
|
|||
writeln!(w, ",").unwrap();
|
||||
}
|
||||
write!(w, "\t}}").unwrap();
|
||||
} else if let syn::Fields::Unnamed(fields) = &var.fields {
|
||||
needs_free = true;
|
||||
write!(w, "(").unwrap();
|
||||
for (idx, field) in fields.unnamed.iter().enumerate() {
|
||||
if export_status(&field.attrs) == ExportStatus::TestOnly { continue; }
|
||||
types.write_c_type(w, &field.ty, None, false);
|
||||
if idx != fields.unnamed.len() - 1 {
|
||||
write!(w, ",").unwrap();
|
||||
}
|
||||
}
|
||||
write!(w, ")").unwrap();
|
||||
}
|
||||
if var.discriminant.is_some() { unimplemented!(); }
|
||||
writeln!(w, ",").unwrap();
|
||||
|
@ -1094,28 +1105,35 @@ fn writeln_enum<'a, 'b, W: std::io::Write>(w: &mut W, e: &'a syn::ItemEnum, type
|
|||
write!(w, "{}{}, ", if $ref { "ref " } else { "mut " }, field.ident.as_ref().unwrap()).unwrap();
|
||||
}
|
||||
write!(w, "}} ").unwrap();
|
||||
} else if let syn::Fields::Unnamed(fields) = &var.fields {
|
||||
write!(w, "(").unwrap();
|
||||
for (idx, field) in fields.unnamed.iter().enumerate() {
|
||||
if export_status(&field.attrs) == ExportStatus::TestOnly { continue; }
|
||||
write!(w, "{}{}, ", if $ref { "ref " } else { "mut " }, ('a' as u8 + idx as u8) as char).unwrap();
|
||||
}
|
||||
write!(w, ") ").unwrap();
|
||||
}
|
||||
write!(w, "=>").unwrap();
|
||||
if let syn::Fields::Named(fields) = &var.fields {
|
||||
write!(w, " {{\n\t\t\t\t").unwrap();
|
||||
for field in fields.named.iter() {
|
||||
if export_status(&field.attrs) == ExportStatus::TestOnly { continue; }
|
||||
|
||||
macro_rules! handle_field_a {
|
||||
($field: expr, $field_ident: expr) => { {
|
||||
if export_status(&$field.attrs) == ExportStatus::TestOnly { continue; }
|
||||
let mut sink = ::std::io::sink();
|
||||
let mut out: &mut dyn std::io::Write = if $ref { &mut sink } else { w };
|
||||
let new_var = if $to_c {
|
||||
types.write_to_c_conversion_new_var(&mut out, field.ident.as_ref().unwrap(), &field.ty, None, false)
|
||||
types.write_to_c_conversion_new_var(&mut out, $field_ident, &$field.ty, None, false)
|
||||
} else {
|
||||
types.write_from_c_conversion_new_var(&mut out, field.ident.as_ref().unwrap(), &field.ty, None)
|
||||
types.write_from_c_conversion_new_var(&mut out, $field_ident, &$field.ty, None)
|
||||
};
|
||||
if $ref || new_var {
|
||||
if $ref {
|
||||
write!(w, "let mut {}_nonref = (*{}).clone();\n\t\t\t\t", field.ident.as_ref().unwrap(), field.ident.as_ref().unwrap()).unwrap();
|
||||
write!(w, "let mut {}_nonref = (*{}).clone();\n\t\t\t\t", $field_ident, $field_ident).unwrap();
|
||||
if new_var {
|
||||
let nonref_ident = syn::Ident::new(&format!("{}_nonref", field.ident.as_ref().unwrap()), Span::call_site());
|
||||
let nonref_ident = syn::Ident::new(&format!("{}_nonref", $field_ident), Span::call_site());
|
||||
if $to_c {
|
||||
types.write_to_c_conversion_new_var(w, &nonref_ident, &field.ty, None, false);
|
||||
types.write_to_c_conversion_new_var(w, &nonref_ident, &$field.ty, None, false);
|
||||
} else {
|
||||
types.write_from_c_conversion_new_var(w, &nonref_ident, &field.ty, None);
|
||||
types.write_from_c_conversion_new_var(w, &nonref_ident, &$field.ty, None);
|
||||
}
|
||||
write!(w, "\n\t\t\t\t").unwrap();
|
||||
}
|
||||
|
@ -1123,31 +1141,58 @@ fn writeln_enum<'a, 'b, W: std::io::Write>(w: &mut W, e: &'a syn::ItemEnum, type
|
|||
write!(w, "\n\t\t\t\t").unwrap();
|
||||
}
|
||||
}
|
||||
} }
|
||||
}
|
||||
if let syn::Fields::Named(fields) = &var.fields {
|
||||
write!(w, " {{\n\t\t\t\t").unwrap();
|
||||
for field in fields.named.iter() {
|
||||
handle_field_a!(field, field.ident.as_ref().unwrap());
|
||||
}
|
||||
} else if let syn::Fields::Unnamed(fields) = &var.fields {
|
||||
write!(w, " {{\n\t\t\t\t").unwrap();
|
||||
for (idx, field) in fields.unnamed.iter().enumerate() {
|
||||
handle_field_a!(field, &syn::Ident::new(&(('a' as u8 + idx as u8) as char).to_string(), Span::call_site()));
|
||||
}
|
||||
} else { write!(w, " ").unwrap(); }
|
||||
|
||||
write!(w, "{}{}::{}", if $to_c { "" } else { "native" }, e.ident, var.ident).unwrap();
|
||||
|
||||
macro_rules! handle_field_b {
|
||||
($field: expr, $field_ident: expr) => { {
|
||||
if export_status(&$field.attrs) == ExportStatus::TestOnly { continue; }
|
||||
if $to_c {
|
||||
types.write_to_c_conversion_inline_prefix(w, &$field.ty, None, false);
|
||||
} else {
|
||||
types.write_from_c_conversion_prefix(w, &$field.ty, None);
|
||||
}
|
||||
write!(w, "{}{}", $field_ident,
|
||||
if $ref { "_nonref" } else { "" }).unwrap();
|
||||
if $to_c {
|
||||
types.write_to_c_conversion_inline_suffix(w, &$field.ty, None, false);
|
||||
} else {
|
||||
types.write_from_c_conversion_suffix(w, &$field.ty, None);
|
||||
}
|
||||
write!(w, ",").unwrap();
|
||||
} }
|
||||
}
|
||||
|
||||
if let syn::Fields::Named(fields) = &var.fields {
|
||||
write!(w, " {{").unwrap();
|
||||
for field in fields.named.iter() {
|
||||
if export_status(&field.attrs) == ExportStatus::TestOnly { continue; }
|
||||
write!(w, "\n\t\t\t\t\t{}: ", field.ident.as_ref().unwrap()).unwrap();
|
||||
if $to_c {
|
||||
types.write_to_c_conversion_inline_prefix(w, &field.ty, None, false);
|
||||
} else {
|
||||
types.write_from_c_conversion_prefix(w, &field.ty, None);
|
||||
}
|
||||
write!(w, "{}{}",
|
||||
field.ident.as_ref().unwrap(),
|
||||
if $ref { "_nonref" } else { "" }).unwrap();
|
||||
if $to_c {
|
||||
types.write_to_c_conversion_inline_suffix(w, &field.ty, None, false);
|
||||
} else {
|
||||
types.write_from_c_conversion_suffix(w, &field.ty, None);
|
||||
}
|
||||
write!(w, ",").unwrap();
|
||||
handle_field_b!(field, field.ident.as_ref().unwrap());
|
||||
}
|
||||
writeln!(w, "\n\t\t\t\t}}").unwrap();
|
||||
write!(w, "\t\t\t}}").unwrap();
|
||||
} else if let syn::Fields::Unnamed(fields) = &var.fields {
|
||||
write!(w, " (").unwrap();
|
||||
for (idx, field) in fields.unnamed.iter().enumerate() {
|
||||
write!(w, "\n\t\t\t\t\t").unwrap();
|
||||
handle_field_b!(field, &syn::Ident::new(&(('a' as u8 + idx as u8) as char).to_string(), Span::call_site()));
|
||||
}
|
||||
writeln!(w, "\n\t\t\t\t)").unwrap();
|
||||
write!(w, "\t\t\t}}").unwrap();
|
||||
}
|
||||
writeln!(w, ",").unwrap();
|
||||
}
|
||||
|
|
|
@ -114,16 +114,20 @@ pub fn assert_simple_bound(bound: &syn::TraitBound) {
|
|||
/// type), otherwise it is mapped into a transparent, C-compatible version of itself.
|
||||
pub fn is_enum_opaque(e: &syn::ItemEnum) -> bool {
|
||||
for var in e.variants.iter() {
|
||||
if let syn::Fields::Unit = var.fields {
|
||||
} else if let syn::Fields::Named(fields) = &var.fields {
|
||||
if let syn::Fields::Named(fields) = &var.fields {
|
||||
for field in fields.named.iter() {
|
||||
match export_status(&field.attrs) {
|
||||
ExportStatus::Export|ExportStatus::TestOnly => {},
|
||||
ExportStatus::NoExport => return true,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
} else if let syn::Fields::Unnamed(fields) = &var.fields {
|
||||
for field in fields.unnamed.iter() {
|
||||
match export_status(&field.attrs) {
|
||||
ExportStatus::Export|ExportStatus::TestOnly => {},
|
||||
ExportStatus::NoExport => return true,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
|
@ -963,7 +967,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
|
|||
").into() }"))
|
||||
},
|
||||
"Vec" if !is_ref => {
|
||||
Some(("Vec::new(); for item in ", vec![(format!(".drain(..) {{ local_{}.push(", var_name), "item".to_string())], "); }"))
|
||||
Some(("Vec::new(); for mut item in ", vec![(format!(".drain(..) {{ local_{}.push(", var_name), "item".to_string())], "); }"))
|
||||
},
|
||||
"Slice" => {
|
||||
Some(("Vec::new(); for item in ", vec![(format!(".iter() {{ local_{}.push(", var_name), "**item".to_string())], "); }"))
|
||||
|
@ -1004,8 +1008,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
|
|||
match full_path {
|
||||
"Result" if !is_ref => {
|
||||
Some(("match ",
|
||||
vec![(".result_ok { true => Ok(".to_string(), format!("(*unsafe {{ Box::from_raw(<*mut _>::take_ptr(&mut {}.contents.result)) }})", var_name)),
|
||||
("), false => Err(".to_string(), format!("(*unsafe {{ Box::from_raw(<*mut _>::take_ptr(&mut {}.contents.err)) }})", var_name))],
|
||||
vec![(".result_ok { true => Ok(".to_string(), format!("(*unsafe {{ Box::from_raw(<*mut _>::take_ptr(&mut {}.contents.result)) }})", var_access)),
|
||||
("), false => Err(".to_string(), format!("(*unsafe {{ Box::from_raw(<*mut _>::take_ptr(&mut {}.contents.err)) }})", var_access))],
|
||||
")}"))
|
||||
},
|
||||
"Vec"|"Slice" if !is_ref => {
|
||||
|
@ -1018,9 +1022,9 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
|
|||
if let Some(syn::Type::Path(p)) = single_contained {
|
||||
if self.c_type_has_inner_from_path(&self.resolve_path(&p.path, generics)) {
|
||||
if is_ref {
|
||||
return Some(("if ", vec![(".inner.is_null() { None } else { Some((*".to_string(), format!("{}", var_name))], ").clone()) }"))
|
||||
return Some(("if ", vec![(".inner.is_null() { None } else { Some((*".to_string(), format!("{}", var_access))], ").clone()) }"))
|
||||
} else {
|
||||
return Some(("if ", vec![(".inner.is_null() { None } else { Some(".to_string(), format!("{}", var_name))], ") }"));
|
||||
return Some(("if ", vec![(".inner.is_null() { None } else { Some(".to_string(), format!("{}", var_access))], ") }"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ int main() {
|
|||
.free = NULL,
|
||||
};
|
||||
|
||||
LDKKeysManager keys = KeysManager_new(&node_seed, net, 0, 0);
|
||||
LDKKeysManager keys = KeysManager_new(&node_seed, 0, 0);
|
||||
LDKKeysInterface keys_source = KeysManager_as_KeysInterface(&keys);
|
||||
|
||||
LDKUserConfig config = UserConfig_default();
|
||||
|
|
|
@ -348,7 +348,7 @@ int main() {
|
|||
// Instantiate classes for node 1:
|
||||
uint8_t node_seed[32];
|
||||
memset(&node_seed, 0, 32);
|
||||
LDK::KeysManager keys1 = KeysManager_new(&node_seed, network, 0, 0);
|
||||
LDK::KeysManager keys1 = KeysManager_new(&node_seed, 0, 0);
|
||||
LDK::KeysInterface keys_source1 = KeysManager_as_KeysInterface(&keys1);
|
||||
node_secret1 = keys_source1->get_node_secret(keys_source1->this_arg);
|
||||
|
||||
|
@ -370,7 +370,7 @@ int main() {
|
|||
|
||||
// Instantiate classes for node 2:
|
||||
memset(&node_seed, 1, 32);
|
||||
LDK::KeysManager keys2 = KeysManager_new(&node_seed, network, 0, 0);
|
||||
LDK::KeysManager keys2 = KeysManager_new(&node_seed, 0, 0);
|
||||
LDK::KeysInterface keys_source2 = KeysManager_as_KeysInterface(&keys2);
|
||||
node_secret2 = keys_source2->get_node_secret(keys_source2->this_arg);
|
||||
|
||||
|
@ -567,7 +567,7 @@ int main() {
|
|||
mons_list1->data[0].is_owned = false; // XXX: God this sucks
|
||||
uint8_t node_seed[32];
|
||||
memset(&node_seed, 0, 32);
|
||||
LDK::KeysManager keys1 = KeysManager_new(&node_seed, network, 1, 0);
|
||||
LDK::KeysManager keys1 = KeysManager_new(&node_seed, 1, 0);
|
||||
LDK::KeysInterface keys_source1 = KeysManager_as_KeysInterface(&keys1);
|
||||
|
||||
LDK::ChannelManagerReadArgs cm1_args = ChannelManagerReadArgs_new(KeysManager_as_KeysInterface(&keys1), fee_est, mon1, broadcast, logger1, UserConfig_default(), std::move(mons_list1));
|
||||
|
@ -581,7 +581,7 @@ int main() {
|
|||
mons_list2->data[0] = *& std::get<1>(mons2.mons[0]); // Note that we need a reference, thus need a raw clone here, which *& does.
|
||||
mons_list2->data[0].is_owned = false; // XXX: God this sucks
|
||||
memset(&node_seed, 1, 32);
|
||||
LDK::KeysManager keys2 = KeysManager_new(&node_seed, network, 1, 0);
|
||||
LDK::KeysManager keys2 = KeysManager_new(&node_seed, 1, 0);
|
||||
|
||||
LDK::ChannelManagerReadArgs cm2_args = ChannelManagerReadArgs_new(KeysManager_as_KeysInterface(&keys2), fee_est, mon2, broadcast, logger2, UserConfig_default(), std::move(mons_list2));
|
||||
LDK::CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ cm2_read =
|
||||
|
|
|
@ -1551,21 +1551,20 @@ typedef struct LDKCResult_NoneChannelMonitorUpdateErrZ {
|
|||
|
||||
|
||||
/**
|
||||
* An event to be processed by the ChannelManager.
|
||||
* Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on
|
||||
* chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the
|
||||
* preimage claim backward will lead to loss of funds.
|
||||
*
|
||||
* [`chain::Watch`]: ../trait.Watch.html
|
||||
*/
|
||||
typedef struct MUST_USE_STRUCT LDKMonitorEvent {
|
||||
typedef struct MUST_USE_STRUCT LDKHTLCUpdate {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
LDKnativeMonitorEvent *inner;
|
||||
LDKnativeHTLCUpdate *inner;
|
||||
bool is_owned;
|
||||
} LDKMonitorEvent;
|
||||
|
||||
typedef struct LDKCVec_MonitorEventZ {
|
||||
struct LDKMonitorEvent *data;
|
||||
uintptr_t datalen;
|
||||
} LDKCVec_MonitorEventZ;
|
||||
} LDKHTLCUpdate;
|
||||
|
||||
|
||||
|
||||
|
@ -1584,6 +1583,71 @@ typedef struct MUST_USE_STRUCT LDKOutPoint {
|
|||
bool is_owned;
|
||||
} LDKOutPoint;
|
||||
|
||||
/**
|
||||
* An event to be processed by the ChannelManager.
|
||||
*/
|
||||
typedef enum LDKMonitorEvent_Tag {
|
||||
/**
|
||||
* A monitor event containing an HTLCUpdate.
|
||||
*/
|
||||
LDKMonitorEvent_HTLCEvent,
|
||||
/**
|
||||
* A monitor event that the Channel's commitment transaction was broadcasted.
|
||||
*/
|
||||
LDKMonitorEvent_CommitmentTxBroadcasted,
|
||||
/**
|
||||
* Must be last for serialization purposes
|
||||
*/
|
||||
LDKMonitorEvent_Sentinel,
|
||||
} LDKMonitorEvent_Tag;
|
||||
|
||||
typedef struct MUST_USE_STRUCT LDKMonitorEvent {
|
||||
LDKMonitorEvent_Tag tag;
|
||||
union {
|
||||
struct {
|
||||
struct LDKHTLCUpdate htlc_event;
|
||||
};
|
||||
struct {
|
||||
struct LDKOutPoint commitment_tx_broadcasted;
|
||||
};
|
||||
};
|
||||
} LDKMonitorEvent;
|
||||
|
||||
typedef struct LDKCVec_MonitorEventZ {
|
||||
struct LDKMonitorEvent *data;
|
||||
uintptr_t datalen;
|
||||
} LDKCVec_MonitorEventZ;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Information about a spendable output to a P2WSH script. See
|
||||
* SpendableOutputDescriptor::DelayedPaymentOutput for more details on how to spend this.
|
||||
*/
|
||||
typedef struct MUST_USE_STRUCT LDKDelayedPaymentOutputDescriptor {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
LDKnativeDelayedPaymentOutputDescriptor *inner;
|
||||
bool is_owned;
|
||||
} LDKDelayedPaymentOutputDescriptor;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Information about a spendable output to our \"payment key\". See
|
||||
* SpendableOutputDescriptor::StaticPaymentOutput for more details on how to spend this.
|
||||
*/
|
||||
typedef struct MUST_USE_STRUCT LDKStaticPaymentOutputDescriptor {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
LDKnativeStaticPaymentOutputDescriptor *inner;
|
||||
bool is_owned;
|
||||
} LDKStaticPaymentOutputDescriptor;
|
||||
|
||||
/**
|
||||
* When on-chain outputs are created by rust-lightning (which our counterparty is not able to
|
||||
* claim at any point in the future) an event is generated which you must track and be able to
|
||||
|
@ -1630,7 +1694,7 @@ typedef enum LDKSpendableOutputDescriptor_Tag {
|
|||
* (derived as above), and the to_self_delay contained here to
|
||||
* chan_utils::get_revokeable_redeemscript.
|
||||
*/
|
||||
LDKSpendableOutputDescriptor_DynamicOutputP2WSH,
|
||||
LDKSpendableOutputDescriptor_DelayedPaymentOutput,
|
||||
/**
|
||||
* An output to a P2WPKH, spendable exclusively by our payment key (ie the private key which
|
||||
* corresponds to the public key in ChannelKeys::pubkeys().payment_point).
|
||||
|
@ -1640,7 +1704,7 @@ typedef enum LDKSpendableOutputDescriptor_Tag {
|
|||
* These are generally the result of our counterparty having broadcast the current state,
|
||||
* allowing us to claim the non-HTLC-encumbered outputs immediately.
|
||||
*/
|
||||
LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment,
|
||||
LDKSpendableOutputDescriptor_StaticPaymentOutput,
|
||||
/**
|
||||
* Must be last for serialization purposes
|
||||
*/
|
||||
|
@ -1652,29 +1716,16 @@ typedef struct LDKSpendableOutputDescriptor_LDKStaticOutput_Body {
|
|||
struct LDKTxOut output;
|
||||
} LDKSpendableOutputDescriptor_LDKStaticOutput_Body;
|
||||
|
||||
typedef struct LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body {
|
||||
struct LDKOutPoint outpoint;
|
||||
struct LDKPublicKey per_commitment_point;
|
||||
uint16_t to_self_delay;
|
||||
struct LDKTxOut output;
|
||||
struct LDKPublicKey revocation_pubkey;
|
||||
struct LDKThirtyTwoBytes channel_keys_id;
|
||||
uint64_t channel_value_satoshis;
|
||||
} LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body;
|
||||
|
||||
typedef struct LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body {
|
||||
struct LDKOutPoint outpoint;
|
||||
struct LDKTxOut output;
|
||||
struct LDKThirtyTwoBytes channel_keys_id;
|
||||
uint64_t channel_value_satoshis;
|
||||
} LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body;
|
||||
|
||||
typedef struct MUST_USE_STRUCT LDKSpendableOutputDescriptor {
|
||||
LDKSpendableOutputDescriptor_Tag tag;
|
||||
union {
|
||||
LDKSpendableOutputDescriptor_LDKStaticOutput_Body static_output;
|
||||
LDKSpendableOutputDescriptor_LDKDynamicOutputP2WSH_Body dynamic_output_p2wsh;
|
||||
LDKSpendableOutputDescriptor_LDKStaticOutputCounterpartyPayment_Body static_output_counterparty_payment;
|
||||
struct {
|
||||
struct LDKDelayedPaymentOutputDescriptor delayed_payment_output;
|
||||
};
|
||||
struct {
|
||||
struct LDKStaticPaymentOutputDescriptor static_payment_output;
|
||||
};
|
||||
};
|
||||
} LDKSpendableOutputDescriptor;
|
||||
|
||||
|
@ -1838,24 +1889,6 @@ typedef struct LDKCResult_ChannelMonitorUpdateDecodeErrorZ {
|
|||
bool result_ok;
|
||||
} LDKCResult_ChannelMonitorUpdateDecodeErrorZ;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on
|
||||
* chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the
|
||||
* preimage claim backward will lead to loss of funds.
|
||||
*
|
||||
* [`chain::Watch`]: ../trait.Watch.html
|
||||
*/
|
||||
typedef struct MUST_USE_STRUCT LDKHTLCUpdate {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
LDKnativeHTLCUpdate *inner;
|
||||
bool is_owned;
|
||||
} LDKHTLCUpdate;
|
||||
|
||||
typedef union LDKCResult_HTLCUpdateDecodeErrorZPtr {
|
||||
struct LDKHTLCUpdate *result;
|
||||
struct LDKDecodeError *err;
|
||||
|
@ -1990,11 +2023,6 @@ typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement {
|
|||
* In any case, ChannelMonitor or fallback watchtowers are always going to be trusted
|
||||
* to act, as liveness and breach reply correctness are always going to be hard requirements
|
||||
* of LN security model, orthogonal of key management issues.
|
||||
*
|
||||
* If you're implementing a custom signer, you almost certainly want to implement
|
||||
* Readable/Writable to serialize out a unique reference to this set of keys so
|
||||
* that you can serialize the full ChannelManager object.
|
||||
*
|
||||
*/
|
||||
typedef struct LDKChannelKeys {
|
||||
void *this_arg;
|
||||
|
@ -2013,7 +2041,6 @@ typedef struct LDKChannelKeys {
|
|||
* May be called more than once for the same index.
|
||||
*
|
||||
* Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
|
||||
* TODO: return a Result so we can signal a validation error
|
||||
*/
|
||||
struct LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx);
|
||||
/**
|
||||
|
@ -2268,6 +2295,16 @@ typedef struct LDKCResult_NoneAPIErrorZ {
|
|||
bool result_ok;
|
||||
} LDKCResult_NoneAPIErrorZ;
|
||||
|
||||
typedef struct LDKCVec_CResult_NoneAPIErrorZZ {
|
||||
struct LDKCResult_NoneAPIErrorZ *data;
|
||||
uintptr_t datalen;
|
||||
} LDKCVec_CResult_NoneAPIErrorZZ;
|
||||
|
||||
typedef struct LDKCVec_APIErrorZ {
|
||||
struct LDKAPIError *data;
|
||||
uintptr_t datalen;
|
||||
} LDKCVec_APIErrorZ;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -2287,20 +2324,71 @@ typedef struct LDKCVec_ChannelDetailsZ {
|
|||
uintptr_t datalen;
|
||||
} LDKCVec_ChannelDetailsZ;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* If a payment fails to send, it can be in one of several states. This enum is returned as the
|
||||
* Err() type describing which state the payment is in, see the description of individual enum
|
||||
* states for more.
|
||||
*/
|
||||
typedef struct MUST_USE_STRUCT LDKPaymentSendFailure {
|
||||
typedef enum LDKPaymentSendFailure_Tag {
|
||||
/**
|
||||
* 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.
|
||||
* A parameter which was passed to send_payment was invalid, preventing us from attempting to
|
||||
* send the payment at all. No channel state has been changed or messages sent to peers, and
|
||||
* once you've changed the parameter at error, you can freely retry the payment in full.
|
||||
*/
|
||||
LDKnativePaymentSendFailure *inner;
|
||||
bool is_owned;
|
||||
LDKPaymentSendFailure_ParameterError,
|
||||
/**
|
||||
* A parameter in a single path which was passed to send_payment was invalid, preventing us
|
||||
* from attempting to send the payment at all. No channel state has been changed or messages
|
||||
* sent to peers, and once you've changed the parameter at error, you can freely retry the
|
||||
* payment in full.
|
||||
*
|
||||
* The results here are ordered the same as the paths in the route object which was passed to
|
||||
* send_payment.
|
||||
*/
|
||||
LDKPaymentSendFailure_PathParameterError,
|
||||
/**
|
||||
* All paths which were attempted failed to send, with no channel state change taking place.
|
||||
* You can freely retry the payment in full (though you probably want to do so over different
|
||||
* paths than the ones selected).
|
||||
*/
|
||||
LDKPaymentSendFailure_AllFailedRetrySafe,
|
||||
/**
|
||||
* Some paths which were attempted failed to send, though possibly not all. At least some
|
||||
* paths have irrevocably committed to the HTLC and retrying the payment in full would result
|
||||
* in over-/re-payment.
|
||||
*
|
||||
* The results here are ordered the same as the paths in the route object which was passed to
|
||||
* send_payment, and any Errs which are not APIError::MonitorUpdateFailed can be safely
|
||||
* retried (though there is currently no API with which to do so).
|
||||
*
|
||||
* Any entries which contain Err(APIError::MonitorUpdateFailed) or Ok(()) MUST NOT be retried
|
||||
* as they will result in over-/re-payment. These HTLCs all either successfully sent (in the
|
||||
* case of Ok(())) or will send once channel_monitor_updated is called on the next-hop channel
|
||||
* with the latest update_id.
|
||||
*/
|
||||
LDKPaymentSendFailure_PartialFailure,
|
||||
/**
|
||||
* Must be last for serialization purposes
|
||||
*/
|
||||
LDKPaymentSendFailure_Sentinel,
|
||||
} LDKPaymentSendFailure_Tag;
|
||||
|
||||
typedef struct MUST_USE_STRUCT LDKPaymentSendFailure {
|
||||
LDKPaymentSendFailure_Tag tag;
|
||||
union {
|
||||
struct {
|
||||
struct LDKAPIError parameter_error;
|
||||
};
|
||||
struct {
|
||||
struct LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error;
|
||||
};
|
||||
struct {
|
||||
struct LDKCVec_APIErrorZ all_failed_retry_safe;
|
||||
};
|
||||
struct {
|
||||
struct LDKCVec_CResult_NoneAPIErrorZZ partial_failure;
|
||||
};
|
||||
};
|
||||
} LDKPaymentSendFailure;
|
||||
|
||||
typedef union LDKCResult_NonePaymentSendFailureZPtr {
|
||||
|
@ -2565,6 +2653,24 @@ typedef struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ {
|
|||
bool result_ok;
|
||||
} LDKCResult_SpendableOutputDescriptorDecodeErrorZ;
|
||||
|
||||
typedef struct LDKCVec_CVec_u8ZZ {
|
||||
struct LDKCVec_u8Z *data;
|
||||
uintptr_t datalen;
|
||||
} LDKCVec_CVec_u8ZZ;
|
||||
|
||||
typedef union LDKCResult_CVec_CVec_u8ZZNoneZPtr {
|
||||
struct LDKCVec_CVec_u8ZZ *result;
|
||||
/**
|
||||
* Note that this value is always NULL, as there are no contents in the Err variant
|
||||
*/
|
||||
void *err;
|
||||
} LDKCResult_CVec_CVec_u8ZZNoneZPtr;
|
||||
|
||||
typedef struct LDKCResult_CVec_CVec_u8ZZNoneZ {
|
||||
union LDKCResult_CVec_CVec_u8ZZNoneZPtr contents;
|
||||
bool result_ok;
|
||||
} LDKCResult_CVec_CVec_u8ZZNoneZ;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -2592,6 +2698,24 @@ typedef struct LDKCResult_InMemoryChannelKeysDecodeErrorZ {
|
|||
bool result_ok;
|
||||
} LDKCResult_InMemoryChannelKeysDecodeErrorZ;
|
||||
|
||||
typedef struct LDKCVec_TxOutZ {
|
||||
struct LDKTxOut *data;
|
||||
uintptr_t datalen;
|
||||
} LDKCVec_TxOutZ;
|
||||
|
||||
typedef union LDKCResult_TransactionNoneZPtr {
|
||||
struct LDKTransaction *result;
|
||||
/**
|
||||
* Note that this value is always NULL, as there are no contents in the Err variant
|
||||
*/
|
||||
void *err;
|
||||
} LDKCResult_TransactionNoneZPtr;
|
||||
|
||||
typedef struct LDKCResult_TransactionNoneZ {
|
||||
union LDKCResult_TransactionNoneZPtr contents;
|
||||
bool result_ok;
|
||||
} LDKCResult_TransactionNoneZ;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -3824,6 +3948,8 @@ extern const uint64_t MIN_RELAY_FEE_SAT_PER_1000_WEIGHT;
|
|||
|
||||
extern const uint64_t CLOSED_CHANNEL_UPDATE_ID;
|
||||
|
||||
extern const uintptr_t REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH;
|
||||
|
||||
void Transaction_free(struct LDKTransaction _res);
|
||||
|
||||
void TxOut_free(struct LDKTxOut _res);
|
||||
|
@ -4158,6 +4284,10 @@ void CResult_NoneAPIErrorZ_free(struct LDKCResult_NoneAPIErrorZ _res);
|
|||
|
||||
struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_clone(const struct LDKCResult_NoneAPIErrorZ *NONNULL_PTR orig);
|
||||
|
||||
void CVec_CResult_NoneAPIErrorZZ_free(struct LDKCVec_CResult_NoneAPIErrorZZ _res);
|
||||
|
||||
void CVec_APIErrorZ_free(struct LDKCVec_APIErrorZ _res);
|
||||
|
||||
void CVec_ChannelDetailsZ_free(struct LDKCVec_ChannelDetailsZ _res);
|
||||
|
||||
struct LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_ok(void);
|
||||
|
@ -4218,6 +4348,16 @@ void CResult_ChannelKeysDecodeErrorZ_free(struct LDKCResult_ChannelKeysDecodeErr
|
|||
|
||||
struct LDKCResult_ChannelKeysDecodeErrorZ CResult_ChannelKeysDecodeErrorZ_clone(const struct LDKCResult_ChannelKeysDecodeErrorZ *NONNULL_PTR orig);
|
||||
|
||||
void CVec_CVec_u8ZZ_free(struct LDKCVec_CVec_u8ZZ _res);
|
||||
|
||||
struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_ok(struct LDKCVec_CVec_u8ZZ o);
|
||||
|
||||
struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_err(void);
|
||||
|
||||
void CResult_CVec_CVec_u8ZZNoneZ_free(struct LDKCResult_CVec_CVec_u8ZZNoneZ _res);
|
||||
|
||||
struct LDKCResult_CVec_CVec_u8ZZNoneZ CResult_CVec_CVec_u8ZZNoneZ_clone(const struct LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR orig);
|
||||
|
||||
struct LDKCResult_InMemoryChannelKeysDecodeErrorZ CResult_InMemoryChannelKeysDecodeErrorZ_ok(struct LDKInMemoryChannelKeys o);
|
||||
|
||||
struct LDKCResult_InMemoryChannelKeysDecodeErrorZ CResult_InMemoryChannelKeysDecodeErrorZ_err(struct LDKDecodeError e);
|
||||
|
@ -4226,6 +4366,14 @@ void CResult_InMemoryChannelKeysDecodeErrorZ_free(struct LDKCResult_InMemoryChan
|
|||
|
||||
struct LDKCResult_InMemoryChannelKeysDecodeErrorZ CResult_InMemoryChannelKeysDecodeErrorZ_clone(const struct LDKCResult_InMemoryChannelKeysDecodeErrorZ *NONNULL_PTR orig);
|
||||
|
||||
void CVec_TxOutZ_free(struct LDKCVec_TxOutZ _res);
|
||||
|
||||
struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_ok(struct LDKTransaction o);
|
||||
|
||||
struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_err(void);
|
||||
|
||||
void CResult_TransactionNoneZ_free(struct LDKCResult_TransactionNoneZ _res);
|
||||
|
||||
void CVec_RouteHopZ_free(struct LDKCVec_RouteHopZ _res);
|
||||
|
||||
void CVec_CVec_RouteHopZZ_free(struct LDKCVec_CVec_RouteHopZZ _res);
|
||||
|
@ -5209,6 +5357,130 @@ struct LDKCVec_u8Z OutPoint_write(const struct LDKOutPoint *NONNULL_PTR obj);
|
|||
|
||||
struct LDKCResult_OutPointDecodeErrorZ OutPoint_read(struct LDKu8slice ser);
|
||||
|
||||
void DelayedPaymentOutputDescriptor_free(struct LDKDelayedPaymentOutputDescriptor this_ptr);
|
||||
|
||||
/**
|
||||
* The outpoint which is spendable
|
||||
*/
|
||||
struct LDKOutPoint DelayedPaymentOutputDescriptor_get_outpoint(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr);
|
||||
|
||||
/**
|
||||
* The outpoint which is spendable
|
||||
*/
|
||||
void DelayedPaymentOutputDescriptor_set_outpoint(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val);
|
||||
|
||||
/**
|
||||
* Per commitment point to derive delayed_payment_key by key holder
|
||||
*/
|
||||
struct LDKPublicKey DelayedPaymentOutputDescriptor_get_per_commitment_point(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr);
|
||||
|
||||
/**
|
||||
* Per commitment point to derive delayed_payment_key by key holder
|
||||
*/
|
||||
void DelayedPaymentOutputDescriptor_set_per_commitment_point(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val);
|
||||
|
||||
/**
|
||||
* The nSequence value which must be set in the spending input to satisfy the OP_CSV in
|
||||
* the witness_script.
|
||||
*/
|
||||
uint16_t DelayedPaymentOutputDescriptor_get_to_self_delay(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr);
|
||||
|
||||
/**
|
||||
* The nSequence value which must be set in the spending input to satisfy the OP_CSV in
|
||||
* the witness_script.
|
||||
*/
|
||||
void DelayedPaymentOutputDescriptor_set_to_self_delay(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint16_t val);
|
||||
|
||||
/**
|
||||
* The output which is referenced by the given outpoint
|
||||
*/
|
||||
void DelayedPaymentOutputDescriptor_set_output(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val);
|
||||
|
||||
/**
|
||||
* The revocation point specific to the commitment transaction which was broadcast. Used to
|
||||
* derive the witnessScript for this output.
|
||||
*/
|
||||
struct LDKPublicKey DelayedPaymentOutputDescriptor_get_revocation_pubkey(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr);
|
||||
|
||||
/**
|
||||
* The revocation point specific to the commitment transaction which was broadcast. Used to
|
||||
* derive the witnessScript for this output.
|
||||
*/
|
||||
void DelayedPaymentOutputDescriptor_set_revocation_pubkey(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val);
|
||||
|
||||
/**
|
||||
* Arbitrary identification information returned by a call to
|
||||
* `ChannelKeys::channel_keys_id()`. This may be useful in re-deriving keys used in
|
||||
* the channel to spend the output.
|
||||
*/
|
||||
const uint8_t (*DelayedPaymentOutputDescriptor_get_channel_keys_id(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32];
|
||||
|
||||
/**
|
||||
* Arbitrary identification information returned by a call to
|
||||
* `ChannelKeys::channel_keys_id()`. This may be useful in re-deriving keys used in
|
||||
* the channel to spend the output.
|
||||
*/
|
||||
void DelayedPaymentOutputDescriptor_set_channel_keys_id(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val);
|
||||
|
||||
/**
|
||||
* The value of the channel which this output originated from, possibly indirectly.
|
||||
*/
|
||||
uint64_t DelayedPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr);
|
||||
|
||||
/**
|
||||
* The value of the channel which this output originated from, possibly indirectly.
|
||||
*/
|
||||
void DelayedPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val);
|
||||
|
||||
MUST_USE_RES struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKPublicKey per_commitment_point_arg, uint16_t to_self_delay_arg, struct LDKTxOut output_arg, struct LDKPublicKey revocation_pubkey_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg);
|
||||
|
||||
struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_clone(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR orig);
|
||||
|
||||
void StaticPaymentOutputDescriptor_free(struct LDKStaticPaymentOutputDescriptor this_ptr);
|
||||
|
||||
/**
|
||||
* The outpoint which is spendable
|
||||
*/
|
||||
struct LDKOutPoint StaticPaymentOutputDescriptor_get_outpoint(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr);
|
||||
|
||||
/**
|
||||
* The outpoint which is spendable
|
||||
*/
|
||||
void StaticPaymentOutputDescriptor_set_outpoint(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val);
|
||||
|
||||
/**
|
||||
* The output which is referenced by the given outpoint
|
||||
*/
|
||||
void StaticPaymentOutputDescriptor_set_output(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val);
|
||||
|
||||
/**
|
||||
* Arbitrary identification information returned by a call to
|
||||
* `ChannelKeys::channel_keys_id()`. This may be useful in re-deriving keys used in
|
||||
* the channel to spend the output.
|
||||
*/
|
||||
const uint8_t (*StaticPaymentOutputDescriptor_get_channel_keys_id(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32];
|
||||
|
||||
/**
|
||||
* Arbitrary identification information returned by a call to
|
||||
* `ChannelKeys::channel_keys_id()`. This may be useful in re-deriving keys used in
|
||||
* the channel to spend the output.
|
||||
*/
|
||||
void StaticPaymentOutputDescriptor_set_channel_keys_id(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val);
|
||||
|
||||
/**
|
||||
* The value of the channel which this transactions spends.
|
||||
*/
|
||||
uint64_t StaticPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr);
|
||||
|
||||
/**
|
||||
* The value of the channel which this transactions spends.
|
||||
*/
|
||||
void StaticPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val);
|
||||
|
||||
MUST_USE_RES struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg);
|
||||
|
||||
struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_clone(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR orig);
|
||||
|
||||
void SpendableOutputDescriptor_free(struct LDKSpendableOutputDescriptor this_ptr);
|
||||
|
||||
struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const struct LDKSpendableOutputDescriptor *NONNULL_PTR orig);
|
||||
|
@ -5340,6 +5612,25 @@ MUST_USE_RES struct LDKOutPoint InMemoryChannelKeys_funding_outpoint(const struc
|
|||
*/
|
||||
MUST_USE_RES struct LDKChannelTransactionParameters InMemoryChannelKeys_get_channel_parameters(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_arg);
|
||||
|
||||
/**
|
||||
* Sign the single input of spend_tx at index `input_idx` which spends the output
|
||||
* described by descriptor, returning the witness stack for the input.
|
||||
*
|
||||
* Returns an Err if the input at input_idx does not exist, has a non-empty script_sig,
|
||||
* or is not spending the outpoint described by `descriptor.outpoint`.
|
||||
*/
|
||||
MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemoryChannelKeys_sign_counterparty_payment_input(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR descriptor);
|
||||
|
||||
/**
|
||||
* Sign the single input of spend_tx at index `input_idx` which spends the output
|
||||
* described by descriptor, returning the witness stack for the input.
|
||||
*
|
||||
* Returns an Err if the input at input_idx does not exist, has a non-empty script_sig,
|
||||
* is not spending the outpoint described by `descriptor.outpoint`, or does not have a
|
||||
* sequence set to `descriptor.to_self_delay`.
|
||||
*/
|
||||
MUST_USE_RES struct LDKCResult_CVec_CVec_u8ZZNoneZ InMemoryChannelKeys_sign_dynamic_p2wsh_input(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR descriptor);
|
||||
|
||||
struct LDKChannelKeys InMemoryChannelKeys_as_ChannelKeys(const struct LDKInMemoryChannelKeys *NONNULL_PTR this_arg);
|
||||
|
||||
struct LDKCVec_u8Z InMemoryChannelKeys_write(const struct LDKInMemoryChannelKeys *NONNULL_PTR obj);
|
||||
|
@ -5369,7 +5660,7 @@ void KeysManager_free(struct LDKKeysManager this_ptr);
|
|||
* versions. Once the library is more fully supported, the docs will be updated to include a
|
||||
* detailed description of the guarantee.
|
||||
*/
|
||||
MUST_USE_RES struct LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], enum LDKNetwork network, uint64_t starting_time_secs, uint32_t starting_time_nanos);
|
||||
MUST_USE_RES struct LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos);
|
||||
|
||||
/**
|
||||
* Derive an old set of ChannelKeys for per-channel secrets based on a key derivation
|
||||
|
@ -5380,6 +5671,21 @@ MUST_USE_RES struct LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], en
|
|||
*/
|
||||
MUST_USE_RES struct LDKInMemoryChannelKeys KeysManager_derive_channel_keys(const struct LDKKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]);
|
||||
|
||||
/**
|
||||
* Creates a Transaction which spends the given descriptors to the given outputs, plus an
|
||||
* output to the given change destination (if sufficient change value remains). The
|
||||
* transaction will have a feerate, at least, of the given value.
|
||||
*
|
||||
* Returns `Err(())` if the output value is greater than the input value minus required fee or
|
||||
* if a descriptor was duplicated.
|
||||
*
|
||||
* We do not enforce that outputs meet the dust limit or that any output scripts are standard.
|
||||
*
|
||||
* May panic if the `SpendableOutputDescriptor`s were not generated by Channels which used
|
||||
* this KeysManager or one of the `InMemoryChannelKeys` created by this KeysManager.
|
||||
*/
|
||||
MUST_USE_RES struct LDKCResult_TransactionNoneZ KeysManager_spend_spendable_outputs(const struct LDKKeysManager *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight);
|
||||
|
||||
struct LDKKeysInterface KeysManager_as_KeysInterface(const struct LDKKeysManager *NONNULL_PTR this_arg);
|
||||
|
||||
void ChannelManager_free(struct LDKChannelManager this_ptr);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -75,8 +75,6 @@ struct nativeChannelMonitorUpdateOpaque;
|
|||
typedef struct nativeChannelMonitorUpdateOpaque LDKnativeChannelMonitorUpdate;
|
||||
struct nativeMonitorUpdateErrorOpaque;
|
||||
typedef struct nativeMonitorUpdateErrorOpaque LDKnativeMonitorUpdateError;
|
||||
struct nativeMonitorEventOpaque;
|
||||
typedef struct nativeMonitorEventOpaque LDKnativeMonitorEvent;
|
||||
struct nativeHTLCUpdateOpaque;
|
||||
typedef struct nativeHTLCUpdateOpaque LDKnativeHTLCUpdate;
|
||||
struct nativeChannelMonitorOpaque;
|
||||
|
@ -85,10 +83,12 @@ struct nativeChannelManagerOpaque;
|
|||
typedef struct nativeChannelManagerOpaque LDKnativeChannelManager;
|
||||
struct nativeChannelDetailsOpaque;
|
||||
typedef struct nativeChannelDetailsOpaque LDKnativeChannelDetails;
|
||||
struct nativePaymentSendFailureOpaque;
|
||||
typedef struct nativePaymentSendFailureOpaque LDKnativePaymentSendFailure;
|
||||
struct nativeChannelManagerReadArgsOpaque;
|
||||
typedef struct nativeChannelManagerReadArgsOpaque LDKnativeChannelManagerReadArgs;
|
||||
struct nativeDelayedPaymentOutputDescriptorOpaque;
|
||||
typedef struct nativeDelayedPaymentOutputDescriptorOpaque LDKnativeDelayedPaymentOutputDescriptor;
|
||||
struct nativeStaticPaymentOutputDescriptorOpaque;
|
||||
typedef struct nativeStaticPaymentOutputDescriptorOpaque LDKnativeStaticPaymentOutputDescriptor;
|
||||
struct LDKChannelKeys;
|
||||
typedef struct LDKChannelKeys LDKChannelKeys;
|
||||
struct nativeInMemoryChannelKeysOpaque;
|
||||
|
|
|
@ -3286,6 +3286,86 @@ impl Clone for CResult_NoneAPIErrorZ {
|
|||
#[no_mangle]
|
||||
pub extern "C" fn CResult_NoneAPIErrorZ_clone(orig: &CResult_NoneAPIErrorZ) -> CResult_NoneAPIErrorZ { orig.clone() }
|
||||
#[repr(C)]
|
||||
pub struct CVec_CResult_NoneAPIErrorZZ {
|
||||
pub data: *mut crate::c_types::derived::CResult_NoneAPIErrorZ,
|
||||
pub datalen: usize
|
||||
}
|
||||
impl CVec_CResult_NoneAPIErrorZZ {
|
||||
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::CResult_NoneAPIErrorZ> {
|
||||
if self.datalen == 0 { return Vec::new(); }
|
||||
let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
|
||||
self.data = std::ptr::null_mut();
|
||||
self.datalen = 0;
|
||||
ret
|
||||
}
|
||||
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::CResult_NoneAPIErrorZ] {
|
||||
unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
|
||||
}
|
||||
}
|
||||
impl From<Vec<crate::c_types::derived::CResult_NoneAPIErrorZ>> for CVec_CResult_NoneAPIErrorZZ {
|
||||
fn from(v: Vec<crate::c_types::derived::CResult_NoneAPIErrorZ>) -> Self {
|
||||
let datalen = v.len();
|
||||
let data = Box::into_raw(v.into_boxed_slice());
|
||||
Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
|
||||
}
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn CVec_CResult_NoneAPIErrorZZ_free(_res: CVec_CResult_NoneAPIErrorZZ) { }
|
||||
impl Drop for CVec_CResult_NoneAPIErrorZZ {
|
||||
fn drop(&mut self) {
|
||||
if self.datalen == 0 { return; }
|
||||
unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
|
||||
}
|
||||
}
|
||||
impl Clone for CVec_CResult_NoneAPIErrorZZ {
|
||||
fn clone(&self) -> Self {
|
||||
let mut res = Vec::new();
|
||||
if self.datalen == 0 { return Self::from(res); }
|
||||
res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
|
||||
Self::from(res)
|
||||
}
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct CVec_APIErrorZ {
|
||||
pub data: *mut crate::util::errors::APIError,
|
||||
pub datalen: usize
|
||||
}
|
||||
impl CVec_APIErrorZ {
|
||||
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::util::errors::APIError> {
|
||||
if self.datalen == 0 { return Vec::new(); }
|
||||
let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
|
||||
self.data = std::ptr::null_mut();
|
||||
self.datalen = 0;
|
||||
ret
|
||||
}
|
||||
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::util::errors::APIError] {
|
||||
unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
|
||||
}
|
||||
}
|
||||
impl From<Vec<crate::util::errors::APIError>> for CVec_APIErrorZ {
|
||||
fn from(v: Vec<crate::util::errors::APIError>) -> Self {
|
||||
let datalen = v.len();
|
||||
let data = Box::into_raw(v.into_boxed_slice());
|
||||
Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
|
||||
}
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn CVec_APIErrorZ_free(_res: CVec_APIErrorZ) { }
|
||||
impl Drop for CVec_APIErrorZ {
|
||||
fn drop(&mut self) {
|
||||
if self.datalen == 0 { return; }
|
||||
unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
|
||||
}
|
||||
}
|
||||
impl Clone for CVec_APIErrorZ {
|
||||
fn clone(&self) -> Self {
|
||||
let mut res = Vec::new();
|
||||
if self.datalen == 0 { return Self::from(res); }
|
||||
res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
|
||||
Self::from(res)
|
||||
}
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct CVec_ChannelDetailsZ {
|
||||
pub data: *mut crate::ln::channelmanager::ChannelDetails,
|
||||
pub datalen: usize
|
||||
|
@ -3847,6 +3927,119 @@ impl Clone for CResult_ChannelKeysDecodeErrorZ {
|
|||
#[no_mangle]
|
||||
pub extern "C" fn CResult_ChannelKeysDecodeErrorZ_clone(orig: &CResult_ChannelKeysDecodeErrorZ) -> CResult_ChannelKeysDecodeErrorZ { orig.clone() }
|
||||
#[repr(C)]
|
||||
pub struct CVec_CVec_u8ZZ {
|
||||
pub data: *mut crate::c_types::derived::CVec_u8Z,
|
||||
pub datalen: usize
|
||||
}
|
||||
impl CVec_CVec_u8ZZ {
|
||||
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::CVec_u8Z> {
|
||||
if self.datalen == 0 { return Vec::new(); }
|
||||
let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
|
||||
self.data = std::ptr::null_mut();
|
||||
self.datalen = 0;
|
||||
ret
|
||||
}
|
||||
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::CVec_u8Z] {
|
||||
unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
|
||||
}
|
||||
}
|
||||
impl From<Vec<crate::c_types::derived::CVec_u8Z>> for CVec_CVec_u8ZZ {
|
||||
fn from(v: Vec<crate::c_types::derived::CVec_u8Z>) -> Self {
|
||||
let datalen = v.len();
|
||||
let data = Box::into_raw(v.into_boxed_slice());
|
||||
Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
|
||||
}
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn CVec_CVec_u8ZZ_free(_res: CVec_CVec_u8ZZ) { }
|
||||
impl Drop for CVec_CVec_u8ZZ {
|
||||
fn drop(&mut self) {
|
||||
if self.datalen == 0 { return; }
|
||||
unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
|
||||
}
|
||||
}
|
||||
impl Clone for CVec_CVec_u8ZZ {
|
||||
fn clone(&self) -> Self {
|
||||
let mut res = Vec::new();
|
||||
if self.datalen == 0 { return Self::from(res); }
|
||||
res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
|
||||
Self::from(res)
|
||||
}
|
||||
}
|
||||
#[repr(C)]
|
||||
pub union CResult_CVec_CVec_u8ZZNoneZPtr {
|
||||
pub result: *mut crate::c_types::derived::CVec_CVec_u8ZZ,
|
||||
/// Note that this value is always NULL, as there are no contents in the Err variant
|
||||
pub err: *mut std::ffi::c_void,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct CResult_CVec_CVec_u8ZZNoneZ {
|
||||
pub contents: CResult_CVec_CVec_u8ZZNoneZPtr,
|
||||
pub result_ok: bool,
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_ok(o: crate::c_types::derived::CVec_CVec_u8ZZ) -> CResult_CVec_CVec_u8ZZNoneZ {
|
||||
CResult_CVec_CVec_u8ZZNoneZ {
|
||||
contents: CResult_CVec_CVec_u8ZZNoneZPtr {
|
||||
result: Box::into_raw(Box::new(o)),
|
||||
},
|
||||
result_ok: true,
|
||||
}
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_err() -> CResult_CVec_CVec_u8ZZNoneZ {
|
||||
CResult_CVec_CVec_u8ZZNoneZ {
|
||||
contents: CResult_CVec_CVec_u8ZZNoneZPtr {
|
||||
err: std::ptr::null_mut(),
|
||||
},
|
||||
result_ok: false,
|
||||
}
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_free(_res: CResult_CVec_CVec_u8ZZNoneZ) { }
|
||||
impl Drop for CResult_CVec_CVec_u8ZZNoneZ {
|
||||
fn drop(&mut self) {
|
||||
if self.result_ok {
|
||||
if unsafe { !(self.contents.result as *mut ()).is_null() } {
|
||||
let _ = unsafe { Box::from_raw(self.contents.result) };
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<crate::c_types::CResultTempl<crate::c_types::derived::CVec_CVec_u8ZZ, u8>> for CResult_CVec_CVec_u8ZZNoneZ {
|
||||
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::CVec_CVec_u8ZZ, u8>) -> Self {
|
||||
let contents = if o.result_ok {
|
||||
let result = unsafe { o.contents.result };
|
||||
unsafe { o.contents.result = std::ptr::null_mut() };
|
||||
CResult_CVec_CVec_u8ZZNoneZPtr { result }
|
||||
} else {
|
||||
let _ = unsafe { Box::from_raw(o.contents.err) };
|
||||
o.contents.err = std::ptr::null_mut();
|
||||
CResult_CVec_CVec_u8ZZNoneZPtr { err: std::ptr::null_mut() }
|
||||
};
|
||||
Self {
|
||||
contents,
|
||||
result_ok: o.result_ok,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Clone for CResult_CVec_CVec_u8ZZNoneZ {
|
||||
fn clone(&self) -> Self {
|
||||
if self.result_ok {
|
||||
Self { result_ok: true, contents: CResult_CVec_CVec_u8ZZNoneZPtr {
|
||||
result: Box::into_raw(Box::new(<crate::c_types::derived::CVec_CVec_u8ZZ>::clone(unsafe { &*self.contents.result })))
|
||||
} }
|
||||
} else {
|
||||
Self { result_ok: false, contents: CResult_CVec_CVec_u8ZZNoneZPtr {
|
||||
err: std::ptr::null_mut()
|
||||
} }
|
||||
}
|
||||
}
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_clone(orig: &CResult_CVec_CVec_u8ZZNoneZ) -> CResult_CVec_CVec_u8ZZNoneZ { orig.clone() }
|
||||
#[repr(C)]
|
||||
pub union CResult_InMemoryChannelKeysDecodeErrorZPtr {
|
||||
pub result: *mut crate::chain::keysinterface::InMemoryChannelKeys,
|
||||
pub err: *mut crate::ln::msgs::DecodeError,
|
||||
|
@ -3922,6 +4115,104 @@ impl Clone for CResult_InMemoryChannelKeysDecodeErrorZ {
|
|||
#[no_mangle]
|
||||
pub extern "C" fn CResult_InMemoryChannelKeysDecodeErrorZ_clone(orig: &CResult_InMemoryChannelKeysDecodeErrorZ) -> CResult_InMemoryChannelKeysDecodeErrorZ { orig.clone() }
|
||||
#[repr(C)]
|
||||
pub struct CVec_TxOutZ {
|
||||
pub data: *mut crate::c_types::TxOut,
|
||||
pub datalen: usize
|
||||
}
|
||||
impl CVec_TxOutZ {
|
||||
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::TxOut> {
|
||||
if self.datalen == 0 { return Vec::new(); }
|
||||
let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
|
||||
self.data = std::ptr::null_mut();
|
||||
self.datalen = 0;
|
||||
ret
|
||||
}
|
||||
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::TxOut] {
|
||||
unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
|
||||
}
|
||||
}
|
||||
impl From<Vec<crate::c_types::TxOut>> for CVec_TxOutZ {
|
||||
fn from(v: Vec<crate::c_types::TxOut>) -> Self {
|
||||
let datalen = v.len();
|
||||
let data = Box::into_raw(v.into_boxed_slice());
|
||||
Self { datalen, data: unsafe { (*data).as_mut_ptr() } }
|
||||
}
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn CVec_TxOutZ_free(_res: CVec_TxOutZ) { }
|
||||
impl Drop for CVec_TxOutZ {
|
||||
fn drop(&mut self) {
|
||||
if self.datalen == 0 { return; }
|
||||
unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
|
||||
}
|
||||
}
|
||||
impl Clone for CVec_TxOutZ {
|
||||
fn clone(&self) -> Self {
|
||||
let mut res = Vec::new();
|
||||
if self.datalen == 0 { return Self::from(res); }
|
||||
res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
|
||||
Self::from(res)
|
||||
}
|
||||
}
|
||||
#[repr(C)]
|
||||
pub union CResult_TransactionNoneZPtr {
|
||||
pub result: *mut crate::c_types::Transaction,
|
||||
/// Note that this value is always NULL, as there are no contents in the Err variant
|
||||
pub err: *mut std::ffi::c_void,
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct CResult_TransactionNoneZ {
|
||||
pub contents: CResult_TransactionNoneZPtr,
|
||||
pub result_ok: bool,
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn CResult_TransactionNoneZ_ok(o: crate::c_types::Transaction) -> CResult_TransactionNoneZ {
|
||||
CResult_TransactionNoneZ {
|
||||
contents: CResult_TransactionNoneZPtr {
|
||||
result: Box::into_raw(Box::new(o)),
|
||||
},
|
||||
result_ok: true,
|
||||
}
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn CResult_TransactionNoneZ_err() -> CResult_TransactionNoneZ {
|
||||
CResult_TransactionNoneZ {
|
||||
contents: CResult_TransactionNoneZPtr {
|
||||
err: std::ptr::null_mut(),
|
||||
},
|
||||
result_ok: false,
|
||||
}
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn CResult_TransactionNoneZ_free(_res: CResult_TransactionNoneZ) { }
|
||||
impl Drop for CResult_TransactionNoneZ {
|
||||
fn drop(&mut self) {
|
||||
if self.result_ok {
|
||||
if unsafe { !(self.contents.result as *mut ()).is_null() } {
|
||||
let _ = unsafe { Box::from_raw(self.contents.result) };
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<crate::c_types::CResultTempl<crate::c_types::Transaction, u8>> for CResult_TransactionNoneZ {
|
||||
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::Transaction, u8>) -> Self {
|
||||
let contents = if o.result_ok {
|
||||
let result = unsafe { o.contents.result };
|
||||
unsafe { o.contents.result = std::ptr::null_mut() };
|
||||
CResult_TransactionNoneZPtr { result }
|
||||
} else {
|
||||
let _ = unsafe { Box::from_raw(o.contents.err) };
|
||||
o.contents.err = std::ptr::null_mut();
|
||||
CResult_TransactionNoneZPtr { err: std::ptr::null_mut() }
|
||||
};
|
||||
Self {
|
||||
contents,
|
||||
result_ok: o.result_ok,
|
||||
}
|
||||
}
|
||||
}
|
||||
#[repr(C)]
|
||||
pub struct CVec_RouteHopZ {
|
||||
pub data: *mut crate::routing::router::RouteHop,
|
||||
pub datalen: usize
|
||||
|
|
|
@ -153,7 +153,7 @@ extern "C" fn ChainMonitor_Watch_update_channel(this_arg: *const c_void, mut fun
|
|||
#[must_use]
|
||||
extern "C" fn ChainMonitor_Watch_release_pending_monitor_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MonitorEventZ {
|
||||
let mut ret = unsafe { &mut *(this_arg as *mut nativeChainMonitor) }.release_pending_monitor_events();
|
||||
let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::chain::channelmonitor::MonitorEvent { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
|
||||
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::chain::channelmonitor::MonitorEvent::native_into(item) }); };
|
||||
local_ret.into()
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ use lightning::util::events::EventsProvider as EventsProviderTraitImport;
|
|||
#[must_use]
|
||||
extern "C" fn ChainMonitor_EventsProvider_get_and_clear_pending_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_EventZ {
|
||||
let mut ret = unsafe { &mut *(this_arg as *mut nativeChainMonitor) }.get_and_clear_pending_events();
|
||||
let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::util::events::Event::native_into(item) }); };
|
||||
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::util::events::Event::native_into(item) }); };
|
||||
local_ret.into()
|
||||
}
|
||||
|
||||
|
|
|
@ -283,58 +283,85 @@ pub(crate) extern "C" fn MonitorUpdateError_clone_void(this_ptr: *const c_void)
|
|||
pub extern "C" fn MonitorUpdateError_clone(orig: &MonitorUpdateError) -> MonitorUpdateError {
|
||||
orig.clone()
|
||||
}
|
||||
|
||||
use lightning::chain::channelmonitor::MonitorEvent as nativeMonitorEventImport;
|
||||
type nativeMonitorEvent = nativeMonitorEventImport;
|
||||
|
||||
/// An event to be processed by the ChannelManager.
|
||||
#[must_use]
|
||||
#[derive(Clone)]
|
||||
#[repr(C)]
|
||||
pub struct MonitorEvent {
|
||||
/// 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 nativeMonitorEvent,
|
||||
pub is_owned: bool,
|
||||
pub enum MonitorEvent {
|
||||
/// A monitor event containing an HTLCUpdate.
|
||||
HTLCEvent(crate::chain::channelmonitor::HTLCUpdate),
|
||||
/// A monitor event that the Channel's commitment transaction was broadcasted.
|
||||
CommitmentTxBroadcasted(crate::chain::transaction::OutPoint),
|
||||
}
|
||||
|
||||
impl Drop for MonitorEvent {
|
||||
fn drop(&mut self) {
|
||||
if self.is_owned && !self.inner.is_null() {
|
||||
let _ = unsafe { Box::from_raw(self.inner) };
|
||||
use lightning::chain::channelmonitor::MonitorEvent as nativeMonitorEvent;
|
||||
impl MonitorEvent {
|
||||
#[allow(unused)]
|
||||
pub(crate) fn to_native(&self) -> nativeMonitorEvent {
|
||||
match self {
|
||||
MonitorEvent::HTLCEvent (ref a, ) => {
|
||||
let mut a_nonref = (*a).clone();
|
||||
nativeMonitorEvent::HTLCEvent (
|
||||
*unsafe { Box::from_raw(a_nonref.take_inner()) },
|
||||
)
|
||||
},
|
||||
MonitorEvent::CommitmentTxBroadcasted (ref a, ) => {
|
||||
let mut a_nonref = (*a).clone();
|
||||
nativeMonitorEvent::CommitmentTxBroadcasted (
|
||||
*unsafe { Box::from_raw(a_nonref.take_inner()) },
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub(crate) fn into_native(self) -> nativeMonitorEvent {
|
||||
match self {
|
||||
MonitorEvent::HTLCEvent (mut a, ) => {
|
||||
nativeMonitorEvent::HTLCEvent (
|
||||
*unsafe { Box::from_raw(a.take_inner()) },
|
||||
)
|
||||
},
|
||||
MonitorEvent::CommitmentTxBroadcasted (mut a, ) => {
|
||||
nativeMonitorEvent::CommitmentTxBroadcasted (
|
||||
*unsafe { Box::from_raw(a.take_inner()) },
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub(crate) fn from_native(native: &nativeMonitorEvent) -> Self {
|
||||
match native {
|
||||
nativeMonitorEvent::HTLCEvent (ref a, ) => {
|
||||
let mut a_nonref = (*a).clone();
|
||||
MonitorEvent::HTLCEvent (
|
||||
crate::chain::channelmonitor::HTLCUpdate { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true },
|
||||
)
|
||||
},
|
||||
nativeMonitorEvent::CommitmentTxBroadcasted (ref a, ) => {
|
||||
let mut a_nonref = (*a).clone();
|
||||
MonitorEvent::CommitmentTxBroadcasted (
|
||||
crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true },
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub(crate) fn native_into(native: nativeMonitorEvent) -> Self {
|
||||
match native {
|
||||
nativeMonitorEvent::HTLCEvent (mut a, ) => {
|
||||
MonitorEvent::HTLCEvent (
|
||||
crate::chain::channelmonitor::HTLCUpdate { inner: Box::into_raw(Box::new(a)), is_owned: true },
|
||||
)
|
||||
},
|
||||
nativeMonitorEvent::CommitmentTxBroadcasted (mut a, ) => {
|
||||
MonitorEvent::CommitmentTxBroadcasted (
|
||||
crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(a)), is_owned: true },
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn MonitorEvent_free(this_ptr: MonitorEvent) { }
|
||||
#[allow(unused)]
|
||||
/// Used only if an object of this type is returned as a trait impl by a method
|
||||
extern "C" fn MonitorEvent_free_void(this_ptr: *mut c_void) {
|
||||
unsafe { let _ = Box::from_raw(this_ptr as *mut nativeMonitorEvent); }
|
||||
}
|
||||
#[allow(unused)]
|
||||
/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
|
||||
impl MonitorEvent {
|
||||
pub(crate) fn take_inner(mut self) -> *mut nativeMonitorEvent {
|
||||
assert!(self.is_owned);
|
||||
let ret = self.inner;
|
||||
self.inner = std::ptr::null_mut();
|
||||
ret
|
||||
}
|
||||
}
|
||||
impl Clone for MonitorEvent {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
inner: if self.inner.is_null() { std::ptr::null_mut() } else {
|
||||
Box::into_raw(Box::new(unsafe { &*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 MonitorEvent_clone_void(this_ptr: *const c_void) -> *mut c_void {
|
||||
Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeMonitorEvent)).clone() })) as *mut c_void
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn MonitorEvent_clone(orig: &MonitorEvent) -> MonitorEvent {
|
||||
orig.clone()
|
||||
|
@ -512,7 +539,7 @@ pub extern "C" fn ChannelMonitor_get_funding_txo(this_arg: &ChannelMonitor) -> c
|
|||
#[no_mangle]
|
||||
pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg: &mut ChannelMonitor) -> crate::c_types::derived::CVec_MonitorEventZ {
|
||||
let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_and_clear_pending_monitor_events();
|
||||
let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::chain::channelmonitor::MonitorEvent { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
|
||||
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::chain::channelmonitor::MonitorEvent::native_into(item) }); };
|
||||
local_ret.into()
|
||||
}
|
||||
|
||||
|
@ -526,7 +553,7 @@ pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg:
|
|||
#[no_mangle]
|
||||
pub extern "C" fn ChannelMonitor_get_and_clear_pending_events(this_arg: &mut ChannelMonitor) -> crate::c_types::derived::CVec_EventZ {
|
||||
let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_and_clear_pending_events();
|
||||
let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::util::events::Event::native_into(item) }); };
|
||||
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::util::events::Event::native_into(item) }); };
|
||||
local_ret.into()
|
||||
}
|
||||
|
||||
|
@ -543,7 +570,7 @@ pub extern "C" fn ChannelMonitor_get_and_clear_pending_events(this_arg: &mut Cha
|
|||
#[no_mangle]
|
||||
pub extern "C" fn ChannelMonitor_get_latest_holder_commitment_txn(this_arg: &mut ChannelMonitor, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionZ {
|
||||
let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_latest_holder_commitment_txn(logger);
|
||||
let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { let mut local_ret_0 = ::bitcoin::consensus::encode::serialize(&item); crate::c_types::Transaction::from_vec(local_ret_0) }); };
|
||||
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let mut local_ret_0 = ::bitcoin::consensus::encode::serialize(&item); crate::c_types::Transaction::from_vec(local_ret_0) }); };
|
||||
local_ret.into()
|
||||
}
|
||||
|
||||
|
@ -563,7 +590,7 @@ pub extern "C" fn ChannelMonitor_get_latest_holder_commitment_txn(this_arg: &mut
|
|||
pub extern "C" fn ChannelMonitor_block_connected(this_arg: &mut ChannelMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32, mut broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut logger: crate::util::logger::Logger) -> crate::c_types::derived::CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ {
|
||||
let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); };
|
||||
let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.block_connected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::<Vec<_>>()[..], height, broadcaster, fee_estimator, logger);
|
||||
let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); };
|
||||
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { let (mut orig_orig_ret_0_1_0_0, mut orig_orig_ret_0_1_0_1) = item; let mut local_orig_ret_0_1_0 = (orig_orig_ret_0_1_0_0, crate::c_types::TxOut::from_rust(orig_orig_ret_0_1_0_1)).into(); local_orig_ret_0_1_0 }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); };
|
||||
local_ret.into()
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,264 @@ use std::ffi::c_void;
|
|||
use bitcoin::hashes::Hash;
|
||||
use crate::c_types::*;
|
||||
|
||||
|
||||
use lightning::chain::keysinterface::DelayedPaymentOutputDescriptor as nativeDelayedPaymentOutputDescriptorImport;
|
||||
type nativeDelayedPaymentOutputDescriptor = nativeDelayedPaymentOutputDescriptorImport;
|
||||
|
||||
/// Information about a spendable output to a P2WSH script. See
|
||||
/// SpendableOutputDescriptor::DelayedPaymentOutput for more details on how to spend this.
|
||||
#[must_use]
|
||||
#[repr(C)]
|
||||
pub struct DelayedPaymentOutputDescriptor {
|
||||
/// 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 nativeDelayedPaymentOutputDescriptor,
|
||||
pub is_owned: bool,
|
||||
}
|
||||
|
||||
impl Drop for DelayedPaymentOutputDescriptor {
|
||||
fn drop(&mut self) {
|
||||
if self.is_owned && !self.inner.is_null() {
|
||||
let _ = unsafe { Box::from_raw(self.inner) };
|
||||
}
|
||||
}
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn DelayedPaymentOutputDescriptor_free(this_ptr: DelayedPaymentOutputDescriptor) { }
|
||||
#[allow(unused)]
|
||||
/// Used only if an object of this type is returned as a trait impl by a method
|
||||
extern "C" fn DelayedPaymentOutputDescriptor_free_void(this_ptr: *mut c_void) {
|
||||
unsafe { let _ = Box::from_raw(this_ptr as *mut nativeDelayedPaymentOutputDescriptor); }
|
||||
}
|
||||
#[allow(unused)]
|
||||
/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
|
||||
impl DelayedPaymentOutputDescriptor {
|
||||
pub(crate) fn take_inner(mut self) -> *mut nativeDelayedPaymentOutputDescriptor {
|
||||
assert!(self.is_owned);
|
||||
let ret = self.inner;
|
||||
self.inner = std::ptr::null_mut();
|
||||
ret
|
||||
}
|
||||
}
|
||||
/// The outpoint which is spendable
|
||||
#[no_mangle]
|
||||
pub extern "C" fn DelayedPaymentOutputDescriptor_get_outpoint(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::chain::transaction::OutPoint {
|
||||
let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outpoint;
|
||||
crate::chain::transaction::OutPoint { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
|
||||
}
|
||||
/// The outpoint which is spendable
|
||||
#[no_mangle]
|
||||
pub extern "C" fn DelayedPaymentOutputDescriptor_set_outpoint(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::chain::transaction::OutPoint) {
|
||||
unsafe { &mut *this_ptr.inner }.outpoint = *unsafe { Box::from_raw(val.take_inner()) };
|
||||
}
|
||||
/// Per commitment point to derive delayed_payment_key by key holder
|
||||
#[no_mangle]
|
||||
pub extern "C" fn DelayedPaymentOutputDescriptor_get_per_commitment_point(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::PublicKey {
|
||||
let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.per_commitment_point;
|
||||
crate::c_types::PublicKey::from_rust(&(*inner_val))
|
||||
}
|
||||
/// Per commitment point to derive delayed_payment_key by key holder
|
||||
#[no_mangle]
|
||||
pub extern "C" fn DelayedPaymentOutputDescriptor_set_per_commitment_point(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::PublicKey) {
|
||||
unsafe { &mut *this_ptr.inner }.per_commitment_point = val.into_rust();
|
||||
}
|
||||
/// The nSequence value which must be set in the spending input to satisfy the OP_CSV in
|
||||
/// the witness_script.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn DelayedPaymentOutputDescriptor_get_to_self_delay(this_ptr: &DelayedPaymentOutputDescriptor) -> u16 {
|
||||
let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.to_self_delay;
|
||||
(*inner_val)
|
||||
}
|
||||
/// The nSequence value which must be set in the spending input to satisfy the OP_CSV in
|
||||
/// the witness_script.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn DelayedPaymentOutputDescriptor_set_to_self_delay(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: u16) {
|
||||
unsafe { &mut *this_ptr.inner }.to_self_delay = val;
|
||||
}
|
||||
/// The output which is referenced by the given outpoint
|
||||
#[no_mangle]
|
||||
pub extern "C" fn DelayedPaymentOutputDescriptor_set_output(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::TxOut) {
|
||||
unsafe { &mut *this_ptr.inner }.output = val.into_rust();
|
||||
}
|
||||
/// The revocation point specific to the commitment transaction which was broadcast. Used to
|
||||
/// derive the witnessScript for this output.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn DelayedPaymentOutputDescriptor_get_revocation_pubkey(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::c_types::PublicKey {
|
||||
let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.revocation_pubkey;
|
||||
crate::c_types::PublicKey::from_rust(&(*inner_val))
|
||||
}
|
||||
/// The revocation point specific to the commitment transaction which was broadcast. Used to
|
||||
/// derive the witnessScript for this output.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn DelayedPaymentOutputDescriptor_set_revocation_pubkey(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::PublicKey) {
|
||||
unsafe { &mut *this_ptr.inner }.revocation_pubkey = val.into_rust();
|
||||
}
|
||||
/// Arbitrary identification information returned by a call to
|
||||
/// `ChannelKeys::channel_keys_id()`. This may be useful in re-deriving keys used in
|
||||
/// the channel to spend the output.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &DelayedPaymentOutputDescriptor) -> *const [u8; 32] {
|
||||
let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_keys_id;
|
||||
&(*inner_val)
|
||||
}
|
||||
/// Arbitrary identification information returned by a call to
|
||||
/// `ChannelKeys::channel_keys_id()`. This may be useful in re-deriving keys used in
|
||||
/// the channel to spend the output.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::c_types::ThirtyTwoBytes) {
|
||||
unsafe { &mut *this_ptr.inner }.channel_keys_id = val.data;
|
||||
}
|
||||
/// The value of the channel which this output originated from, possibly indirectly.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_value_satoshis(this_ptr: &DelayedPaymentOutputDescriptor) -> u64 {
|
||||
let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_value_satoshis;
|
||||
(*inner_val)
|
||||
}
|
||||
/// The value of the channel which this output originated from, possibly indirectly.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_value_satoshis(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: u64) {
|
||||
unsafe { &mut *this_ptr.inner }.channel_value_satoshis = val;
|
||||
}
|
||||
#[must_use]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn DelayedPaymentOutputDescriptor_new(mut outpoint_arg: crate::chain::transaction::OutPoint, mut per_commitment_point_arg: crate::c_types::PublicKey, mut to_self_delay_arg: u16, mut output_arg: crate::c_types::TxOut, mut revocation_pubkey_arg: crate::c_types::PublicKey, mut channel_keys_id_arg: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis_arg: u64) -> DelayedPaymentOutputDescriptor {
|
||||
DelayedPaymentOutputDescriptor { inner: Box::into_raw(Box::new(nativeDelayedPaymentOutputDescriptor {
|
||||
outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) },
|
||||
per_commitment_point: per_commitment_point_arg.into_rust(),
|
||||
to_self_delay: to_self_delay_arg,
|
||||
output: output_arg.into_rust(),
|
||||
revocation_pubkey: revocation_pubkey_arg.into_rust(),
|
||||
channel_keys_id: channel_keys_id_arg.data,
|
||||
channel_value_satoshis: channel_value_satoshis_arg,
|
||||
})), is_owned: true }
|
||||
}
|
||||
impl Clone for DelayedPaymentOutputDescriptor {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
inner: if self.inner.is_null() { std::ptr::null_mut() } else {
|
||||
Box::into_raw(Box::new(unsafe { &*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 DelayedPaymentOutputDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void {
|
||||
Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeDelayedPaymentOutputDescriptor)).clone() })) as *mut c_void
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn DelayedPaymentOutputDescriptor_clone(orig: &DelayedPaymentOutputDescriptor) -> DelayedPaymentOutputDescriptor {
|
||||
orig.clone()
|
||||
}
|
||||
|
||||
use lightning::chain::keysinterface::StaticPaymentOutputDescriptor as nativeStaticPaymentOutputDescriptorImport;
|
||||
type nativeStaticPaymentOutputDescriptor = nativeStaticPaymentOutputDescriptorImport;
|
||||
|
||||
/// Information about a spendable output to our \"payment key\". See
|
||||
/// SpendableOutputDescriptor::StaticPaymentOutput for more details on how to spend this.
|
||||
#[must_use]
|
||||
#[repr(C)]
|
||||
pub struct StaticPaymentOutputDescriptor {
|
||||
/// 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 nativeStaticPaymentOutputDescriptor,
|
||||
pub is_owned: bool,
|
||||
}
|
||||
|
||||
impl Drop for StaticPaymentOutputDescriptor {
|
||||
fn drop(&mut self) {
|
||||
if self.is_owned && !self.inner.is_null() {
|
||||
let _ = unsafe { Box::from_raw(self.inner) };
|
||||
}
|
||||
}
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn StaticPaymentOutputDescriptor_free(this_ptr: StaticPaymentOutputDescriptor) { }
|
||||
#[allow(unused)]
|
||||
/// Used only if an object of this type is returned as a trait impl by a method
|
||||
extern "C" fn StaticPaymentOutputDescriptor_free_void(this_ptr: *mut c_void) {
|
||||
unsafe { let _ = Box::from_raw(this_ptr as *mut nativeStaticPaymentOutputDescriptor); }
|
||||
}
|
||||
#[allow(unused)]
|
||||
/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
|
||||
impl StaticPaymentOutputDescriptor {
|
||||
pub(crate) fn take_inner(mut self) -> *mut nativeStaticPaymentOutputDescriptor {
|
||||
assert!(self.is_owned);
|
||||
let ret = self.inner;
|
||||
self.inner = std::ptr::null_mut();
|
||||
ret
|
||||
}
|
||||
}
|
||||
/// The outpoint which is spendable
|
||||
#[no_mangle]
|
||||
pub extern "C" fn StaticPaymentOutputDescriptor_get_outpoint(this_ptr: &StaticPaymentOutputDescriptor) -> crate::chain::transaction::OutPoint {
|
||||
let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.outpoint;
|
||||
crate::chain::transaction::OutPoint { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
|
||||
}
|
||||
/// The outpoint which is spendable
|
||||
#[no_mangle]
|
||||
pub extern "C" fn StaticPaymentOutputDescriptor_set_outpoint(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::chain::transaction::OutPoint) {
|
||||
unsafe { &mut *this_ptr.inner }.outpoint = *unsafe { Box::from_raw(val.take_inner()) };
|
||||
}
|
||||
/// The output which is referenced by the given outpoint
|
||||
#[no_mangle]
|
||||
pub extern "C" fn StaticPaymentOutputDescriptor_set_output(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::c_types::TxOut) {
|
||||
unsafe { &mut *this_ptr.inner }.output = val.into_rust();
|
||||
}
|
||||
/// Arbitrary identification information returned by a call to
|
||||
/// `ChannelKeys::channel_keys_id()`. This may be useful in re-deriving keys used in
|
||||
/// the channel to spend the output.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_keys_id(this_ptr: &StaticPaymentOutputDescriptor) -> *const [u8; 32] {
|
||||
let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_keys_id;
|
||||
&(*inner_val)
|
||||
}
|
||||
/// Arbitrary identification information returned by a call to
|
||||
/// `ChannelKeys::channel_keys_id()`. This may be useful in re-deriving keys used in
|
||||
/// the channel to spend the output.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_keys_id(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: crate::c_types::ThirtyTwoBytes) {
|
||||
unsafe { &mut *this_ptr.inner }.channel_keys_id = val.data;
|
||||
}
|
||||
/// The value of the channel which this transactions spends.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn StaticPaymentOutputDescriptor_get_channel_value_satoshis(this_ptr: &StaticPaymentOutputDescriptor) -> u64 {
|
||||
let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_value_satoshis;
|
||||
(*inner_val)
|
||||
}
|
||||
/// The value of the channel which this transactions spends.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn StaticPaymentOutputDescriptor_set_channel_value_satoshis(this_ptr: &mut StaticPaymentOutputDescriptor, mut val: u64) {
|
||||
unsafe { &mut *this_ptr.inner }.channel_value_satoshis = val;
|
||||
}
|
||||
#[must_use]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn StaticPaymentOutputDescriptor_new(mut outpoint_arg: crate::chain::transaction::OutPoint, mut output_arg: crate::c_types::TxOut, mut channel_keys_id_arg: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis_arg: u64) -> StaticPaymentOutputDescriptor {
|
||||
StaticPaymentOutputDescriptor { inner: Box::into_raw(Box::new(nativeStaticPaymentOutputDescriptor {
|
||||
outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) },
|
||||
output: output_arg.into_rust(),
|
||||
channel_keys_id: channel_keys_id_arg.data,
|
||||
channel_value_satoshis: channel_value_satoshis_arg,
|
||||
})), is_owned: true }
|
||||
}
|
||||
impl Clone for StaticPaymentOutputDescriptor {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
inner: if self.inner.is_null() { std::ptr::null_mut() } else {
|
||||
Box::into_raw(Box::new(unsafe { &*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 StaticPaymentOutputDescriptor_clone_void(this_ptr: *const c_void) -> *mut c_void {
|
||||
Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeStaticPaymentOutputDescriptor)).clone() })) as *mut c_void
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn StaticPaymentOutputDescriptor_clone(orig: &StaticPaymentOutputDescriptor) -> StaticPaymentOutputDescriptor {
|
||||
orig.clone()
|
||||
}
|
||||
/// When on-chain outputs are created by rust-lightning (which our counterparty is not able to
|
||||
/// claim at any point in the future) an event is generated which you must track and be able to
|
||||
/// spend on-chain. The information needed to do this is provided in this enum, including the
|
||||
|
@ -52,15 +310,7 @@ pub enum SpendableOutputDescriptor {
|
|||
/// regenerated by passing the revocation_pubkey (derived as above), our delayed_payment pubkey
|
||||
/// (derived as above), and the to_self_delay contained here to
|
||||
/// chan_utils::get_revokeable_redeemscript.
|
||||
DynamicOutputP2WSH {
|
||||
outpoint: crate::chain::transaction::OutPoint,
|
||||
per_commitment_point: crate::c_types::PublicKey,
|
||||
to_self_delay: u16,
|
||||
output: crate::c_types::TxOut,
|
||||
revocation_pubkey: crate::c_types::PublicKey,
|
||||
channel_keys_id: crate::c_types::ThirtyTwoBytes,
|
||||
channel_value_satoshis: u64,
|
||||
},
|
||||
DelayedPaymentOutput(crate::chain::keysinterface::DelayedPaymentOutputDescriptor),
|
||||
/// An output to a P2WPKH, spendable exclusively by our payment key (ie the private key which
|
||||
/// corresponds to the public key in ChannelKeys::pubkeys().payment_point).
|
||||
/// The witness in the spending input, is, thus, simply:
|
||||
|
@ -68,12 +318,7 @@ pub enum SpendableOutputDescriptor {
|
|||
///
|
||||
/// These are generally the result of our counterparty having broadcast the current state,
|
||||
/// allowing us to claim the non-HTLC-encumbered outputs immediately.
|
||||
StaticOutputCounterpartyPayment {
|
||||
outpoint: crate::chain::transaction::OutPoint,
|
||||
output: crate::c_types::TxOut,
|
||||
channel_keys_id: crate::c_types::ThirtyTwoBytes,
|
||||
channel_value_satoshis: u64,
|
||||
},
|
||||
StaticPaymentOutput(crate::chain::keysinterface::StaticPaymentOutputDescriptor),
|
||||
}
|
||||
use lightning::chain::keysinterface::SpendableOutputDescriptor as nativeSpendableOutputDescriptor;
|
||||
impl SpendableOutputDescriptor {
|
||||
|
@ -88,35 +333,17 @@ impl SpendableOutputDescriptor {
|
|||
output: output_nonref.into_rust(),
|
||||
}
|
||||
},
|
||||
SpendableOutputDescriptor::DynamicOutputP2WSH {ref outpoint, ref per_commitment_point, ref to_self_delay, ref output, ref revocation_pubkey, ref channel_keys_id, ref channel_value_satoshis, } => {
|
||||
let mut outpoint_nonref = (*outpoint).clone();
|
||||
let mut per_commitment_point_nonref = (*per_commitment_point).clone();
|
||||
let mut to_self_delay_nonref = (*to_self_delay).clone();
|
||||
let mut output_nonref = (*output).clone();
|
||||
let mut revocation_pubkey_nonref = (*revocation_pubkey).clone();
|
||||
let mut channel_keys_id_nonref = (*channel_keys_id).clone();
|
||||
let mut channel_value_satoshis_nonref = (*channel_value_satoshis).clone();
|
||||
nativeSpendableOutputDescriptor::DynamicOutputP2WSH {
|
||||
outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_inner()) },
|
||||
per_commitment_point: per_commitment_point_nonref.into_rust(),
|
||||
to_self_delay: to_self_delay_nonref,
|
||||
output: output_nonref.into_rust(),
|
||||
revocation_pubkey: revocation_pubkey_nonref.into_rust(),
|
||||
channel_keys_id: channel_keys_id_nonref.data,
|
||||
channel_value_satoshis: channel_value_satoshis_nonref,
|
||||
}
|
||||
SpendableOutputDescriptor::DelayedPaymentOutput (ref a, ) => {
|
||||
let mut a_nonref = (*a).clone();
|
||||
nativeSpendableOutputDescriptor::DelayedPaymentOutput (
|
||||
*unsafe { Box::from_raw(a_nonref.take_inner()) },
|
||||
)
|
||||
},
|
||||
SpendableOutputDescriptor::StaticOutputCounterpartyPayment {ref outpoint, ref output, ref channel_keys_id, ref channel_value_satoshis, } => {
|
||||
let mut outpoint_nonref = (*outpoint).clone();
|
||||
let mut output_nonref = (*output).clone();
|
||||
let mut channel_keys_id_nonref = (*channel_keys_id).clone();
|
||||
let mut channel_value_satoshis_nonref = (*channel_value_satoshis).clone();
|
||||
nativeSpendableOutputDescriptor::StaticOutputCounterpartyPayment {
|
||||
outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_inner()) },
|
||||
output: output_nonref.into_rust(),
|
||||
channel_keys_id: channel_keys_id_nonref.data,
|
||||
channel_value_satoshis: channel_value_satoshis_nonref,
|
||||
}
|
||||
SpendableOutputDescriptor::StaticPaymentOutput (ref a, ) => {
|
||||
let mut a_nonref = (*a).clone();
|
||||
nativeSpendableOutputDescriptor::StaticPaymentOutput (
|
||||
*unsafe { Box::from_raw(a_nonref.take_inner()) },
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -129,24 +356,15 @@ impl SpendableOutputDescriptor {
|
|||
output: output.into_rust(),
|
||||
}
|
||||
},
|
||||
SpendableOutputDescriptor::DynamicOutputP2WSH {mut outpoint, mut per_commitment_point, mut to_self_delay, mut output, mut revocation_pubkey, mut channel_keys_id, mut channel_value_satoshis, } => {
|
||||
nativeSpendableOutputDescriptor::DynamicOutputP2WSH {
|
||||
outpoint: *unsafe { Box::from_raw(outpoint.take_inner()) },
|
||||
per_commitment_point: per_commitment_point.into_rust(),
|
||||
to_self_delay: to_self_delay,
|
||||
output: output.into_rust(),
|
||||
revocation_pubkey: revocation_pubkey.into_rust(),
|
||||
channel_keys_id: channel_keys_id.data,
|
||||
channel_value_satoshis: channel_value_satoshis,
|
||||
}
|
||||
SpendableOutputDescriptor::DelayedPaymentOutput (mut a, ) => {
|
||||
nativeSpendableOutputDescriptor::DelayedPaymentOutput (
|
||||
*unsafe { Box::from_raw(a.take_inner()) },
|
||||
)
|
||||
},
|
||||
SpendableOutputDescriptor::StaticOutputCounterpartyPayment {mut outpoint, mut output, mut channel_keys_id, mut channel_value_satoshis, } => {
|
||||
nativeSpendableOutputDescriptor::StaticOutputCounterpartyPayment {
|
||||
outpoint: *unsafe { Box::from_raw(outpoint.take_inner()) },
|
||||
output: output.into_rust(),
|
||||
channel_keys_id: channel_keys_id.data,
|
||||
channel_value_satoshis: channel_value_satoshis,
|
||||
}
|
||||
SpendableOutputDescriptor::StaticPaymentOutput (mut a, ) => {
|
||||
nativeSpendableOutputDescriptor::StaticPaymentOutput (
|
||||
*unsafe { Box::from_raw(a.take_inner()) },
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -161,35 +379,17 @@ impl SpendableOutputDescriptor {
|
|||
output: crate::c_types::TxOut::from_rust(output_nonref),
|
||||
}
|
||||
},
|
||||
nativeSpendableOutputDescriptor::DynamicOutputP2WSH {ref outpoint, ref per_commitment_point, ref to_self_delay, ref output, ref revocation_pubkey, ref channel_keys_id, ref channel_value_satoshis, } => {
|
||||
let mut outpoint_nonref = (*outpoint).clone();
|
||||
let mut per_commitment_point_nonref = (*per_commitment_point).clone();
|
||||
let mut to_self_delay_nonref = (*to_self_delay).clone();
|
||||
let mut output_nonref = (*output).clone();
|
||||
let mut revocation_pubkey_nonref = (*revocation_pubkey).clone();
|
||||
let mut channel_keys_id_nonref = (*channel_keys_id).clone();
|
||||
let mut channel_value_satoshis_nonref = (*channel_value_satoshis).clone();
|
||||
SpendableOutputDescriptor::DynamicOutputP2WSH {
|
||||
outpoint: crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(outpoint_nonref)), is_owned: true },
|
||||
per_commitment_point: crate::c_types::PublicKey::from_rust(&per_commitment_point_nonref),
|
||||
to_self_delay: to_self_delay_nonref,
|
||||
output: crate::c_types::TxOut::from_rust(output_nonref),
|
||||
revocation_pubkey: crate::c_types::PublicKey::from_rust(&revocation_pubkey_nonref),
|
||||
channel_keys_id: crate::c_types::ThirtyTwoBytes { data: channel_keys_id_nonref },
|
||||
channel_value_satoshis: channel_value_satoshis_nonref,
|
||||
}
|
||||
nativeSpendableOutputDescriptor::DelayedPaymentOutput (ref a, ) => {
|
||||
let mut a_nonref = (*a).clone();
|
||||
SpendableOutputDescriptor::DelayedPaymentOutput (
|
||||
crate::chain::keysinterface::DelayedPaymentOutputDescriptor { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true },
|
||||
)
|
||||
},
|
||||
nativeSpendableOutputDescriptor::StaticOutputCounterpartyPayment {ref outpoint, ref output, ref channel_keys_id, ref channel_value_satoshis, } => {
|
||||
let mut outpoint_nonref = (*outpoint).clone();
|
||||
let mut output_nonref = (*output).clone();
|
||||
let mut channel_keys_id_nonref = (*channel_keys_id).clone();
|
||||
let mut channel_value_satoshis_nonref = (*channel_value_satoshis).clone();
|
||||
SpendableOutputDescriptor::StaticOutputCounterpartyPayment {
|
||||
outpoint: crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(outpoint_nonref)), is_owned: true },
|
||||
output: crate::c_types::TxOut::from_rust(output_nonref),
|
||||
channel_keys_id: crate::c_types::ThirtyTwoBytes { data: channel_keys_id_nonref },
|
||||
channel_value_satoshis: channel_value_satoshis_nonref,
|
||||
}
|
||||
nativeSpendableOutputDescriptor::StaticPaymentOutput (ref a, ) => {
|
||||
let mut a_nonref = (*a).clone();
|
||||
SpendableOutputDescriptor::StaticPaymentOutput (
|
||||
crate::chain::keysinterface::StaticPaymentOutputDescriptor { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true },
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -202,24 +402,15 @@ impl SpendableOutputDescriptor {
|
|||
output: crate::c_types::TxOut::from_rust(output),
|
||||
}
|
||||
},
|
||||
nativeSpendableOutputDescriptor::DynamicOutputP2WSH {mut outpoint, mut per_commitment_point, mut to_self_delay, mut output, mut revocation_pubkey, mut channel_keys_id, mut channel_value_satoshis, } => {
|
||||
SpendableOutputDescriptor::DynamicOutputP2WSH {
|
||||
outpoint: crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(outpoint)), is_owned: true },
|
||||
per_commitment_point: crate::c_types::PublicKey::from_rust(&per_commitment_point),
|
||||
to_self_delay: to_self_delay,
|
||||
output: crate::c_types::TxOut::from_rust(output),
|
||||
revocation_pubkey: crate::c_types::PublicKey::from_rust(&revocation_pubkey),
|
||||
channel_keys_id: crate::c_types::ThirtyTwoBytes { data: channel_keys_id },
|
||||
channel_value_satoshis: channel_value_satoshis,
|
||||
}
|
||||
nativeSpendableOutputDescriptor::DelayedPaymentOutput (mut a, ) => {
|
||||
SpendableOutputDescriptor::DelayedPaymentOutput (
|
||||
crate::chain::keysinterface::DelayedPaymentOutputDescriptor { inner: Box::into_raw(Box::new(a)), is_owned: true },
|
||||
)
|
||||
},
|
||||
nativeSpendableOutputDescriptor::StaticOutputCounterpartyPayment {mut outpoint, mut output, mut channel_keys_id, mut channel_value_satoshis, } => {
|
||||
SpendableOutputDescriptor::StaticOutputCounterpartyPayment {
|
||||
outpoint: crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(outpoint)), is_owned: true },
|
||||
output: crate::c_types::TxOut::from_rust(output),
|
||||
channel_keys_id: crate::c_types::ThirtyTwoBytes { data: channel_keys_id },
|
||||
channel_value_satoshis: channel_value_satoshis,
|
||||
}
|
||||
nativeSpendableOutputDescriptor::StaticPaymentOutput (mut a, ) => {
|
||||
SpendableOutputDescriptor::StaticPaymentOutput (
|
||||
crate::chain::keysinterface::StaticPaymentOutputDescriptor { inner: Box::into_raw(Box::new(a)), is_owned: true },
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -257,11 +448,6 @@ pub extern "C" fn SpendableOutputDescriptor_read(ser: crate::c_types::u8slice) -
|
|||
/// In any case, ChannelMonitor or fallback watchtowers are always going to be trusted
|
||||
/// to act, as liveness and breach reply correctness are always going to be hard requirements
|
||||
/// of LN security model, orthogonal of key management issues.
|
||||
///
|
||||
/// If you're implementing a custom signer, you almost certainly want to implement
|
||||
/// Readable/Writable to serialize out a unique reference to this set of keys so
|
||||
/// that you can serialize the full ChannelManager object.
|
||||
///
|
||||
#[repr(C)]
|
||||
pub struct ChannelKeys {
|
||||
pub this_arg: *mut c_void,
|
||||
|
@ -278,7 +464,6 @@ pub struct ChannelKeys {
|
|||
/// May be called more than once for the same index.
|
||||
///
|
||||
/// Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
|
||||
/// TODO: return a Result so we can signal a validation error
|
||||
#[must_use]
|
||||
pub release_commitment_secret: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::ThirtyTwoBytes,
|
||||
/// Gets the holder's channel public keys and basepoints
|
||||
|
@ -779,6 +964,33 @@ pub extern "C" fn InMemoryChannelKeys_get_channel_parameters(this_arg: &InMemory
|
|||
crate::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ( (&(*ret) as *const _) as *mut _) }, is_owned: false }
|
||||
}
|
||||
|
||||
/// Sign the single input of spend_tx at index `input_idx` which spends the output
|
||||
/// described by descriptor, returning the witness stack for the input.
|
||||
///
|
||||
/// Returns an Err if the input at input_idx does not exist, has a non-empty script_sig,
|
||||
/// or is not spending the outpoint described by `descriptor.outpoint`.
|
||||
#[must_use]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn InMemoryChannelKeys_sign_counterparty_payment_input(this_arg: &InMemoryChannelKeys, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::chain::keysinterface::StaticPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ {
|
||||
let mut ret = unsafe { &*this_arg.inner }.sign_counterparty_payment_input(&spend_tx.into_bitcoin(), input_idx, unsafe { &*descriptor.inner }, &bitcoin::secp256k1::Secp256k1::new());
|
||||
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = Vec::new(); for mut item in item.drain(..) { local_ret_0_0.push( { item }); }; local_ret_0_0.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
|
||||
local_ret
|
||||
}
|
||||
|
||||
/// Sign the single input of spend_tx at index `input_idx` which spends the output
|
||||
/// described by descriptor, returning the witness stack for the input.
|
||||
///
|
||||
/// Returns an Err if the input at input_idx does not exist, has a non-empty script_sig,
|
||||
/// is not spending the outpoint described by `descriptor.outpoint`, or does not have a
|
||||
/// sequence set to `descriptor.to_self_delay`.
|
||||
#[must_use]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn InMemoryChannelKeys_sign_dynamic_p2wsh_input(this_arg: &InMemoryChannelKeys, mut spend_tx: crate::c_types::Transaction, mut input_idx: usize, descriptor: &crate::chain::keysinterface::DelayedPaymentOutputDescriptor) -> crate::c_types::derived::CResult_CVec_CVec_u8ZZNoneZ {
|
||||
let mut ret = unsafe { &*this_arg.inner }.sign_dynamic_p2wsh_input(&spend_tx.into_bitcoin(), input_idx, unsafe { &*descriptor.inner }, &bitcoin::secp256k1::Secp256k1::new());
|
||||
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let mut local_ret_0_0 = Vec::new(); for mut item in item.drain(..) { local_ret_0_0.push( { item }); }; local_ret_0_0.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
|
||||
local_ret
|
||||
}
|
||||
|
||||
impl From<nativeInMemoryChannelKeys> for crate::chain::keysinterface::ChannelKeys {
|
||||
fn from(obj: nativeInMemoryChannelKeys) -> Self {
|
||||
let mut rust_obj = InMemoryChannelKeys { inner: Box::into_raw(Box::new(obj)), is_owned: true };
|
||||
|
@ -842,13 +1054,13 @@ extern "C" fn InMemoryChannelKeys_ChannelKeys_channel_keys_id(this_arg: *const c
|
|||
#[must_use]
|
||||
extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_counterparty_commitment(this_arg: *const c_void, commitment_tx: &crate::ln::chan_utils::CommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
|
||||
let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_counterparty_commitment(unsafe { &*commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new());
|
||||
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
|
||||
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
|
||||
local_ret
|
||||
}
|
||||
#[must_use]
|
||||
extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_holder_commitment_and_htlcs(this_arg: *const c_void, commitment_tx: &crate::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
|
||||
let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_holder_commitment_and_htlcs(unsafe { &*commitment_tx.inner }, &bitcoin::secp256k1::Secp256k1::new());
|
||||
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
|
||||
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
|
||||
local_ret
|
||||
}
|
||||
#[must_use]
|
||||
|
@ -959,8 +1171,8 @@ impl KeysManager {
|
|||
/// detailed description of the guarantee.
|
||||
#[must_use]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn KeysManager_new(seed: *const [u8; 32], mut network: crate::bitcoin::network::Network, mut starting_time_secs: u64, mut starting_time_nanos: u32) -> KeysManager {
|
||||
let mut ret = lightning::chain::keysinterface::KeysManager::new(unsafe { &*seed}, network.into_bitcoin(), starting_time_secs, starting_time_nanos);
|
||||
pub extern "C" fn KeysManager_new(seed: *const [u8; 32], mut starting_time_secs: u64, mut starting_time_nanos: u32) -> KeysManager {
|
||||
let mut ret = lightning::chain::keysinterface::KeysManager::new(unsafe { &*seed}, starting_time_secs, starting_time_nanos);
|
||||
KeysManager { inner: Box::into_raw(Box::new(ret)), is_owned: true }
|
||||
}
|
||||
|
||||
|
@ -976,6 +1188,27 @@ pub extern "C" fn KeysManager_derive_channel_keys(this_arg: &KeysManager, mut ch
|
|||
crate::chain::keysinterface::InMemoryChannelKeys { inner: Box::into_raw(Box::new(ret)), is_owned: true }
|
||||
}
|
||||
|
||||
/// Creates a Transaction which spends the given descriptors to the given outputs, plus an
|
||||
/// output to the given change destination (if sufficient change value remains). The
|
||||
/// transaction will have a feerate, at least, of the given value.
|
||||
///
|
||||
/// Returns `Err(())` if the output value is greater than the input value minus required fee or
|
||||
/// if a descriptor was duplicated.
|
||||
///
|
||||
/// We do not enforce that outputs meet the dust limit or that any output scripts are standard.
|
||||
///
|
||||
/// May panic if the `SpendableOutputDescriptor`s were not generated by Channels which used
|
||||
/// this KeysManager or one of the `InMemoryChannelKeys` created by this KeysManager.
|
||||
#[must_use]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn KeysManager_spend_spendable_outputs(this_arg: &KeysManager, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32) -> crate::c_types::derived::CResult_TransactionNoneZ {
|
||||
let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); };
|
||||
let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); };
|
||||
let mut ret = unsafe { &*this_arg.inner }.spend_spendable_outputs(&local_descriptors.iter().collect::<Vec<_>>()[..], local_outputs, ::bitcoin::blockdata::script::Script::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, &bitcoin::secp256k1::Secp256k1::new());
|
||||
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = ::bitcoin::consensus::encode::serialize(&o); crate::c_types::Transaction::from_vec(local_ret_0) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
|
||||
local_ret
|
||||
}
|
||||
|
||||
impl From<nativeKeysManager> for crate::chain::keysinterface::KeysInterface {
|
||||
fn from(obj: nativeKeysManager) -> Self {
|
||||
let mut rust_obj = KeysManager { inner: Box::into_raw(Box::new(obj)), is_owned: true };
|
||||
|
|
|
@ -168,7 +168,7 @@ impl rustWatch for Watch {
|
|||
}
|
||||
fn release_pending_monitor_events(&self) -> Vec<lightning::chain::channelmonitor::MonitorEvent> {
|
||||
let mut ret = (self.release_pending_monitor_events)(self.this_arg);
|
||||
let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
|
||||
let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); };
|
||||
local_ret
|
||||
}
|
||||
}
|
||||
|
|
|
@ -396,6 +396,9 @@ pub extern "C" fn TxCreationKeys_from_channel_static_keys(mut per_commitment_poi
|
|||
local_ret
|
||||
}
|
||||
|
||||
|
||||
#[no_mangle]
|
||||
pub static REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH: usize = lightning::ln::chan_utils::REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH;
|
||||
/// A script either spendable by the revocation
|
||||
/// key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain.
|
||||
/// Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions.
|
||||
|
@ -1351,7 +1354,7 @@ pub extern "C" fn TrustedCommitmentTransaction_keys(this_arg: &TrustedCommitment
|
|||
#[no_mangle]
|
||||
pub extern "C" fn TrustedCommitmentTransaction_get_htlc_sigs(this_arg: &TrustedCommitmentTransaction, htlc_base_key: *const [u8; 32], channel_parameters: &crate::ln::chan_utils::DirectedChannelTransactionParameters) -> crate::c_types::derived::CResult_CVec_SignatureZNoneZ {
|
||||
let mut ret = unsafe { &*this_arg.inner }.get_htlc_sigs(&::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *htlc_base_key}[..]).unwrap(), unsafe { &*channel_parameters.inner }, &bitcoin::secp256k1::Secp256k1::new());
|
||||
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for item in o.drain(..) { local_ret_0.push( { crate::c_types::Signature::from_rust(&item) }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
|
||||
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { crate::c_types::Signature::from_rust(&item) }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }).into() };
|
||||
local_ret
|
||||
}
|
||||
|
||||
|
|
|
@ -256,60 +256,168 @@ pub(crate) extern "C" fn ChannelDetails_clone_void(this_ptr: *const c_void) -> *
|
|||
pub extern "C" fn ChannelDetails_clone(orig: &ChannelDetails) -> ChannelDetails {
|
||||
orig.clone()
|
||||
}
|
||||
|
||||
use lightning::ln::channelmanager::PaymentSendFailure as nativePaymentSendFailureImport;
|
||||
type nativePaymentSendFailure = nativePaymentSendFailureImport;
|
||||
|
||||
/// If a payment fails to send, it can be in one of several states. This enum is returned as the
|
||||
/// Err() type describing which state the payment is in, see the description of individual enum
|
||||
/// states for more.
|
||||
#[must_use]
|
||||
#[derive(Clone)]
|
||||
#[repr(C)]
|
||||
pub struct PaymentSendFailure {
|
||||
/// 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 nativePaymentSendFailure,
|
||||
pub is_owned: bool,
|
||||
pub enum PaymentSendFailure {
|
||||
/// A parameter which was passed to send_payment was invalid, preventing us from attempting to
|
||||
/// send the payment at all. No channel state has been changed or messages sent to peers, and
|
||||
/// once you've changed the parameter at error, you can freely retry the payment in full.
|
||||
ParameterError(crate::util::errors::APIError),
|
||||
/// A parameter in a single path which was passed to send_payment was invalid, preventing us
|
||||
/// from attempting to send the payment at all. No channel state has been changed or messages
|
||||
/// sent to peers, and once you've changed the parameter at error, you can freely retry the
|
||||
/// payment in full.
|
||||
///
|
||||
/// The results here are ordered the same as the paths in the route object which was passed to
|
||||
/// send_payment.
|
||||
PathParameterError(crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ),
|
||||
/// All paths which were attempted failed to send, with no channel state change taking place.
|
||||
/// You can freely retry the payment in full (though you probably want to do so over different
|
||||
/// paths than the ones selected).
|
||||
AllFailedRetrySafe(crate::c_types::derived::CVec_APIErrorZ),
|
||||
/// Some paths which were attempted failed to send, though possibly not all. At least some
|
||||
/// paths have irrevocably committed to the HTLC and retrying the payment in full would result
|
||||
/// in over-/re-payment.
|
||||
///
|
||||
/// The results here are ordered the same as the paths in the route object which was passed to
|
||||
/// send_payment, and any Errs which are not APIError::MonitorUpdateFailed can be safely
|
||||
/// retried (though there is currently no API with which to do so).
|
||||
///
|
||||
/// Any entries which contain Err(APIError::MonitorUpdateFailed) or Ok(()) MUST NOT be retried
|
||||
/// as they will result in over-/re-payment. These HTLCs all either successfully sent (in the
|
||||
/// case of Ok(())) or will send once channel_monitor_updated is called on the next-hop channel
|
||||
/// with the latest update_id.
|
||||
PartialFailure(crate::c_types::derived::CVec_CResult_NoneAPIErrorZZ),
|
||||
}
|
||||
|
||||
impl Drop for PaymentSendFailure {
|
||||
fn drop(&mut self) {
|
||||
if self.is_owned && !self.inner.is_null() {
|
||||
let _ = unsafe { Box::from_raw(self.inner) };
|
||||
use lightning::ln::channelmanager::PaymentSendFailure as nativePaymentSendFailure;
|
||||
impl PaymentSendFailure {
|
||||
#[allow(unused)]
|
||||
pub(crate) fn to_native(&self) -> nativePaymentSendFailure {
|
||||
match self {
|
||||
PaymentSendFailure::ParameterError (ref a, ) => {
|
||||
let mut a_nonref = (*a).clone();
|
||||
nativePaymentSendFailure::ParameterError (
|
||||
a_nonref.into_native(),
|
||||
)
|
||||
},
|
||||
PaymentSendFailure::PathParameterError (ref a, ) => {
|
||||
let mut a_nonref = (*a).clone();
|
||||
let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { let mut local_a_nonref_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_a_nonref_0 }); };
|
||||
nativePaymentSendFailure::PathParameterError (
|
||||
local_a_nonref,
|
||||
)
|
||||
},
|
||||
PaymentSendFailure::AllFailedRetrySafe (ref a, ) => {
|
||||
let mut a_nonref = (*a).clone();
|
||||
let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { item.into_native() }); };
|
||||
nativePaymentSendFailure::AllFailedRetrySafe (
|
||||
local_a_nonref,
|
||||
)
|
||||
},
|
||||
PaymentSendFailure::PartialFailure (ref a, ) => {
|
||||
let mut a_nonref = (*a).clone();
|
||||
let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { let mut local_a_nonref_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_a_nonref_0 }); };
|
||||
nativePaymentSendFailure::PartialFailure (
|
||||
local_a_nonref,
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub(crate) fn into_native(self) -> nativePaymentSendFailure {
|
||||
match self {
|
||||
PaymentSendFailure::ParameterError (mut a, ) => {
|
||||
nativePaymentSendFailure::ParameterError (
|
||||
a.into_native(),
|
||||
)
|
||||
},
|
||||
PaymentSendFailure::PathParameterError (mut a, ) => {
|
||||
let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { let mut local_a_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_a_0 }); };
|
||||
nativePaymentSendFailure::PathParameterError (
|
||||
local_a,
|
||||
)
|
||||
},
|
||||
PaymentSendFailure::AllFailedRetrySafe (mut a, ) => {
|
||||
let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { item.into_native() }); };
|
||||
nativePaymentSendFailure::AllFailedRetrySafe (
|
||||
local_a,
|
||||
)
|
||||
},
|
||||
PaymentSendFailure::PartialFailure (mut a, ) => {
|
||||
let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { let mut local_a_0 = match item.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut item.contents.err)) }).into_native() })}; local_a_0 }); };
|
||||
nativePaymentSendFailure::PartialFailure (
|
||||
local_a,
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub(crate) fn from_native(native: &nativePaymentSendFailure) -> Self {
|
||||
match native {
|
||||
nativePaymentSendFailure::ParameterError (ref a, ) => {
|
||||
let mut a_nonref = (*a).clone();
|
||||
PaymentSendFailure::ParameterError (
|
||||
crate::util::errors::APIError::native_into(a_nonref),
|
||||
)
|
||||
},
|
||||
nativePaymentSendFailure::PathParameterError (ref a, ) => {
|
||||
let mut a_nonref = (*a).clone();
|
||||
let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { let mut local_a_nonref_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::util::errors::APIError::native_into(e) }).into() }; local_a_nonref_0 }); };
|
||||
PaymentSendFailure::PathParameterError (
|
||||
local_a_nonref.into(),
|
||||
)
|
||||
},
|
||||
nativePaymentSendFailure::AllFailedRetrySafe (ref a, ) => {
|
||||
let mut a_nonref = (*a).clone();
|
||||
let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { crate::util::errors::APIError::native_into(item) }); };
|
||||
PaymentSendFailure::AllFailedRetrySafe (
|
||||
local_a_nonref.into(),
|
||||
)
|
||||
},
|
||||
nativePaymentSendFailure::PartialFailure (ref a, ) => {
|
||||
let mut a_nonref = (*a).clone();
|
||||
let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { let mut local_a_nonref_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::util::errors::APIError::native_into(e) }).into() }; local_a_nonref_0 }); };
|
||||
PaymentSendFailure::PartialFailure (
|
||||
local_a_nonref.into(),
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub(crate) fn native_into(native: nativePaymentSendFailure) -> Self {
|
||||
match native {
|
||||
nativePaymentSendFailure::ParameterError (mut a, ) => {
|
||||
PaymentSendFailure::ParameterError (
|
||||
crate::util::errors::APIError::native_into(a),
|
||||
)
|
||||
},
|
||||
nativePaymentSendFailure::PathParameterError (mut a, ) => {
|
||||
let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { let mut local_a_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::util::errors::APIError::native_into(e) }).into() }; local_a_0 }); };
|
||||
PaymentSendFailure::PathParameterError (
|
||||
local_a.into(),
|
||||
)
|
||||
},
|
||||
nativePaymentSendFailure::AllFailedRetrySafe (mut a, ) => {
|
||||
let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { crate::util::errors::APIError::native_into(item) }); };
|
||||
PaymentSendFailure::AllFailedRetrySafe (
|
||||
local_a.into(),
|
||||
)
|
||||
},
|
||||
nativePaymentSendFailure::PartialFailure (mut a, ) => {
|
||||
let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { let mut local_a_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::util::errors::APIError::native_into(e) }).into() }; local_a_0 }); };
|
||||
PaymentSendFailure::PartialFailure (
|
||||
local_a.into(),
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn PaymentSendFailure_free(this_ptr: PaymentSendFailure) { }
|
||||
#[allow(unused)]
|
||||
/// Used only if an object of this type is returned as a trait impl by a method
|
||||
extern "C" fn PaymentSendFailure_free_void(this_ptr: *mut c_void) {
|
||||
unsafe { let _ = Box::from_raw(this_ptr as *mut nativePaymentSendFailure); }
|
||||
}
|
||||
#[allow(unused)]
|
||||
/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
|
||||
impl PaymentSendFailure {
|
||||
pub(crate) fn take_inner(mut self) -> *mut nativePaymentSendFailure {
|
||||
assert!(self.is_owned);
|
||||
let ret = self.inner;
|
||||
self.inner = std::ptr::null_mut();
|
||||
ret
|
||||
}
|
||||
}
|
||||
impl Clone for PaymentSendFailure {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
inner: if self.inner.is_null() { std::ptr::null_mut() } else {
|
||||
Box::into_raw(Box::new(unsafe { &*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 PaymentSendFailure_clone_void(this_ptr: *const c_void) -> *mut c_void {
|
||||
Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativePaymentSendFailure)).clone() })) as *mut c_void
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn PaymentSendFailure_clone(orig: &PaymentSendFailure) -> PaymentSendFailure {
|
||||
orig.clone()
|
||||
|
@ -362,7 +470,7 @@ pub extern "C" fn ChannelManager_create_channel(this_arg: &ChannelManager, mut t
|
|||
#[no_mangle]
|
||||
pub extern "C" fn ChannelManager_list_channels(this_arg: &ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ {
|
||||
let mut ret = unsafe { &*this_arg.inner }.list_channels();
|
||||
let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::ln::channelmanager::ChannelDetails { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
|
||||
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::ln::channelmanager::ChannelDetails { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
|
||||
local_ret.into()
|
||||
}
|
||||
|
||||
|
@ -375,7 +483,7 @@ pub extern "C" fn ChannelManager_list_channels(this_arg: &ChannelManager) -> cra
|
|||
#[no_mangle]
|
||||
pub extern "C" fn ChannelManager_list_usable_channels(this_arg: &ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ {
|
||||
let mut ret = unsafe { &*this_arg.inner }.list_usable_channels();
|
||||
let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::ln::channelmanager::ChannelDetails { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
|
||||
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::ln::channelmanager::ChannelDetails { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
|
||||
local_ret.into()
|
||||
}
|
||||
|
||||
|
@ -453,7 +561,7 @@ pub extern "C" fn ChannelManager_force_close_all_channels(this_arg: &ChannelMana
|
|||
pub extern "C" fn ChannelManager_send_payment(this_arg: &ChannelManager, route: &crate::routing::router::Route, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut payment_secret: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_NonePaymentSendFailureZ {
|
||||
let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentSecret(payment_secret.data) }) };
|
||||
let mut ret = unsafe { &*this_arg.inner }.send_payment(unsafe { &*route.inner }, ::lightning::ln::channelmanager::PaymentHash(payment_hash.data), &local_payment_secret);
|
||||
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::channelmanager::PaymentSendFailure { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
|
||||
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::channelmanager::PaymentSendFailure::native_into(e) }).into() };
|
||||
local_ret
|
||||
}
|
||||
|
||||
|
@ -600,7 +708,7 @@ use lightning::util::events::MessageSendEventsProvider as MessageSendEventsProvi
|
|||
#[must_use]
|
||||
extern "C" fn ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ {
|
||||
let mut ret = unsafe { &mut *(this_arg as *mut nativeChannelManager) }.get_and_clear_pending_msg_events();
|
||||
let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::util::events::MessageSendEvent::native_into(item) }); };
|
||||
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::util::events::MessageSendEvent::native_into(item) }); };
|
||||
local_ret.into()
|
||||
}
|
||||
|
||||
|
@ -626,7 +734,7 @@ use lightning::util::events::EventsProvider as EventsProviderTraitImport;
|
|||
#[must_use]
|
||||
extern "C" fn ChannelManager_EventsProvider_get_and_clear_pending_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_EventZ {
|
||||
let mut ret = unsafe { &mut *(this_arg as *mut nativeChannelManager) }.get_and_clear_pending_events();
|
||||
let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::util::events::Event::native_into(item) }); };
|
||||
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::util::events::Event::native_into(item) }); };
|
||||
local_ret.into()
|
||||
}
|
||||
|
||||
|
@ -749,7 +857,7 @@ use lightning::util::events::MessageSendEventsProvider as nativeMessageSendEvent
|
|||
#[must_use]
|
||||
extern "C" fn ChannelManager_ChannelMessageHandler_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ {
|
||||
let mut ret = unsafe { &mut *(this_arg as *mut nativeChannelManager) }.get_and_clear_pending_msg_events();
|
||||
let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::util::events::MessageSendEvent::native_into(item) }); };
|
||||
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::util::events::MessageSendEvent::native_into(item) }); };
|
||||
local_ret.into()
|
||||
}
|
||||
|
||||
|
|
|
@ -320,7 +320,7 @@ pub extern "C" fn PeerManager_new(mut message_handler: crate::ln::peer_handler::
|
|||
#[no_mangle]
|
||||
pub extern "C" fn PeerManager_get_peer_node_ids(this_arg: &PeerManager) -> crate::c_types::derived::CVec_PublicKeyZ {
|
||||
let mut ret = unsafe { &*this_arg.inner }.get_peer_node_ids();
|
||||
let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::c_types::PublicKey::from_rust(&item) }); };
|
||||
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::PublicKey::from_rust(&item) }); };
|
||||
local_ret.into()
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ pub extern "C" fn PeerManager_get_peer_node_ids(this_arg: &PeerManager) -> crate
|
|||
#[no_mangle]
|
||||
pub extern "C" fn PeerManager_new_outbound_connection(this_arg: &PeerManager, mut their_node_id: crate::c_types::PublicKey, mut descriptor: crate::ln::peer_handler::SocketDescriptor) -> crate::c_types::derived::CResult_CVec_u8ZPeerHandleErrorZ {
|
||||
let mut ret = unsafe { &*this_arg.inner }.new_outbound_connection(their_node_id.into_rust(), descriptor);
|
||||
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for item in o.drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::peer_handler::PeerHandleError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
|
||||
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::peer_handler::PeerHandleError { inner: Box::into_raw(Box::new(e)), is_owned: true } }).into() };
|
||||
local_ret
|
||||
}
|
||||
|
||||
|
|
|
@ -224,14 +224,14 @@ extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_channel_update(thi
|
|||
#[must_use]
|
||||
extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_get_next_channel_announcements(this_arg: *const c_void, mut starting_point: u64, mut batch_amount: u8) -> crate::c_types::derived::CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
|
||||
let mut ret = unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.get_next_channel_announcements(starting_point, batch_amount);
|
||||
let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_1 = crate::ln::msgs::ChannelUpdate { inner: if orig_ret_0_1.is_none() { std::ptr::null_mut() } else { { Box::into_raw(Box::new((orig_ret_0_1.unwrap()))) } }, is_owned: true }; let mut local_orig_ret_0_2 = crate::ln::msgs::ChannelUpdate { inner: if orig_ret_0_2.is_none() { std::ptr::null_mut() } else { { Box::into_raw(Box::new((orig_ret_0_2.unwrap()))) } }, is_owned: true }; let mut local_ret_0 = (crate::ln::msgs::ChannelAnnouncement { inner: Box::into_raw(Box::new(orig_ret_0_0)), is_owned: true }, local_orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }); };
|
||||
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_1 = crate::ln::msgs::ChannelUpdate { inner: if orig_ret_0_1.is_none() { std::ptr::null_mut() } else { { Box::into_raw(Box::new((orig_ret_0_1.unwrap()))) } }, is_owned: true }; let mut local_orig_ret_0_2 = crate::ln::msgs::ChannelUpdate { inner: if orig_ret_0_2.is_none() { std::ptr::null_mut() } else { { Box::into_raw(Box::new((orig_ret_0_2.unwrap()))) } }, is_owned: true }; let mut local_ret_0 = (crate::ln::msgs::ChannelAnnouncement { inner: Box::into_raw(Box::new(orig_ret_0_0)), is_owned: true }, local_orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }); };
|
||||
local_ret.into()
|
||||
}
|
||||
#[must_use]
|
||||
extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_get_next_node_announcements(this_arg: *const c_void, mut starting_point: crate::c_types::PublicKey, mut batch_amount: u8) -> crate::c_types::derived::CVec_NodeAnnouncementZ {
|
||||
let mut local_starting_point_base = if starting_point.is_null() { None } else { Some( { starting_point.into_rust() }) }; let mut local_starting_point = local_starting_point_base.as_ref();
|
||||
let mut ret = unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.get_next_node_announcements(local_starting_point, batch_amount);
|
||||
let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
|
||||
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::ln::msgs::NodeAnnouncement { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
|
||||
local_ret.into()
|
||||
}
|
||||
extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_sync_routing_table(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init_msg: &crate::ln::msgs::Init) {
|
||||
|
@ -265,7 +265,7 @@ use lightning::util::events::MessageSendEventsProvider as nativeMessageSendEvent
|
|||
#[must_use]
|
||||
extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ {
|
||||
let mut ret = unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.get_and_clear_pending_msg_events();
|
||||
let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::util::events::MessageSendEvent::native_into(item) }); };
|
||||
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::util::events::MessageSendEvent::native_into(item) }); };
|
||||
local_ret.into()
|
||||
}
|
||||
|
||||
|
@ -291,7 +291,7 @@ use lightning::util::events::MessageSendEventsProvider as MessageSendEventsProvi
|
|||
#[must_use]
|
||||
extern "C" fn NetGraphMsgHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ {
|
||||
let mut ret = unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.get_and_clear_pending_msg_events();
|
||||
let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::util::events::MessageSendEvent::native_into(item) }); };
|
||||
let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::util::events::MessageSendEvent::native_into(item) }); };
|
||||
local_ret.into()
|
||||
}
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ impl Event {
|
|||
},
|
||||
nativeEvent::SpendableOutputs {ref outputs, } => {
|
||||
let mut outputs_nonref = (*outputs).clone();
|
||||
let mut local_outputs_nonref = Vec::new(); for item in outputs_nonref.drain(..) { local_outputs_nonref.push( { crate::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); };
|
||||
let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.drain(..) { local_outputs_nonref.push( { crate::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); };
|
||||
Event::SpendableOutputs {
|
||||
outputs: local_outputs_nonref.into(),
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ impl Event {
|
|||
}
|
||||
},
|
||||
nativeEvent::SpendableOutputs {mut outputs, } => {
|
||||
let mut local_outputs = Vec::new(); for item in outputs.drain(..) { local_outputs.push( { crate::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); };
|
||||
let mut local_outputs = Vec::new(); for mut item in outputs.drain(..) { local_outputs.push( { crate::chain::keysinterface::SpendableOutputDescriptor::native_into(item) }); };
|
||||
Event::SpendableOutputs {
|
||||
outputs: local_outputs.into(),
|
||||
}
|
||||
|
|
|
@ -884,7 +884,7 @@ impl KeysManager {
|
|||
///
|
||||
/// May panic if the `SpendableOutputDescriptor`s were not generated by Channels which used
|
||||
/// this KeysManager or one of the `InMemoryChannelKeys` created by this KeysManager.
|
||||
pub fn spend_spendable_outputs<C: Signing>(&self, descriptors: &[SpendableOutputDescriptor], outputs: Vec<TxOut>, change_destination_script: Script, feerate_sat_per_1000_weight: u32, secp_ctx: &Secp256k1<C>) -> Result<Transaction, ()> {
|
||||
pub fn spend_spendable_outputs<C: Signing>(&self, descriptors: &[&SpendableOutputDescriptor], outputs: Vec<TxOut>, change_destination_script: Script, feerate_sat_per_1000_weight: u32, secp_ctx: &Secp256k1<C>) -> Result<Transaction, ()> {
|
||||
let mut input = Vec::new();
|
||||
let mut input_value = 0;
|
||||
let mut witness_weight = 0;
|
||||
|
|
|
@ -4694,16 +4694,15 @@ macro_rules! check_spendable_outputs {
|
|||
match event {
|
||||
Event::SpendableOutputs { mut outputs } => {
|
||||
for outp in outputs.drain(..) {
|
||||
let mut outputs = vec![outp];
|
||||
txn.push($keysinterface.backing.spend_spendable_outputs(&outputs, Vec::new(), Builder::new().push_opcode(opcodes::all::OP_RETURN).into_script(), 253, &secp_ctx).unwrap());
|
||||
all_outputs.push(outputs.pop().unwrap());
|
||||
txn.push($keysinterface.backing.spend_spendable_outputs(&[&outp], Vec::new(), Builder::new().push_opcode(opcodes::all::OP_RETURN).into_script(), 253, &secp_ctx).unwrap());
|
||||
all_outputs.push(outp);
|
||||
}
|
||||
},
|
||||
_ => panic!("Unexpected event"),
|
||||
};
|
||||
}
|
||||
if all_outputs.len() > 1 {
|
||||
if let Ok(tx) = $keysinterface.backing.spend_spendable_outputs(&all_outputs, Vec::new(), Builder::new().push_opcode(opcodes::all::OP_RETURN).into_script(), 253, &secp_ctx) {
|
||||
if let Ok(tx) = $keysinterface.backing.spend_spendable_outputs(&all_outputs.iter().map(|a| a).collect::<Vec<_>>(), Vec::new(), Builder::new().push_opcode(opcodes::all::OP_RETURN).into_script(), 253, &secp_ctx) {
|
||||
txn.push(tx);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,8 @@ pub enum DecodeError {
|
|||
/// A length descriptor in the packet didn't describe the later data correctly
|
||||
BadLengthDescriptor,
|
||||
/// Error from std::io
|
||||
Io(::std::io::ErrorKind),
|
||||
Io(/// (C-not exported) as ErrorKind doesn't have a reasonable mapping
|
||||
::std::io::ErrorKind),
|
||||
}
|
||||
|
||||
/// An init message to be sent or received from a peer
|
||||
|
|
Loading…
Add table
Reference in a new issue