Skip to content
Merged
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
17 changes: 0 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,6 @@ jobs:
shell: bash # Default on Winblows is powershell
run: cargo check --workspace --verbose --color always

wasm:
runs-on: ubuntu-latest
env:
TOOLCHAIN: stable
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Install Rust ${{ env.TOOLCHAIN }} toolchain
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
- name: Install wasm32 target
run: rustup target add wasm32-unknown-unknown
- name: Build lightning for wasm32 (rgb-wasm backend)
run: cargo check -p lightning --target wasm32-unknown-unknown --no-default-features --features std,grind_signatures,rgb-wasm --verbose --color always
- name: Build lightning-transaction-sync for wasm32 (rgb-wasm backend)
run: cargo check --manifest-path lightning-transaction-sync/Cargo.toml --target wasm32-unknown-unknown --no-default-features --features time,esplora-async,rgb-wasm --verbose --color always

linting:
runs-on: ubuntu-latest
env:
Expand Down
2 changes: 1 addition & 1 deletion lightning-background-processor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ std = ["lightning/std", "lightning-liquidity/std", "bitcoin-io/std", "bitcoin_ha
bitcoin = { version = "0.32.2", default-features = false }
bitcoin_hashes = { version = "0.14.0", default-features = false }
bitcoin-io = { version = "0.1.2", default-features = false }
lightning = { version = "0.2.0", path = "../lightning", default-features = false, features = ["rgb-native"] }
lightning = { version = "0.2.0", path = "../lightning", default-features = false }
lightning-rapid-gossip-sync = { version = "0.2.0", path = "../lightning-rapid-gossip-sync", default-features = false }
lightning-liquidity = { version = "0.2.0", path = "../lightning-liquidity", default-features = false }
possiblyrandom = { version = "0.2", path = "../possiblyrandom", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion lightning-dns-resolver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "A crate which implements DNSSEC resolution for lightning clients
edition = "2021"

[dependencies]
lightning = { version = "0.2.0", path = "../lightning", default-features = false, features = ["rgb-native"] }
lightning = { version = "0.2.0", path = "../lightning", default-features = false }
lightning-types = { version = "0.3.0", path = "../lightning-types", default-features = false }
dnssec-prover = { version = "0.6", default-features = false, features = [ "std", "tokio" ] }
tokio = { version = "1.0", default-features = false, features = ["rt"] }
Expand Down
9 changes: 5 additions & 4 deletions lightning-invoice/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ rustdoc-args = ["--cfg", "docsrs"]
[features]
std = []

default = []

[dependencies]
bech32 = { version = "0.11.0", default-features = false }
lightning-types = { version = "0.3.0", path = "../lightning-types", default-features = false }
serde = { version = "1.0", optional = true, default-features = false, features = ["alloc"] }
bitcoin = { version = "0.32.2", default-features = false, features = ["secp-recovery"] }

# RGB protocol types
rgb-ops = { version = "=0.11.1-rc.10", default-features = false }
# RGB and related
rgb-lib = { git = "https://github.com/UTEXO-Protocol/rgb-lib.git", tag = "v0.3.0-beta.24", features = [
"electrum",
"esplora",
] }

[dev-dependencies]
serde_json = { version = "1"}
Expand Down
2 changes: 1 addition & 1 deletion lightning-invoice/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use lightning_types::routing::{RouteHint, RouteHintHop, RoutingFees};
use bitcoin::secp256k1::ecdsa::{RecoverableSignature, RecoveryId};
use bitcoin::secp256k1::PublicKey;

use crate::ContractId;
use rgb_lib::ContractId;

use super::{
constants, Bolt11Invoice, Bolt11InvoiceFeatures, Bolt11InvoiceSignature, Bolt11ParseError,
Expand Down
4 changes: 2 additions & 2 deletions lightning-invoice/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use bitcoin::secp256k1::ecdsa::RecoverableSignature;
use bitcoin::secp256k1::PublicKey;
use bitcoin::secp256k1::{Message, Secp256k1};

pub use rgbstd::ContractId;
use rgb_lib::ContractId;

use alloc::boxed::Box;
use alloc::string;
Expand Down Expand Up @@ -1682,7 +1682,7 @@ impl Bolt11Invoice {

/// Returns the invoice's `rgb_contract_id` if present
pub fn rgb_contract_id(&self) -> Option<ContractId> {
self.signed_invoice.rgb_contract_id().map(|x| x.0.clone())
self.signed_invoice.rgb_contract_id().map(|x| x.0)
}
}

Expand Down
4 changes: 2 additions & 2 deletions lightning-liquidity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ backtrace = ["dep:backtrace"]
_test_utils = []

[dependencies]
lightning = { version = "0.2.0", path = "../lightning", default-features = false, features = ["rgb-native"] }
lightning = { version = "0.2.0", path = "../lightning", default-features = false }
lightning-types = { version = "0.3.0", path = "../lightning-types", default-features = false }
lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default-features = false, features = ["serde"] }
lightning-macros = { version = "0.2.0", path = "../lightning-macros" }
Expand All @@ -34,7 +34,7 @@ serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
backtrace = { version = "0.3", optional = true }

[dev-dependencies]
lightning = { version = "0.2.0", path = "../lightning", default-features = false, features = ["_test_utils", "rgb-native"] }
lightning = { version = "0.2.0", path = "../lightning", default-features = false, features = ["_test_utils"] }
lightning-invoice = { version = "0.34.0", path = "../lightning-invoice", default-features = false, features = ["serde", "std"] }
lightning-persister = { version = "0.2.0", path = "../lightning-persister", default-features = false }

Expand Down
2 changes: 1 addition & 1 deletion lightning-rapid-gossip-sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ default = ["std"]
std = ["bitcoin-io/std", "bitcoin_hashes/std"]

[dependencies]
lightning = { version = "0.2.0", path = "../lightning", default-features = false, features = ["rgb-native"] }
lightning = { version = "0.2.0", path = "../lightning", default-features = false }
bitcoin = { version = "0.32.2", default-features = false }
bitcoin_hashes = { version = "0.14.0", default-features = false }
bitcoin-io = { version = "0.1.2", default-features = false }
Expand Down
9 changes: 3 additions & 6 deletions lightning-transaction-sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[features]
default = ["time", "rgb-native"]
time = ["dep:web-time"]
rgb-native = ["lightning/rgb-native"]
rgb-wasm = ["lightning/rgb-wasm"]
default = ["time"]
time = []
esplora-async = ["async-interface", "esplora-client/async", "esplora-client/tokio", "futures"]
esplora-async-https = ["esplora-async", "esplora-client/async-https-rustls"]
esplora-blocking = ["esplora-client/blocking"]
Expand All @@ -40,10 +38,9 @@ bitcoin = { version = "0.32.2", default-features = false }
futures = { version = "0.3", optional = true }
esplora-client = { version = "0.12", default-features = false, optional = true }
electrum-client = { version = "0.24.0", optional = true, default-features = false, features = ["proxy"] }
web-time = { version = "1.1", optional = true }

[dev-dependencies]
lightning = { version = "0.2.0", path = "../lightning", default-features = false, features = ["std", "_test_utils", "rgb-native"] }
lightning = { version = "0.2.0", path = "../lightning", default-features = false, features = ["std", "_test_utils"] }
tokio = { version = "1.35.0", features = ["macros"] }

[target.'cfg(not(target_os = "windows"))'.dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion lightning-transaction-sync/src/electrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use bitcoin::{BlockHash, Script, Transaction, Txid};
use std::collections::HashSet;
use std::ops::Deref;
use std::sync::{Arc, Mutex};
use web_time::Instant;
use std::time::Instant;

/// Synchronizes LDK with a given Electrum server.
///
Expand Down
2 changes: 1 addition & 1 deletion lightning-transaction-sync/src/esplora.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ where

log_trace!(self.logger, "Starting transaction sync.");
#[cfg(feature = "time")]
let start_time = web_time::Instant::now();
let start_time = std::time::Instant::now();
let mut num_confirmed = 0;
let mut num_unconfirmed = 0;

Expand Down
23 changes: 11 additions & 12 deletions lightning/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@ _externalize_tests = ["inventory", "_test_utils"]
# This is unsafe to use in production because it may result in the counterparty publishing taking our funds.
unsafe_revoked_tx_signing = []

std = ["dep:web-time"]
std = []

dnssec = ["dnssec-prover/validation"]

# Generates low-r bitcoin signatures, which saves 1 byte in 50% of the cases
grind_signatures = []

rgb-native = ["dep:rgb-lib", "dep:tokio"]
rgb-wasm = ["std", "dep:rgb-lib-wasm"]

default = ["std", "grind_signatures", "rgb-native"]
default = ["std", "grind_signatures"]

[dependencies]
lightning-types = { version = "0.3.0", path = "../lightning-types", default-features = false }
Expand All @@ -56,16 +53,18 @@ inventory = { version = "0.3", optional = true }

# RGB and related
bincode = "1.3"
rgb-invoicing = { version = "=0.11.1-rc.10", default-features = false, features = ["serde"] }
rgb-lib = { git = "https://github.com/UTEXO-Protocol/rgb-lib.git", tag = "v0.3.0-beta.24", optional = true, features = [
futures = "0.3"
rgb-lib = { git = "https://github.com/UTEXO-Protocol/rgb-lib.git", tag = "v0.3.0-beta.24", features = [
"electrum",
"esplora",
] }
rgb-lib-wasm = { git = "https://github.com/UTEXO-Protocol/rgb-lib-wasm.git", branch = "dev", optional = true }
serde = { version = "^1.0", features = ["derive"] }
serde_json = "1.0"
tokio = { version = "1.14.1", optional = true, features = ["macros", "rt-multi-thread"] }
web-time = { version = "1.1", optional = true }
serde = { version = "^1.0", features = [
"derive",
] }
tokio = { version = "1.14.1", features = [
"macros",
"rt-multi-thread",
] }

[dev-dependencies]
regex = "1.5.6"
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/chain/channelmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use bitcoin::hashes::Hash;
use bitcoin::ecdsa::Signature as BitcoinSignature;
use bitcoin::secp256k1::{self, ecdsa::Signature, PublicKey, Secp256k1, SecretKey};

use crate::rgb_utils::ContractId;
use rgb_lib::ContractId;

use crate::chain;
use crate::chain::chaininterface::{
Expand Down
44 changes: 1 addition & 43 deletions lightning/src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

pub mod bump_transaction;

use crate::rgb_utils::ContractId;
use rgb_lib::ContractId;

pub use bump_transaction::BumpTransactionEvent;

Expand All @@ -34,7 +34,6 @@ use crate::offers::invoice::Bolt12Invoice;
use crate::offers::invoice_request::InvoiceRequest;
use crate::offers::static_invoice::StaticInvoice;
use crate::onion_message::messenger::Responder;
use crate::rgb_utils::RgbTransport;
use crate::routing::gossip::NetworkUpdate;
use crate::routing::router::{BlindedTail, Path, RouteHop, RouteParameters};
use crate::sign::SpendableOutputDescriptor;
Expand Down Expand Up @@ -786,35 +785,6 @@ pub enum Event {
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
user_channel_id: u128,
},
/// Requests asynchronous validation of an incoming RGB funding transfer.
///
/// Call [`ChannelManager::process_pending_rgb_funding_validation`] to validate the transfer
/// using the injected production RGB backend and finish processing `funding_created`, or call
/// [`ChannelManager::reject_pending_rgb_funding_validation`] to reject the pending channel.
///
/// [`ChannelManager::process_pending_rgb_funding_validation`]: crate::ln::channelmanager::ChannelManager::process_pending_rgb_funding_validation
/// [`ChannelManager::reject_pending_rgb_funding_validation`]: crate::ln::channelmanager::ChannelManager::reject_pending_rgb_funding_validation
RgbFundingValidationRequired {
/// Temporary channel ID awaiting RGB funding validation.
temporary_channel_id: ChannelId,
/// Node that sent the funding message.
counterparty_node_id: PublicKey,
/// Funding transaction ID used to retrieve the consignment.
funding_txid: bitcoin::Txid,
/// Funding output index whose RGB assignment must be validated.
funding_output_index: u16,
/// Endpoint from which the RGB consignment must be retrieved.
consignment_endpoint: RgbTransport,
},
/// Indicates that prepared RGB transactions are waiting for durable fascia consumption.
///
/// Call [`ChannelManager::process_pending_rgb_transactions`] before expecting blocked
/// commitment, HTLC, funding, or cooperative-close signatures and messages to resume.
///
/// This event is regenerated from the persisted RGB KVStore records after reload.
///
/// [`ChannelManager::process_pending_rgb_transactions`]: crate::ln::channelmanager::ChannelManager::process_pending_rgb_transactions
RgbTransactionPersistenceRequired,
/// Used to indicate that the counterparty node has provided the signature(s) required to
/// recover our funds in case they go offline.
///
Expand Down Expand Up @@ -1933,14 +1903,6 @@ impl Writeable for Event {
// We never write out FundingGenerationReady events as, upon disconnection, peers
// drop any channels which have not yet exchanged funding_signed.
},
&Event::RgbFundingValidationRequired { .. } => {
55u8.write(writer)?;
// Regenerated from ChannelManager's persisted pending validation records.
},
&Event::RgbTransactionPersistenceRequired => {
57u8.write(writer)?;
// Regenerated from persisted pending fascia records.
},
&Event::PaymentClaimable {
ref payment_hash,
ref amount_msat,
Expand Down Expand Up @@ -2442,10 +2404,6 @@ impl MaybeReadable for Event {
match Readable::read(reader)? {
// Note that we do not write a length-prefixed TLV for FundingGenerationReady events.
0u8 => Ok(None),
// Regenerated from ChannelManager's persisted pending validation records.
55u8 => Ok(None),
// Regenerated from the RGB KVStore's pending fascia records.
57u8 => Ok(None),
1u8 => {
let mut f = || {
let mut payment_hash = PaymentHash([0; 32]);
Expand Down
12 changes: 0 additions & 12 deletions lightning/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@
//! * `std` - enables functionalities which require `std`, including `std::io` trait implementations and things which utilize time
//! * `grind_signatures` - enables generation of [low-r bitcoin signatures](https://bitcoin.stackexchange.com/questions/111660/what-is-signature-grinding),
//! which saves 1 byte per signature in 50% of the cases (see [bitcoin PR #13666](https://github.com/bitcoin/bitcoin/pull/13666))
//! * `rgb-native` - selects the native production RGB wallet backend
//!
//! Available features are:
//!
//! * `std`
//! * `grind_signatures`
//! * `rgb-native`
//! * `rgb-wasm` - selects the browser WebAssembly production RGB wallet backend

#![cfg_attr(not(any(test, fuzzing, feature = "_test_utils")), deny(missing_docs))]
#![deny(rustdoc::broken_intra_doc_links)]
Expand All @@ -46,15 +43,6 @@
#[cfg(all(fuzzing, test))]
compile_error!("Tests will always fail with cfg=fuzzing");

#[cfg(all(feature = "rgb-native", feature = "rgb-wasm"))]
compile_error!("`rgb-native` and `rgb-wasm` are mutually exclusive production RGB backends");

#[cfg(not(any(feature = "rgb-native", feature = "rgb-wasm")))]
compile_error!("exactly one production RGB backend must be enabled: `rgb-native` or `rgb-wasm`");

#[cfg(all(feature = "rgb-wasm", not(target_arch = "wasm32")))]
compile_error!("the `rgb-wasm` production backend requires a wasm32 target");

#[macro_use]
extern crate alloc;

Expand Down
12 changes: 5 additions & 7 deletions lightning/src/ln/chan_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//! largely of interest for those implementing the traits on [`crate::sign`] by hand.

use std::collections::HashMap;
use std::path::PathBuf;

use bitcoin::amount::Amount;
use bitcoin::constants::WITNESS_SCALE_FACTOR;
Expand All @@ -33,7 +34,7 @@ use crate::chain::chaininterface::{
};
use crate::chain::package::WEIGHT_REVOKED_OUTPUT;
use crate::ln::msgs::DecodeError;
use crate::rgb_utils::{color_htlc, is_tx_colored, RgbBackend};
use crate::rgb_utils::{color_htlc, is_tx_colored};
use crate::sign::EntropySource;
use crate::types::payment::{PaymentHash, PaymentPreimage};
use crate::util::persist::KVStoreSync;
Expand All @@ -46,7 +47,7 @@ use bitcoin::secp256k1::{ecdsa::Signature, Message, Secp256k1};
use bitcoin::secp256k1::{PublicKey, Scalar, SecretKey};
use bitcoin::{secp256k1, Sequence, Witness};

use crate::rgb_utils::ContractId;
use rgb_lib::ContractId;

use super::channel_keys::{
DelayedPaymentBasepoint, DelayedPaymentKey, HtlcBasepoint, HtlcKey, RevocationBasepoint,
Expand Down Expand Up @@ -2246,7 +2247,7 @@ impl<'a> TrustedCommitmentTransaction<'a> {
#[rustfmt::skip]
pub fn get_htlc_sigs<T: secp256k1::Signing, ES: Deref>(
&self, htlc_base_key: &SecretKey, channel_parameters: &DirectedChannelTransactionParameters,
entropy_source: &ES, secp_ctx: &Secp256k1<T>, rgb_backend: &RgbBackend,
entropy_source: &ES, secp_ctx: &Secp256k1<T>, ldk_data_dir: &PathBuf,
rgb_kv_store: &dyn KVStoreSync,
) -> Result<Vec<Signature>, ()> where ES::Target: EntropySource {
let inner = self.inner;
Expand All @@ -2259,10 +2260,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, rgb_backend, rgb_kv_store) {
return Err(());
}
if !rgb_backend.is_transaction_durable(&htlc_tx.compute_txid(), rgb_kv_store) {
if let Err(_e) = color_htlc(&mut htlc_tx, this_htlc, ldk_data_dir, rgb_kv_store) {
return Err(());
}
}
Expand Down
Loading
Loading