Skip to content

Commit 06e5a87

Browse files
committed
Add an internal typedef for transaction outputs
1 parent c1a317a commit 06e5a87

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

140139
fn process_transactions<FN>(&self, header: &BlockHeader, txdata: &TransactionData, process: FN)
141140
where
142-
FN: Fn(&ChannelMonitor<ChannelSigner>, &TransactionData) -> Vec<(Txid, Vec<(u32, TxOut)>)>
141+
FN: Fn(&ChannelMonitor<ChannelSigner>, &TransactionData) -> Vec<TransactionOutputs>
143142
{
144143
let mut dependent_txdata = Vec::new();
145144
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,
@@ -1692,7 +1695,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
16921695
/// HTLC-Success/HTLC-Timeout transactions.
16931696
/// Return updates for HTLC pending in the channel and failed automatically by the broadcast of
16941697
/// revoked counterparty commitment tx
1695-
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 {
1698+
fn check_spend_counterparty_transaction<L: Deref>(&mut self, tx: &Transaction, height: u32, logger: &L) -> (Vec<ClaimRequest>, TransactionOutputs) where L::Target: Logger {
16961699
// Most secp and related errors trying to create keys means we have no hope of constructing
16971700
// a spend transaction...so we return no transactions to broadcast
16981701
let mut claimable_outpoints = Vec::new();
@@ -1903,7 +1906,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
19031906
}
19041907

19051908
/// Attempts to claim a counterparty HTLC-Success/HTLC-Timeout's outputs using the revocation key
1906-
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 {
1909+
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 {
19071910
let htlc_txid = tx.txid();
19081911
if tx.input.len() != 1 || tx.output.len() != 1 || tx.input[0].witness.len() != 5 {
19091912
return (Vec::new(), None)
@@ -1972,7 +1975,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
19721975
/// Attempts to claim any claimable HTLCs in a commitment transaction which was not (yet)
19731976
/// revoked using data in holder_claimable_outpoints.
19741977
/// Should not be used if check_spend_revoked_transaction succeeds.
1975-
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 {
1978+
fn check_spend_holder_transaction<L: Deref>(&mut self, tx: &Transaction, height: u32, logger: &L) -> (Vec<ClaimRequest>, TransactionOutputs) where L::Target: Logger {
19761979
let commitment_txid = tx.txid();
19771980
let mut claim_requests = Vec::new();
19781981
let mut watch_outputs = Vec::new();
@@ -2095,7 +2098,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
20952098
return res
20962099
}
20972100

2098-
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)>)>
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<TransactionOutputs>
20992102
where B::Target: BroadcasterInterface,
21002103
F::Target: FeeEstimator,
21012104
L::Target: Logger,
@@ -2114,7 +2117,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
21142117
broadcaster: B,
21152118
fee_estimator: F,
21162119
logger: L,
2117-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
2120+
) -> Vec<TransactionOutputs>
21182121
where
21192122
B::Target: BroadcasterInterface,
21202123
F::Target: FeeEstimator,
@@ -2142,7 +2145,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
21422145
broadcaster: B,
21432146
fee_estimator: F,
21442147
logger: L,
2145-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
2148+
) -> Vec<TransactionOutputs>
21462149
where
21472150
B::Target: BroadcasterInterface,
21482151
F::Target: FeeEstimator,
@@ -2210,12 +2213,12 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
22102213
&mut self,
22112214
height: u32,
22122215
txn_matched: Vec<&Transaction>,
2213-
mut watch_outputs: Vec<(Txid, Vec<(u32, TxOut)>)>,
2216+
mut watch_outputs: Vec<TransactionOutputs>,
22142217
mut claimable_outpoints: Vec<ClaimRequest>,
22152218
broadcaster: B,
22162219
fee_estimator: F,
22172220
logger: L,
2218-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
2221+
) -> Vec<TransactionOutputs>
22192222
where
22202223
B::Target: BroadcasterInterface,
22212224
F::Target: FeeEstimator,

0 commit comments

Comments
 (0)