Skip to content

Commit

Permalink
Update to main, up to Nov 27, 146a291
Browse files Browse the repository at this point in the history
  • Loading branch information
optout21 committed Jan 8, 2024
2 parents dfe53d7 + 146a291 commit d7d2f98
Show file tree
Hide file tree
Showing 33 changed files with 1,283 additions and 473 deletions.
2 changes: 2 additions & 0 deletions ci/ci-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ if [[ $RUSTC_MINOR_VERSION -gt 67 && "$HOST_PLATFORM" != *windows* ]]; then
cargo check --verbose --color always --features esplora-async
cargo test --verbose --color always --features esplora-async-https
cargo check --verbose --color always --features esplora-async-https
cargo test --verbose --color always --features electrum
cargo check --verbose --color always --features electrum
popd
fi

Expand Down
2 changes: 1 addition & 1 deletion fuzz/src/chanmon_consistency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl SignerProvider for KeyProvider {
})
}

fn get_destination_script(&self) -> Result<ScriptBuf, ()> {
fn get_destination_script(&self, _channel_keys_id: [u8; 32]) -> Result<ScriptBuf, ()> {
let secp_ctx = Secp256k1::signing_only();
let channel_monitor_claim_key = SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, self.node_secret[31]]).unwrap();
let our_channel_monitor_claim_key_hash = WPubkeyHash::hash(&PublicKey::from_secret_key(&secp_ctx, &channel_monitor_claim_key).serialize());
Expand Down
2 changes: 1 addition & 1 deletion fuzz/src/full_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ impl SignerProvider for KeyProvider {
))
}

fn get_destination_script(&self) -> Result<ScriptBuf, ()> {
fn get_destination_script(&self, _channel_keys_id: [u8; 32]) -> Result<ScriptBuf, ()> {
let secp_ctx = Secp256k1::signing_only();
let channel_monitor_claim_key = SecretKey::from_slice(&<Vec<u8>>::from_hex("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap();
let our_channel_monitor_claim_key_hash = WPubkeyHash::hash(&PublicKey::from_secret_key(&secp_ctx, &channel_monitor_claim_key).serialize());
Expand Down
2 changes: 1 addition & 1 deletion fuzz/src/onion_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl SignerProvider for KeyProvider {

fn read_chan_signer(&self, _data: &[u8]) -> Result<TestChannelSigner, DecodeError> { unreachable!() }

fn get_destination_script(&self) -> Result<ScriptBuf, ()> { unreachable!() }
fn get_destination_script(&self, _channel_keys_id: [u8; 32]) -> Result<ScriptBuf, ()> { unreachable!() }

fn get_shutdown_scriptpubkey(&self) -> Result<ShutdownScript, ()> { unreachable!() }
}
Expand Down
5 changes: 4 additions & 1 deletion lightning-invoice/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,10 @@ impl From<Network> for Currency {
Network::Testnet => Currency::BitcoinTestnet,
Network::Regtest => Currency::Regtest,
Network::Signet => Currency::Signet,
_ => unreachable!(),
_ => {
debug_assert!(false, "Need to handle new rust-bitcoin network type");
Currency::Regtest
},
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions lightning-transaction-sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ rustdoc-args = ["--cfg", "docsrs"]
[features]
default = []
esplora-async = ["async-interface", "esplora-client/async", "futures"]
esplora-async-https = ["esplora-async", "reqwest/rustls-tls"]
esplora-async-https = ["esplora-async", "esplora-client/async-https-rustls"]
esplora-blocking = ["esplora-client/blocking"]
electrum = ["electrum-client"]
async-interface = []

[dependencies]
Expand All @@ -26,10 +27,9 @@ bitcoin = { version = "0.30.2", default-features = false }
bdk-macros = "0.6"
futures = { version = "0.3", optional = true }
esplora-client = { version = "0.6", default-features = false, optional = true }
reqwest = { version = "0.11", optional = true, default-features = false, features = ["json"] }
electrum-client = { version = "0.18.0", optional = true }

[dev-dependencies]
lightning = { version = "0.0.118", path = "../lightning", features = ["std"] }
lightning = { version = "0.0.118", path = "../lightning", features = ["std", "_test_utils"] }
electrsd = { version = "0.26.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_25_0"] }
electrum-client = "0.18.0"
tokio = { version = "1.14.0", features = ["full"] }
38 changes: 36 additions & 2 deletions lightning-transaction-sync/src/common.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use lightning::chain::WatchedOutput;
use lightning::chain::{Confirm, WatchedOutput};
use bitcoin::{Txid, BlockHash, Transaction, OutPoint};
use bitcoin::blockdata::block::Header;
use bitcoin::block::Header;

use std::collections::{HashSet, HashMap};

Expand Down Expand Up @@ -28,6 +28,39 @@ impl SyncState {
pending_sync: false,
}
}
pub fn sync_unconfirmed_transactions(
&mut self, confirmables: &Vec<&(dyn Confirm + Sync + Send)>,
unconfirmed_txs: Vec<Txid>,
) {
for txid in unconfirmed_txs {
for c in confirmables {
c.transaction_unconfirmed(&txid);
}

self.watched_transactions.insert(txid);
}
}

pub fn sync_confirmed_transactions(
&mut self, confirmables: &Vec<&(dyn Confirm + Sync + Send)>,
confirmed_txs: Vec<ConfirmedTx>
) {
for ctx in confirmed_txs {
for c in confirmables {
c.transactions_confirmed(
&ctx.block_header,
&[(ctx.pos, &ctx.tx)],
ctx.block_height,
);
}

self.watched_transactions.remove(&ctx.tx.txid());

for input in &ctx.tx.input {
self.watched_outputs.remove(&input.previous_output);
}
}
}
}


Expand Down Expand Up @@ -68,6 +101,7 @@ impl FilterQueue {
}
}

#[derive(Debug)]
pub(crate) struct ConfirmedTx {
pub tx: Transaction,
pub block_header: Header,
Expand Down
Loading

0 comments on commit d7d2f98

Please sign in to comment.