X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Fchain%2Ftransaction.rs;fp=lightning-c-bindings%2Fsrc%2Flightning%2Fchain%2Ftransaction.rs;h=45794a14c39029f880df02418fe94b66582930c2;hb=6658ad877ed253301df2c729b1c6a2a859515777;hp=05667fdab7ef2fa2deeb6f0316c2cc847b391f57;hpb=7e6274489182ebb64202f790e462a9d464d75de2;p=ldk-c-bindings diff --git a/lightning-c-bindings/src/lightning/chain/transaction.rs b/lightning-c-bindings/src/lightning/chain/transaction.rs index 05667fd..45794a1 100644 --- a/lightning-c-bindings/src/lightning/chain/transaction.rs +++ b/lightning-c-bindings/src/lightning/chain/transaction.rs @@ -111,6 +111,25 @@ pub(crate) extern "C" fn OutPoint_clone_void(this_ptr: *const c_void) -> *mut c_ pub extern "C" fn OutPoint_clone(orig: &OutPoint) -> OutPoint { orig.clone() } +/// Checks if two OutPoints contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn OutPoint_eq(a: &OutPoint, b: &OutPoint) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if unsafe { &*a.inner } == unsafe { &*b.inner } { true } else { false } +} +/// Checks if two OutPoints contain equal inner contents. +#[no_mangle] +pub extern "C" fn OutPoint_hash(o: &OutPoint) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + std::hash::Hash::hash(unsafe { &*o.inner }, &mut hasher); + std::hash::Hasher::finish(&hasher) +} /// Convert an `OutPoint` to a lightning channel id. #[must_use] #[no_mangle]