Skip to content

Commit d70fdd3

Browse files
committed
Return optional Transaction from register_output
Electrum clients primarily operate by subscribing to notifications of transactions by script pubkeys. Therefore, they will send filtered transaction data without including dependent transactions. Outputs for such transactions must be explicitly registered with these clients. Therefore, upon block_connected, provide a mechanism for an Electrum- backed chain::Filter to return new transaction data to scan.
1 parent 8a8c75a commit d70fdd3

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lightning/src/chain/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
1212
use bitcoin::blockdata::block::{Block, BlockHeader};
1313
use bitcoin::blockdata::script::Script;
14-
use bitcoin::blockdata::transaction::TxOut;
14+
use bitcoin::blockdata::transaction::{Transaction, TxOut};
1515
use bitcoin::hash_types::{BlockHash, Txid};
1616

1717
use chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpdateErr, MonitorEvent};
@@ -131,7 +131,10 @@ pub trait Filter: Send + Sync {
131131

132132
/// Registers interest in spends of a transaction output identified by `outpoint` having
133133
/// `script_pubkey` as the spending condition.
134-
fn register_output(&self, outpoint: &OutPoint, script_pubkey: &Script);
134+
///
135+
/// Optionally, returns any transaction dependent on the output. This is useful for Electrum
136+
/// clients to facilitate registering in-block descendants.
137+
fn register_output(&self, outpoint: &OutPoint, script_pubkey: &Script) -> Option<(usize, Transaction)>;
135138
}
136139

137140
impl<T: Listen> Listen for std::ops::Deref<Target = T> {

lightning/src/util/test_utils.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,8 @@ impl chain::Filter for TestChainSource {
546546
self.watched_txn.lock().unwrap().insert((*txid, script_pubkey.clone()));
547547
}
548548

549-
fn register_output(&self, outpoint: &OutPoint, script_pubkey: &Script) {
549+
fn register_output(&self, outpoint: &OutPoint, script_pubkey: &Script) -> Option<(usize, Transaction)> {
550550
self.watched_outputs.lock().unwrap().insert((*outpoint, script_pubkey.clone()));
551+
None
551552
}
552553
}

0 commit comments

Comments
 (0)