Skip to content

Commit 3aed8a6

Browse files
committed
Add an internal typedef for transaction outputs
1 parent f5b0086 commit 3aed8a6

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
@@ -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,
@@ -1377,7 +1380,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
13771380
broadcaster: B,
13781381
fee_estimator: F,
13791382
logger: L,
1380-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
1383+
) -> Vec<TransactionOutputs>
13811384
where
13821385
B::Target: BroadcasterInterface,
13831386
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)