Skip to content

Commit e751ee9

Browse files
committed
Add an internal typedef for transaction outputs
1 parent 3edd969 commit e751ee9

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;
@@ -140,7 +139,7 @@ where C::Target: chain::Filter,
140139

141140
fn process_transactions<FN>(&self, header: &BlockHeader, txdata: &TransactionData, process: FN)
142141
where
143-
FN: Fn(&ChannelMonitor<ChannelSigner>, &TransactionData) -> Vec<(Txid, Vec<(u32, TxOut)>)>
142+
FN: Fn(&ChannelMonitor<ChannelSigner>, &TransactionData) -> Vec<TransactionOutputs>
144143
{
145144
let mut dependent_txdata = Vec::new();
146145
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
@@ -747,6 +747,9 @@ pub(crate) struct ChannelMonitorImpl<Signer: Sign> {
747747
secp_ctx: Secp256k1<secp256k1::All>, //TODO: dedup this a bit...
748748
}
749749

750+
/// Transaction outputs to watch for on-chain spends.
751+
pub(super) type TransactionOutputs = (Txid, Vec<(u32, TxOut)>);
752+
750753
#[cfg(any(test, feature = "fuzztarget", feature = "_test_utils"))]
751754
/// Used only in testing and fuzztarget to check serialization roundtrips don't change the
752755
/// underlying object
@@ -1278,7 +1281,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
12781281
broadcaster: B,
12791282
fee_estimator: F,
12801283
logger: L,
1281-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
1284+
) -> Vec<TransactionOutputs>
12821285
where
12831286
B::Target: BroadcasterInterface,
12841287
F::Target: FeeEstimator,
@@ -1323,7 +1326,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
13231326
broadcaster: B,
13241327
fee_estimator: F,
13251328
logger: L,
1326-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
1329+
) -> Vec<TransactionOutputs>
13271330
where
13281331
B::Target: BroadcasterInterface,
13291332
F::Target: FeeEstimator,
@@ -1379,7 +1382,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
13791382
broadcaster: B,
13801383
fee_estimator: F,
13811384
logger: L,
1382-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
1385+
) -> Vec<TransactionOutputs>
13831386
where
13841387
B::Target: BroadcasterInterface,
13851388
F::Target: FeeEstimator,
@@ -1695,7 +1698,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
16951698
/// HTLC-Success/HTLC-Timeout transactions.
16961699
/// Return updates for HTLC pending in the channel and failed automatically by the broadcast of
16971700
/// revoked counterparty commitment tx
1698-
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 {
1701+
fn check_spend_counterparty_transaction<L: Deref>(&mut self, tx: &Transaction, height: u32, logger: &L) -> (Vec<ClaimRequest>, TransactionOutputs) where L::Target: Logger {
16991702
// Most secp and related errors trying to create keys means we have no hope of constructing
17001703
// a spend transaction...so we return no transactions to broadcast
17011704
let mut claimable_outpoints = Vec::new();
@@ -1906,7 +1909,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
19061909
}
19071910

19081911
/// Attempts to claim a counterparty HTLC-Success/HTLC-Timeout's outputs using the revocation key
1909-
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 {
1912+
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 {
19101913
let htlc_txid = tx.txid();
19111914
if tx.input.len() != 1 || tx.output.len() != 1 || tx.input[0].witness.len() != 5 {
19121915
return (Vec::new(), None)
@@ -1975,7 +1978,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
19751978
/// Attempts to claim any claimable HTLCs in a commitment transaction which was not (yet)
19761979
/// revoked using data in holder_claimable_outpoints.
19771980
/// Should not be used if check_spend_revoked_transaction succeeds.
1978-
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 {
1981+
fn check_spend_holder_transaction<L: Deref>(&mut self, tx: &Transaction, height: u32, logger: &L) -> (Vec<ClaimRequest>, TransactionOutputs) where L::Target: Logger {
19791982
let commitment_txid = tx.txid();
19801983
let mut claim_requests = Vec::new();
19811984
let mut watch_outputs = Vec::new();
@@ -2098,7 +2101,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
20982101
return res
20992102
}
21002103

2101-
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)>)>
2104+
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>
21022105
where B::Target: BroadcasterInterface,
21032106
F::Target: FeeEstimator,
21042107
L::Target: Logger,
@@ -2117,7 +2120,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
21172120
broadcaster: B,
21182121
fee_estimator: F,
21192122
logger: L,
2120-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
2123+
) -> Vec<TransactionOutputs>
21212124
where
21222125
B::Target: BroadcasterInterface,
21232126
F::Target: FeeEstimator,
@@ -2145,7 +2148,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
21452148
broadcaster: B,
21462149
fee_estimator: F,
21472150
logger: L,
2148-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
2151+
) -> Vec<TransactionOutputs>
21492152
where
21502153
B::Target: BroadcasterInterface,
21512154
F::Target: FeeEstimator,
@@ -2213,12 +2216,12 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
22132216
&mut self,
22142217
height: u32,
22152218
txn_matched: Vec<&Transaction>,
2216-
mut watch_outputs: Vec<(Txid, Vec<(u32, TxOut)>)>,
2219+
mut watch_outputs: Vec<TransactionOutputs>,
22172220
mut claimable_outpoints: Vec<ClaimRequest>,
22182221
broadcaster: B,
22192222
fee_estimator: F,
22202223
logger: L,
2221-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
2224+
) -> Vec<TransactionOutputs>
22222225
where
22232226
B::Target: BroadcasterInterface,
22242227
F::Target: FeeEstimator,

0 commit comments

Comments
 (0)