Merge pull request #1740 from TheBlueMatt/2022-09-invoice-bindings-nostd
authorvalentinewallace <valentinewallace@users.noreply.github.com>
Mon, 26 Sep 2022 13:22:01 +0000 (09:22 -0400)
committerGitHub <noreply@github.com>
Mon, 26 Sep 2022 13:22:01 +0000 (09:22 -0400)
Don't make references to `std` in `lightning-invoice` in bindings

lightning/src/ln/channelmanager.rs
lightning/src/util/wakers.rs

index 72f1f4d596f80597736ec1bb59e9b27673eddf96..8c12f5470b9ca0fd36f2e5410efeece305c99d71 100644 (file)
@@ -2935,7 +2935,6 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
                        // Transactions are evaluated as final by network mempools at the next block. However, the modules
                        // constituting our Lightning node might not have perfect sync about their blockchain views. Thus, if
                        // the wallet module is in advance on the LDK view, allow one more block of headroom.
-                       // TODO: updated if/when https://github.com/rust-bitcoin/rust-bitcoin/pull/994 landed and rust-bitcoin bumped.
                        if !funding_transaction.input.iter().all(|input| input.sequence == Sequence::MAX) && LockTime::from(funding_transaction.lock_time).is_block_height() && funding_transaction.lock_time.0 > height + 2 {
                                return Err(APIError::APIMisuseError {
                                        err: "Funding transaction absolute timelock is non-final".to_owned()
index e49c832ef67fd8aeb0dd25f193eb3fe179bb57c1..166771948fad62bc2f10078b5360fb67207f50f5 100644 (file)
@@ -163,6 +163,8 @@ pub struct Future {
 impl Future {
        /// Registers a callback to be called upon completion of this future. If the future has already
        /// completed, the callback will be called immediately.
+       ///
+       /// (C-not exported) use the bindings-only `register_callback_fn` instead
        pub fn register_callback(&self, callback: Box<dyn FutureCallback>) {
                let mut state = self.state.lock().unwrap();
                if state.complete {
@@ -172,6 +174,16 @@ impl Future {
                        state.callbacks.push(callback);
                }
        }
+
+       // C bindings don't (currently) know how to map `Box<dyn Trait>`, and while it could add the
+       // following wrapper, doing it in the bindings is currently much more work than simply doing it
+       // here.
+       /// Registers a callback to be called upon completion of this future. If the future has already
+       /// completed, the callback will be called immediately.
+       #[cfg(c_bindings)]
+       pub fn register_callback_fn<F: 'static + FutureCallback>(&self, callback: F) {
+               self.register_callback(Box::new(callback));
+       }
 }
 
 mod std_future {