Skip to content

Commit

Permalink
wip: upgrade ldk library version
Browse files Browse the repository at this point in the history
Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo committed Mar 5, 2024
1 parent 9de9841 commit e9624c9
Show file tree
Hide file tree
Showing 17 changed files with 492 additions and 1,076 deletions.
789 changes: 447 additions & 342 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 6 additions & 8 deletions lampo-bitcoind/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,27 @@ use std::thread::JoinHandle;
use std::time::Duration;

use bitcoincore_rpc::bitcoin::hashes::Hash;
use bitcoincore_rpc::bitcoin::ScriptBuf;
use bitcoincore_rpc::bitcoincore_rpc_json::GetTxOutResult;
use bitcoincore_rpc::Client;
use bitcoincore_rpc::RpcApi;

use lampo_common::backend::BlockHash;
use lampo_common::backend::{deserialize, serialize};
use lampo_common::backend::{Backend, TxResult};
use lampo_common::backend::{Block, BlockData};
use lampo_common::bitcoin::locktime::Height;
use lampo_common::backend::{Block, BlockData, BlockHash};
use lampo_common::bitcoin::absolute::Height;
use lampo_common::bitcoin::{Script, Transaction, Txid};
use lampo_common::error;
use lampo_common::event::onchain::OnChainEvent;
use lampo_common::event::Event;
use lampo_common::handler::Handler;
use lampo_common::json;
use lampo_common::secp256k1::hashes::hex::ToHex;

pub struct BitcoinCore {
inner: Client,
handler: RefCell<Option<Arc<dyn Handler>>>,
ours_txs: Mutex<RefCell<Vec<Txid>>>,
others_txs: Mutex<RefCell<Vec<(Txid, Script)>>>,
others_txs: Mutex<RefCell<Vec<(Txid, ScriptBuf)>>>,
// receive notification if the
// deamon was stop
stop: Arc<bool>,
Expand Down Expand Up @@ -86,7 +85,7 @@ impl BitcoinCore {
Ok(tx.script_pub_key.hex)
}

pub fn watch_tx(&self, txid: &Txid, script: &Script) -> error::Result<()> {
pub fn watch_tx(&self, txid: &Txid, script: &ScriptBuf) -> error::Result<()> {
log::debug!(target: "bitcoind", "Looking an external transaction `{}`", txid);
if self
.ours_txs
Expand Down Expand Up @@ -115,7 +114,7 @@ impl BitcoinCore {
log::debug!(target: "bitcoin", "looking the tx inside the new block");
let utxos = self.others_txs.lock().unwrap();
let mut utxos = utxos.borrow_mut();
let mut still_unconfirmed: Vec<(Txid, Script)> = vec![];
let mut still_unconfirmed: Vec<(Txid, ScriptBuf)> = vec![];
for (utxo, script) in utxos.iter() {
log::debug!(target: "bitcoind", "looking for UTXO {} inside the block at height: {}", utxo, self.best_height.borrow());
if let Some((idx, tx)) = block
Expand Down Expand Up @@ -244,7 +243,6 @@ impl Backend for BitcoinCore {
header_hash: &lampo_common::backend::BlockHash,
) -> error::Result<lampo_common::backend::BlockData> {
use bitcoincore_rpc::bitcoin::consensus::serialize as inner_serialize;
use bitcoincore_rpc::bitcoin::BlockHash;

// FIXME: change the version of rust bitcoin in nakamoto and in lampod_common.
let bytes = serialize(header_hash);
Expand Down
17 changes: 8 additions & 9 deletions lampo-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
lightning = { version = "0.0.118", features = ["max_level_trace"] }
lightning-block-sync = { version = "0.0.118" }
lightning-persister = { version = "0.0.118" }
lightning-background-processor = { version = "0.0.118" }
lightning-net-tokio = { version = "0.0.118" }
lightning-rapid-gossip-sync = { version = "0.0.118" }
lightning-invoice = { version = "0.26.0" }

lightning = { git = "https://github.com/vincenzopalazzo/rust-lightning.git", branch = "macros/allow-to-inject-channels-keys", features = ["max_level_trace"] }
lightning-block-sync = { git = "https://github.com/vincenzopalazzo/rust-lightning.git", branch = "macros/allow-to-inject-channels-keys" }
lightning-persister = { git = "https://github.com/vincenzopalazzo/rust-lightning.git", branch = "macros/allow-to-inject-channels-keys" }
lightning-background-processor = { git = "https://github.com/vincenzopalazzo/rust-lightning.git", branch = "macros/allow-to-inject-channels-keys" }
lightning-net-tokio = { git = "https://github.com/vincenzopalazzo/rust-lightning.git", branch = "macros/allow-to-inject-channels-keys" }
lightning-rapid-gossip-sync = { git = "https://github.com/vincenzopalazzo/rust-lightning.git", branch = "macros/allow-to-inject-channels-keys" }
lightning-invoice = { git = "https://github.com/vincenzopalazzo/rust-lightning.git", branch = "macros/allow-to-inject-channels-keys" }
bitcoin = { version = "0.30.2", features = ["serde"] }
clightningrpc-conf = { git = "https://github.com/laanwj/cln4rust.git", branch = "master" }
crossbeam-channel = "0.5.8"
bitcoin = { version = "0.29.0", features = ["serde"] }
anyhow = "1.0.70"
colored = "1.9"
log = { version = "0.4", features = ["std"] }
Expand Down
5 changes: 3 additions & 2 deletions lampo-common/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
use std::sync::Arc;
use std::thread::JoinHandle;

use bitcoin::block::Header as BlockHeader;
use bitcoin::relative::Height;

pub use bitcoin::consensus::{deserialize, serialize};
use bitcoin::locktime::Height;
use bitcoin::BlockHeader;
pub use bitcoin::{Block, BlockHash, Script, Transaction, Txid};
pub use lightning::chain::WatchedOutput;
pub use lightning::routing::utxo::UtxoResult;
Expand Down
10 changes: 5 additions & 5 deletions lampo-common/src/event/onchain.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
//! Event generated by onchain events.
use std::fmt::Debug;

use crate::bitcoin::BlockHeader;
use crate::bitcoin::{locktime::Height, Txid};
use crate::bitcoin::{Block, Transaction};
use crate::bitcoin::absolute::Height;
use crate::bitcoin::block::Header;
use crate::bitcoin::{Block, Transaction, Txid};

#[derive(Clone)]
pub enum OnChainEvent {
NewBlock(Block),
NewBestBlock((BlockHeader, Height)),
NewBestBlock((Header, Height)),
FeeEstimation(u32),
SendRawTransaction(Transaction),
ConfirmedTransaction((Transaction, u32, BlockHeader, Height)),
ConfirmedTransaction((Transaction, u32, Header, Height)),
DiscardedTransaction(Txid),
UnconfirmedTransaction(Txid),
}
Expand Down
Loading

0 comments on commit e9624c9

Please sign in to comment.