Skip to content

Commit 1c72489

Browse files
committed
Add an internal typedef for transaction outputs
1 parent 34792d0 commit 1c72489

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

lightning/src/chain/chainmonitor.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@
2525
2626
use bitcoin::blockdata::block::{Block, BlockHeader};
2727
use bitcoin::hash_types::Txid;
28-
use bitcoin::blockdata::transaction::TxOut;
2928

3029
use chain;
3130
use chain::{Filter, WatchedOutput};
3231
use chain::chaininterface::{BroadcasterInterface, FeeEstimator};
3332
use chain::channelmonitor;
34-
use chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpdateErr, MonitorEvent, Persist};
33+
use chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpdateErr, MonitorEvent, Persist, TransactionOutputs};
3534
use chain::transaction::{OutPoint, TransactionData};
3635
use chain::keysinterface::Sign;
3736
use util::logger::Logger;
@@ -135,7 +134,7 @@ where C::Target: chain::Filter,
135134

136135
fn process_chain_data<FN>(&self, header: &BlockHeader, txdata: &TransactionData, process: FN)
137136
where
138-
FN: Fn(&ChannelMonitor<ChannelSigner>, &TransactionData) -> Vec<(Txid, Vec<(u32, TxOut)>)>
137+
FN: Fn(&ChannelMonitor<ChannelSigner>, &TransactionData) -> Vec<TransactionOutputs>
139138
{
140139
let mut dependent_txdata = Vec::new();
141140
let monitors = self.monitors.read().unwrap();

lightning/src/chain/channelmonitor.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,9 @@ pub(crate) struct ChannelMonitorImpl<Signer: Sign> {
745745
secp_ctx: Secp256k1<secp256k1::All>, //TODO: dedup this a bit...
746746
}
747747

748+
/// Transaction outputs to watch for on-chain spends.
749+
pub(super) type TransactionOutputs = (Txid, Vec<(u32, TxOut)>);
750+
748751
#[cfg(any(test, feature = "fuzztarget", feature = "_test_utils"))]
749752
/// Used only in testing and fuzztarget to check serialization roundtrips don't change the
750753
/// underlying object
@@ -1276,7 +1279,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
12761279
broadcaster: B,
12771280
fee_estimator: F,
12781281
logger: L,
1279-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
1282+
) -> Vec<TransactionOutputs>
12801283
where
12811284
B::Target: BroadcasterInterface,
12821285
F::Target: FeeEstimator,
@@ -1321,7 +1324,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
13211324
broadcaster: B,
13221325
fee_estimator: F,
13231326
logger: L,
1324-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
1327+
) -> Vec<TransactionOutputs>
13251328
where
13261329
B::Target: BroadcasterInterface,
13271330
F::Target: FeeEstimator,
@@ -1376,7 +1379,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
13761379
broadcaster: B,
13771380
fee_estimator: F,
13781381
logger: L,
1379-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
1382+
) -> Vec<TransactionOutputs>
13801383
where
13811384
B::Target: BroadcasterInterface,
13821385
F::Target: FeeEstimator,
@@ -1691,7 +1694,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
16911694
/// HTLC-Success/HTLC-Timeout transactions.
16921695
/// Return updates for HTLC pending in the channel and failed automatically by the broadcast of
16931696
/// revoked counterparty commitment tx
1694-
fn check_spend_counterparty_transaction<L: Deref>(&mut self, tx: &Transaction, height: u32, logger: &L) -> (Vec<ClaimRequest>, (Txid, Vec<(u32, TxOut)>)) where L::Target: Logger {
1697+
fn check_spend_counterparty_transaction<L: Deref>(&mut self, tx: &Transaction, height: u32, logger: &L) -> (Vec<ClaimRequest>, TransactionOutputs) where L::Target: Logger {
16951698
// Most secp and related errors trying to create keys means we have no hope of constructing
16961699
// a spend transaction...so we return no transactions to broadcast
16971700
let mut claimable_outpoints = Vec::new();
@@ -1902,7 +1905,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
19021905
}
19031906

19041907
/// Attempts to claim a counterparty HTLC-Success/HTLC-Timeout's outputs using the revocation key
1905-
fn check_spend_counterparty_htlc<L: Deref>(&mut self, tx: &Transaction, commitment_number: u64, height: u32, logger: &L) -> (Vec<ClaimRequest>, Option<(Txid, Vec<(u32, TxOut)>)>) where L::Target: Logger {
1908+
fn check_spend_counterparty_htlc<L: Deref>(&mut self, tx: &Transaction, commitment_number: u64, height: u32, logger: &L) -> (Vec<ClaimRequest>, Option<TransactionOutputs>) where L::Target: Logger {
19061909
let htlc_txid = tx.txid();
19071910
if tx.input.len() != 1 || tx.output.len() != 1 || tx.input[0].witness.len() != 5 {
19081911
return (Vec::new(), None)
@@ -1971,7 +1974,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
19711974
/// Attempts to claim any claimable HTLCs in a commitment transaction which was not (yet)
19721975
/// revoked using data in holder_claimable_outpoints.
19731976
/// Should not be used if check_spend_revoked_transaction succeeds.
1974-
fn check_spend_holder_transaction<L: Deref>(&mut self, tx: &Transaction, height: u32, logger: &L) -> (Vec<ClaimRequest>, (Txid, Vec<(u32, TxOut)>)) where L::Target: Logger {
1977+
fn check_spend_holder_transaction<L: Deref>(&mut self, tx: &Transaction, height: u32, logger: &L) -> (Vec<ClaimRequest>, TransactionOutputs) where L::Target: Logger {
19751978
let commitment_txid = tx.txid();
19761979
let mut claim_requests = Vec::new();
19771980
let mut watch_outputs = Vec::new();
@@ -2094,7 +2097,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
20942097
return res
20952098
}
20962099

2097-
pub fn block_connected<B: Deref, F: Deref, L: Deref>(&mut self, header: &BlockHeader, txdata: &TransactionData, height: u32, broadcaster: B, fee_estimator: F, logger: L)-> Vec<(Txid, Vec<(u32, TxOut)>)>
2100+
pub fn block_connected<B: Deref, F: Deref, L: Deref>(&mut self, header: &BlockHeader, txdata: &TransactionData, height: u32, broadcaster: B, fee_estimator: F, logger: L) -> Vec<TransactionOutputs>
20982101
where B::Target: BroadcasterInterface,
20992102
F::Target: FeeEstimator,
21002103
L::Target: Logger,
@@ -2113,7 +2116,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
21132116
broadcaster: B,
21142117
fee_estimator: F,
21152118
logger: L,
2116-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
2119+
) -> Vec<TransactionOutputs>
21172120
where
21182121
B::Target: BroadcasterInterface,
21192122
F::Target: FeeEstimator,
@@ -2141,7 +2144,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
21412144
broadcaster: B,
21422145
fee_estimator: F,
21432146
logger: L,
2144-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
2147+
) -> Vec<TransactionOutputs>
21452148
where
21462149
B::Target: BroadcasterInterface,
21472150
F::Target: FeeEstimator,
@@ -2209,12 +2212,12 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
22092212
&mut self,
22102213
height: u32,
22112214
txn_matched: Vec<&Transaction>,
2212-
mut watch_outputs: Vec<(Txid, Vec<(u32, TxOut)>)>,
2215+
mut watch_outputs: Vec<TransactionOutputs>,
22132216
mut claimable_outpoints: Vec<ClaimRequest>,
22142217
broadcaster: B,
22152218
fee_estimator: F,
22162219
logger: L,
2217-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
2220+
) -> Vec<TransactionOutputs>
22182221
where
22192222
B::Target: BroadcasterInterface,
22202223
F::Target: FeeEstimator,

0 commit comments

Comments
 (0)