Skip to content

Commit 9ea1f83

Browse files
committed
Add an internal typedef for transaction outputs
1 parent f35f96c commit 9ea1f83

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;
@@ -115,7 +114,7 @@ where C::Target: chain::Filter,
115114

116115
fn process_transactions<FN>(&self, header: &BlockHeader, txdata: &TransactionData, process: FN)
117116
where
118-
FN: Fn(&ChannelMonitor<ChannelSigner>, &TransactionData) -> Vec<(Txid, Vec<(u32, TxOut)>)>
117+
FN: Fn(&ChannelMonitor<ChannelSigner>, &TransactionData) -> Vec<TransactionOutputs>
119118
{
120119
let mut dependent_txdata = Vec::new();
121120
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
@@ -1277,7 +1280,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
12771280
broadcaster: B,
12781281
fee_estimator: F,
12791282
logger: L,
1280-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
1283+
) -> Vec<TransactionOutputs>
12811284
where
12821285
B::Target: BroadcasterInterface,
12831286
F::Target: FeeEstimator,
@@ -1319,7 +1322,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
13191322
broadcaster: B,
13201323
fee_estimator: F,
13211324
logger: L,
1322-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
1325+
) -> Vec<TransactionOutputs>
13231326
where
13241327
B::Target: BroadcasterInterface,
13251328
F::Target: FeeEstimator,
@@ -1355,7 +1358,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
13551358
broadcaster: B,
13561359
fee_estimator: F,
13571360
logger: L,
1358-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
1361+
) -> Vec<TransactionOutputs>
13591362
where
13601363
B::Target: BroadcasterInterface,
13611364
F::Target: FeeEstimator,
@@ -1670,7 +1673,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
16701673
/// HTLC-Success/HTLC-Timeout transactions.
16711674
/// Return updates for HTLC pending in the channel and failed automatically by the broadcast of
16721675
/// revoked counterparty commitment tx
1673-
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 {
1676+
fn check_spend_counterparty_transaction<L: Deref>(&mut self, tx: &Transaction, height: u32, logger: &L) -> (Vec<ClaimRequest>, TransactionOutputs) where L::Target: Logger {
16741677
// Most secp and related errors trying to create keys means we have no hope of constructing
16751678
// a spend transaction...so we return no transactions to broadcast
16761679
let mut claimable_outpoints = Vec::new();
@@ -1881,7 +1884,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
18811884
}
18821885

18831886
/// Attempts to claim a counterparty HTLC-Success/HTLC-Timeout's outputs using the revocation key
1884-
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 {
1887+
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 {
18851888
let htlc_txid = tx.txid();
18861889
if tx.input.len() != 1 || tx.output.len() != 1 || tx.input[0].witness.len() != 5 {
18871890
return (Vec::new(), None)
@@ -1950,7 +1953,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
19501953
/// Attempts to claim any claimable HTLCs in a commitment transaction which was not (yet)
19511954
/// revoked using data in holder_claimable_outpoints.
19521955
/// Should not be used if check_spend_revoked_transaction succeeds.
1953-
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 {
1956+
fn check_spend_holder_transaction<L: Deref>(&mut self, tx: &Transaction, height: u32, logger: &L) -> (Vec<ClaimRequest>, TransactionOutputs) where L::Target: Logger {
19541957
let commitment_txid = tx.txid();
19551958
let mut claim_requests = Vec::new();
19561959
let mut watch_outputs = Vec::new();
@@ -2073,7 +2076,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
20732076
return res
20742077
}
20752078

2076-
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)>)>
2079+
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>
20772080
where B::Target: BroadcasterInterface,
20782081
F::Target: FeeEstimator,
20792082
L::Target: Logger,
@@ -2093,7 +2096,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
20932096
broadcaster: B,
20942097
fee_estimator: F,
20952098
logger: L,
2096-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
2099+
) -> Vec<TransactionOutputs>
20972100
where
20982101
B::Target: BroadcasterInterface,
20992102
F::Target: FeeEstimator,
@@ -2121,7 +2124,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
21212124
broadcaster: B,
21222125
fee_estimator: F,
21232126
logger: L,
2124-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
2127+
) -> Vec<TransactionOutputs>
21252128
where
21262129
B::Target: BroadcasterInterface,
21272130
F::Target: FeeEstimator,
@@ -2189,12 +2192,12 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
21892192
&mut self,
21902193
height: u32,
21912194
txn_matched: Vec<&Transaction>,
2192-
mut watch_outputs: Vec<(Txid, Vec<(u32, TxOut)>)>,
2195+
mut watch_outputs: Vec<TransactionOutputs>,
21932196
mut claimable_outpoints: Vec<ClaimRequest>,
21942197
broadcaster: B,
21952198
fee_estimator: F,
21962199
logger: L,
2197-
) -> Vec<(Txid, Vec<(u32, TxOut)>)>
2200+
) -> Vec<TransactionOutputs>
21982201
where
21992202
B::Target: BroadcasterInterface,
22002203
F::Target: FeeEstimator,

0 commit comments

Comments
 (0)