Skip to content

Commit 250f30b

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 8a91bd9 commit 250f30b

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};
@@ -134,7 +134,10 @@ pub trait Filter: Send + Sync {
134134

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

140143
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
@@ -545,7 +545,8 @@ impl chain::Filter for TestChainSource {
545545
self.watched_txn.lock().unwrap().insert((*txid, script_pubkey.clone()));
546546
}
547547

548-
fn register_output(&self, outpoint: &OutPoint, script_pubkey: &Script) {
548+
fn register_output(&self, outpoint: &OutPoint, script_pubkey: &Script) -> Option<(usize, Transaction)> {
549549
self.watched_outputs.lock().unwrap().insert((*outpoint, script_pubkey.clone()));
550+
None
550551
}
551552
}

0 commit comments

Comments
 (0)