From: Jeffrey Czyz Date: Fri, 2 Apr 2021 23:53:00 +0000 (-0700) Subject: Add an internal typedef for transaction outputs X-Git-Tag: v0.0.14~24^2~4 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=1c72489e52ab30d08befe6e9478aca48fef654fb;p=rust-lightning Add an internal typedef for transaction outputs --- diff --git a/lightning/src/chain/chainmonitor.rs b/lightning/src/chain/chainmonitor.rs index 63e1a7da5..ee6df63a1 100644 --- a/lightning/src/chain/chainmonitor.rs +++ b/lightning/src/chain/chainmonitor.rs @@ -25,13 +25,12 @@ use bitcoin::blockdata::block::{Block, BlockHeader}; use bitcoin::hash_types::Txid; -use bitcoin::blockdata::transaction::TxOut; use chain; use chain::{Filter, WatchedOutput}; use chain::chaininterface::{BroadcasterInterface, FeeEstimator}; use chain::channelmonitor; -use chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpdateErr, MonitorEvent, Persist}; +use chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpdateErr, MonitorEvent, Persist, TransactionOutputs}; use chain::transaction::{OutPoint, TransactionData}; use chain::keysinterface::Sign; use util::logger::Logger; @@ -135,7 +134,7 @@ where C::Target: chain::Filter, fn process_chain_data(&self, header: &BlockHeader, txdata: &TransactionData, process: FN) where - FN: Fn(&ChannelMonitor, &TransactionData) -> Vec<(Txid, Vec<(u32, TxOut)>)> + FN: Fn(&ChannelMonitor, &TransactionData) -> Vec { let mut dependent_txdata = Vec::new(); let monitors = self.monitors.read().unwrap(); diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index cc80de6c0..ed206dcfe 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -745,6 +745,9 @@ pub(crate) struct ChannelMonitorImpl { secp_ctx: Secp256k1, //TODO: dedup this a bit... } +/// Transaction outputs to watch for on-chain spends. +pub(super) type TransactionOutputs = (Txid, Vec<(u32, TxOut)>); + #[cfg(any(test, feature = "fuzztarget", feature = "_test_utils"))] /// Used only in testing and fuzztarget to check serialization roundtrips don't change the /// underlying object @@ -1276,7 +1279,7 @@ impl ChannelMonitor { broadcaster: B, fee_estimator: F, logger: L, - ) -> Vec<(Txid, Vec<(u32, TxOut)>)> + ) -> Vec where B::Target: BroadcasterInterface, F::Target: FeeEstimator, @@ -1321,7 +1324,7 @@ impl ChannelMonitor { broadcaster: B, fee_estimator: F, logger: L, - ) -> Vec<(Txid, Vec<(u32, TxOut)>)> + ) -> Vec where B::Target: BroadcasterInterface, F::Target: FeeEstimator, @@ -1376,7 +1379,7 @@ impl ChannelMonitor { broadcaster: B, fee_estimator: F, logger: L, - ) -> Vec<(Txid, Vec<(u32, TxOut)>)> + ) -> Vec where B::Target: BroadcasterInterface, F::Target: FeeEstimator, @@ -1691,7 +1694,7 @@ impl ChannelMonitorImpl { /// HTLC-Success/HTLC-Timeout transactions. /// Return updates for HTLC pending in the channel and failed automatically by the broadcast of /// revoked counterparty commitment tx - fn check_spend_counterparty_transaction(&mut self, tx: &Transaction, height: u32, logger: &L) -> (Vec, (Txid, Vec<(u32, TxOut)>)) where L::Target: Logger { + fn check_spend_counterparty_transaction(&mut self, tx: &Transaction, height: u32, logger: &L) -> (Vec, TransactionOutputs) where L::Target: Logger { // Most secp and related errors trying to create keys means we have no hope of constructing // a spend transaction...so we return no transactions to broadcast let mut claimable_outpoints = Vec::new(); @@ -1902,7 +1905,7 @@ impl ChannelMonitorImpl { } /// Attempts to claim a counterparty HTLC-Success/HTLC-Timeout's outputs using the revocation key - fn check_spend_counterparty_htlc(&mut self, tx: &Transaction, commitment_number: u64, height: u32, logger: &L) -> (Vec, Option<(Txid, Vec<(u32, TxOut)>)>) where L::Target: Logger { + fn check_spend_counterparty_htlc(&mut self, tx: &Transaction, commitment_number: u64, height: u32, logger: &L) -> (Vec, Option) where L::Target: Logger { let htlc_txid = tx.txid(); if tx.input.len() != 1 || tx.output.len() != 1 || tx.input[0].witness.len() != 5 { return (Vec::new(), None) @@ -1971,7 +1974,7 @@ impl ChannelMonitorImpl { /// Attempts to claim any claimable HTLCs in a commitment transaction which was not (yet) /// revoked using data in holder_claimable_outpoints. /// Should not be used if check_spend_revoked_transaction succeeds. - fn check_spend_holder_transaction(&mut self, tx: &Transaction, height: u32, logger: &L) -> (Vec, (Txid, Vec<(u32, TxOut)>)) where L::Target: Logger { + fn check_spend_holder_transaction(&mut self, tx: &Transaction, height: u32, logger: &L) -> (Vec, TransactionOutputs) where L::Target: Logger { let commitment_txid = tx.txid(); let mut claim_requests = Vec::new(); let mut watch_outputs = Vec::new(); @@ -2094,7 +2097,7 @@ impl ChannelMonitorImpl { return res } - pub fn block_connected(&mut self, header: &BlockHeader, txdata: &TransactionData, height: u32, broadcaster: B, fee_estimator: F, logger: L)-> Vec<(Txid, Vec<(u32, TxOut)>)> + pub fn block_connected(&mut self, header: &BlockHeader, txdata: &TransactionData, height: u32, broadcaster: B, fee_estimator: F, logger: L) -> Vec where B::Target: BroadcasterInterface, F::Target: FeeEstimator, L::Target: Logger, @@ -2113,7 +2116,7 @@ impl ChannelMonitorImpl { broadcaster: B, fee_estimator: F, logger: L, - ) -> Vec<(Txid, Vec<(u32, TxOut)>)> + ) -> Vec where B::Target: BroadcasterInterface, F::Target: FeeEstimator, @@ -2141,7 +2144,7 @@ impl ChannelMonitorImpl { broadcaster: B, fee_estimator: F, logger: L, - ) -> Vec<(Txid, Vec<(u32, TxOut)>)> + ) -> Vec where B::Target: BroadcasterInterface, F::Target: FeeEstimator, @@ -2209,12 +2212,12 @@ impl ChannelMonitorImpl { &mut self, height: u32, txn_matched: Vec<&Transaction>, - mut watch_outputs: Vec<(Txid, Vec<(u32, TxOut)>)>, + mut watch_outputs: Vec, mut claimable_outpoints: Vec, broadcaster: B, fee_estimator: F, logger: L, - ) -> Vec<(Txid, Vec<(u32, TxOut)>)> + ) -> Vec where B::Target: BroadcasterInterface, F::Target: FeeEstimator,