Skip to content

Commit b06b08d

Browse files
committed
Add an internal typedef for transaction outputs
1 parent c315490 commit b06b08d

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;
@@ -138,7 +137,7 @@ where C::Target: chain::Filter,
138137

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

751+
/// Transaction outputs to watch for on-chain spends.
752+
pub(super) type TransactionOutputs = (Txid, Vec<(u32, TxOut)>);
753+
751754
#[cfg(any(test, feature = "fuzztarget", feature = "_test_utils"))]
752755
/// Used only in testing and fuzztarget to check serialization roundtrips don't change the
753756
/// underlying object
@@ -1280,7 +1283,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
12801283
broadcaster: B,
12811284
fee_estimator: F,
12821285
logger: L,
1283-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
1286+
) -> Vec<TransactionOutputs>
12841287
where
12851288
B::Target: BroadcasterInterface,
12861289
F::Target: FeeEstimator,
@@ -1325,7 +1328,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
13251328
broadcaster: B,
13261329
fee_estimator: F,
13271330
logger: L,
1328-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
1331+
) -> Vec<TransactionOutputs>
13291332
where
13301333
B::Target: BroadcasterInterface,
13311334
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,
@@ -1694,7 +1697,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
16941697
/// HTLC-Success/HTLC-Timeout transactions.
16951698
/// Return updates for HTLC pending in the channel and failed automatically by the broadcast of
16961699
/// revoked counterparty commitment tx
1697-
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 {
1700+
fn check_spend_counterparty_transaction<L: Deref>(&mut self, tx: &Transaction, height: u32, logger: &L) -> (Vec<ClaimRequest>, TransactionOutputs) where L::Target: Logger {
16981701
// Most secp and related errors trying to create keys means we have no hope of constructing
16991702
// a spend transaction...so we return no transactions to broadcast
17001703
let mut claimable_outpoints = Vec::new();
@@ -1905,7 +1908,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
19051908
}
19061909

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

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<(Txid, Vec<(u32, TxOut)>)>
2103+
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>
21012104
where B::Target: BroadcasterInterface,
21022105
F::Target: FeeEstimator,
21032106
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)