Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions lightning-background-processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,21 +362,51 @@ type DynMessageRouter = lightning::onion_message::messenger::DefaultMessageRoute
&'static (dyn EntropySource + Send + Sync),
>;

/// Placeholder [`lightning::util::persist::KVStoreSync`] used only to name the `Dyn*` alias types
/// below, which are never instantiated.
#[cfg(not(c_bindings))]
#[doc(hidden)]
pub struct UnusedKvStore;

#[cfg(not(c_bindings))]
impl lightning::util::persist::KVStoreSync for UnusedKvStore {
fn read(
&self, _primary_namespace: &str, _secondary_namespace: &str, _key: &str,
) -> Result<Vec<u8>, lightning::io::Error> {
unreachable!()
}
fn write(
&self, _primary_namespace: &str, _secondary_namespace: &str, _key: &str, _buf: Vec<u8>,
) -> Result<(), lightning::io::Error> {
unreachable!()
}
fn remove(
&self, _primary_namespace: &str, _secondary_namespace: &str, _key: &str, _lazy: bool,
) -> Result<(), lightning::io::Error> {
unreachable!()
}
fn list(
&self, _primary_namespace: &str, _secondary_namespace: &str,
) -> Result<Vec<String>, lightning::io::Error> {
unreachable!()
}
}

#[cfg(all(not(c_bindings), not(taproot)))]
type DynSignerProvider = dyn lightning::sign::SignerProvider<EcdsaSigner = lightning::sign::InMemorySigner>
type DynSignerProvider = dyn lightning::sign::SignerProvider<EcdsaSigner = lightning::sign::InMemorySigner<UnusedKvStore>>
+ Send
+ Sync;

#[cfg(all(not(c_bindings), taproot))]
type DynSignerProvider = (dyn lightning::sign::SignerProvider<
EcdsaSigner = lightning::sign::InMemorySigner,
TaprootSigner = lightning::sign::InMemorySigner,
EcdsaSigner = lightning::sign::InMemorySigner<UnusedKvStore>,
TaprootSigner = lightning::sign::InMemorySigner<UnusedKvStore>,
> + Send
+ Sync);

#[cfg(not(c_bindings))]
type DynChannelManager = lightning::ln::channelmanager::ChannelManager<
&'static (dyn chain::Watch<lightning::sign::InMemorySigner> + Send + Sync),
&'static (dyn chain::Watch<lightning::sign::InMemorySigner<UnusedKvStore>> + Send + Sync),
&'static (dyn BroadcasterInterface + Send + Sync),
&'static (dyn EntropySource + Send + Sync),
&'static (dyn lightning::sign::NodeSigner + Send + Sync),
Expand All @@ -385,6 +415,7 @@ type DynChannelManager = lightning::ln::channelmanager::ChannelManager<
&'static DynRouter,
&'static DynMessageRouter,
&'static (dyn Logger + Send + Sync),
UnusedKvStore,
>;

/// When initializing a background processor without an onion messenger, this can be used to avoid
Expand Down
2 changes: 1 addition & 1 deletion lightning/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ libm = { version = "0.2", default-features = false }
inventory = { version = "0.3", optional = true }

# RGB and related
bincode = "1.3"
futures = "0.3"
rgb-lib = { version = "0.3.0-beta.6", features = [
"electrum",
Expand All @@ -60,7 +61,6 @@ rgb-lib = { version = "0.3.0-beta.6", features = [
serde = { version = "^1.0", features = [
"derive",
] }
serde_json = "^1.0"
tokio = { version = "1.14.1", features = [
"macros",
"rt-multi-thread",
Expand Down
6 changes: 4 additions & 2 deletions lightning/src/ln/chan_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use crate::ln::msgs::DecodeError;
use crate::rgb_utils::{color_htlc, is_tx_colored};
use crate::sign::EntropySource;
use crate::types::payment::{PaymentHash, PaymentPreimage};
use crate::util::persist::KVStoreSync;
use crate::util::ser::{Readable, ReadableArgs, RequiredWrapper, Writeable, Writer};
use crate::util::transaction_utils;

Expand Down Expand Up @@ -2153,9 +2154,10 @@ impl<'a> TrustedCommitmentTransaction<'a> {
///
/// This function is only valid in the holder commitment context, it always uses EcdsaSighashType::All.
#[rustfmt::skip]
pub fn get_htlc_sigs<T: secp256k1::Signing, ES: Deref>(
pub fn get_htlc_sigs<T: secp256k1::Signing, ES: Deref, K: KVStoreSync + ?Sized>(
&self, htlc_base_key: &SecretKey, channel_parameters: &DirectedChannelTransactionParameters,
entropy_source: &ES, secp_ctx: &Secp256k1<T>, ldk_data_dir: &PathBuf,
rgb_kv_store: &K,
) -> Result<Vec<Signature>, ()> where ES::Target: EntropySource {
let inner = self.inner;
let keys = &inner.keys;
Expand All @@ -2167,7 +2169,7 @@ impl<'a> TrustedCommitmentTransaction<'a> {
assert!(this_htlc.transaction_output_index.is_some());
let mut htlc_tx = build_htlc_transaction(&txid, inner.feerate_per_kw, channel_parameters.contest_delay(), &this_htlc, &self.channel_type_features, &keys.broadcaster_delayed_payment_key, &keys.revocation_key);
if inner.is_colored() {
if let Err(_e) = color_htlc(&mut htlc_tx, this_htlc, ldk_data_dir) {
if let Err(_e) = color_htlc(&mut htlc_tx, this_htlc, ldk_data_dir, rgb_kv_store) {
return Err(());
}
}
Expand Down
Loading
Loading