@@ -45,6 +45,7 @@ use chain;
45
45
use chain:: chaininterface:: { BroadcasterInterface , FeeEstimator } ;
46
46
use chain:: transaction:: { OutPoint , TransactionData } ;
47
47
use chain:: keysinterface:: { SpendableOutputDescriptor , StaticPaymentOutputDescriptor , DelayedPaymentOutputDescriptor , Sign , KeysInterface } ;
48
+ use chain:: Filter ;
48
49
use util:: logger:: Logger ;
49
50
use util:: ser:: { Readable , ReadableArgs , MaybeReadable , Writer , Writeable , U48 } ;
50
51
use util:: byte_utils;
@@ -1165,10 +1166,23 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1165
1166
1166
1167
/// Gets a list of txids, with their output scripts (in the order they appear in the
1167
1168
/// transaction), which we must learn about spends of via block_connected().
1168
- ///
1169
- /// (C-not exported) because we have no HashMap bindings
1170
- pub fn get_outputs_to_watch ( & self ) -> HashMap < Txid , Vec < ( u32 , Script ) > > {
1171
- self . inner . lock ( ) . unwrap ( ) . get_outputs_to_watch ( ) . clone ( )
1169
+ pub fn get_outputs_to_watch ( & self ) -> Vec < ( Txid , Vec < ( u32 , Script ) > ) > {
1170
+ self . inner . lock ( ) . unwrap ( ) . get_outputs_to_watch ( )
1171
+ . iter ( ) . map ( |( txid, outputs) | ( * txid, outputs. clone ( ) ) ) . collect ( )
1172
+ }
1173
+
1174
+ /// Loads the funding txo and outputs to watch into the given `chain::Filter` by repeatedly
1175
+ /// calling `chain::Filter::register_output` and `chain::Filter::register_tx` until all outputs
1176
+ /// have been registered.
1177
+ pub fn load_outputs_to_watch < F : Deref > ( & self , filter : & F ) where F :: Target : chain:: Filter {
1178
+ let lock = self . inner . lock ( ) . unwrap ( ) ;
1179
+ filter. register_tx ( & lock. get_funding_txo ( ) . 0 . txid , & lock. get_funding_txo ( ) . 1 ) ;
1180
+ for ( txid, outputs) in lock. get_outputs_to_watch ( ) . iter ( ) {
1181
+ for ( index, script_pubkey) in outputs. iter ( ) {
1182
+ assert ! ( * index <= u16 :: max_value( ) as u32 ) ;
1183
+ filter. register_output ( & OutPoint { txid : * txid, index : * index as u16 } , script_pubkey) ;
1184
+ }
1185
+ }
1172
1186
}
1173
1187
1174
1188
/// Get the list of HTLCs who's status has been updated on chain. This should be called by
0 commit comments