Add an internal typedef for transaction outputs
[rust-lightning] / lightning / src / chain / chainmonitor.rs
index ecdd6c3f28395d814ebb98f6315810a70038409e..ee6df63a1e07ee272fda9f2217526e15c3d7beca 100644 (file)
 
 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<FN>(&self, header: &BlockHeader, txdata: &TransactionData, process: FN)
        where
-               FN: Fn(&ChannelMonitor<ChannelSigner>, &TransactionData) -> Vec<(Txid, Vec<(u32, TxOut)>)>
+               FN: Fn(&ChannelMonitor<ChannelSigner>, &TransactionData) -> Vec<TransactionOutputs>
        {
                let mut dependent_txdata = Vec::new();
                let monitors = self.monitors.read().unwrap();
@@ -146,15 +145,15 @@ where C::Target: chain::Filter,
                        // transactions from within the block that previously had not been included in txdata.
                        if let Some(ref chain_source) = self.chain_source {
                                let block_hash = header.block_hash();
-                               for (txid, outputs) in txn_outputs.drain(..) {
-                                       for (idx, output) in outputs.iter() {
+                               for (txid, mut outputs) in txn_outputs.drain(..) {
+                                       for (idx, output) in outputs.drain(..) {
                                                // Register any new outputs with the chain source for filtering and recurse
                                                // if it indicates that there are dependent transactions within the block
                                                // that had not been previously included in txdata.
                                                let output = WatchedOutput {
                                                        block_hash: Some(block_hash),
-                                                       outpoint: OutPoint { txid, index: *idx as u16 },
-                                                       script_pubkey: output.script_pubkey.clone(),
+                                                       outpoint: OutPoint { txid, index: idx as u16 },
+                                                       script_pubkey: output.script_pubkey,
                                                };
                                                if let Some(tx) = chain_source.register_output(output) {
                                                        dependent_txdata.push(tx);