@@ -11,7 +11,7 @@ use lightning::sign::{EntropySource, SpendableOutputDescriptor};
1111use lightning:: util:: ser:: Writeable ;
1212
1313use bitcoin:: secp256k1:: Secp256k1 ;
14- use bitcoin:: { BlockHash , BlockHeader , LockTime , PackedLockTime , Script , Transaction , Txid } ;
14+ use bitcoin:: { BlockHash , BlockHeader , LockTime , PackedLockTime , Transaction , Txid } ;
1515
1616use std:: ops:: Deref ;
1717use std:: sync:: { Arc , Mutex } ;
6262 if let Some ( filter) = chain_source. as_ref ( ) {
6363 for o in & outputs {
6464 if let Some ( tx) = o. spending_tx . as_ref ( ) {
65- // TODO: can we give something better than the empty script here?
66- filter. register_tx ( & tx. txid ( ) , & Script :: new ( ) )
65+ if let Some ( tx_out) = tx. output . first ( ) {
66+ filter. register_tx ( & tx. txid ( ) , & tx_out. script_pubkey ) ;
67+ }
6768 }
6869 }
6970 }
@@ -78,27 +79,30 @@ where
7879
7980 let cur_height = self . best_block . lock ( ) . unwrap ( ) . height ( ) ;
8081
81- let ( spending_tx, broadcast_height) = match self . get_spending_tx ( & output_descriptors, cur_height) {
82- Ok ( Some ( spending_tx) ) => {
83- self . wallet . broadcast_transactions ( & [ & spending_tx] ) ;
84- if let Some ( filter) = self . chain_source . as_ref ( ) {
85- filter. register_tx ( & spending_tx. txid ( ) , & Script :: new ( ) )
82+ let ( spending_tx, broadcast_height) =
83+ match self . get_spending_tx ( & output_descriptors, cur_height) {
84+ Ok ( Some ( spending_tx) ) => {
85+ self . wallet . broadcast_transactions ( & [ & spending_tx] ) ;
86+ if let Some ( filter) = self . chain_source . as_ref ( ) {
87+ if let Some ( tx_out) = spending_tx. output . first ( ) {
88+ filter. register_tx ( & spending_tx. txid ( ) , & tx_out. script_pubkey ) ;
89+ }
90+ }
91+ ( Some ( spending_tx) , Some ( cur_height) )
8692 }
87- ( Some ( spending_tx) , Some ( cur_height) )
88- }
89- Ok ( None ) => {
90- log_debug ! (
91- self . logger,
92- "Omitted spending static outputs: {:?}" ,
93- output_descriptors
94- ) ;
95- ( None , None )
96- }
97- Err ( e) => {
98- log_error ! ( self . logger, "Error spending outputs: {:?}" , e) ;
99- ( None , None )
100- }
101- } ;
93+ Ok ( None ) => {
94+ log_debug ! (
95+ self . logger,
96+ "Omitted spending static outputs: {:?}" ,
97+ output_descriptors
98+ ) ;
99+ ( None , None )
100+ }
101+ Err ( e) => {
102+ log_error ! ( self . logger, "Error spending outputs: {:?}" , e) ;
103+ ( None , None )
104+ }
105+ } ;
102106
103107 for descriptor in output_descriptors {
104108 let id = self . keys_manager . get_secure_random_bytes ( ) ;
@@ -276,7 +280,9 @@ where
276280 Ok ( Some ( spending_tx) ) => {
277281 self . wallet . broadcast_transactions ( & [ & spending_tx] ) ;
278282 if let Some ( filter) = self . chain_source . as_ref ( ) {
279- filter. register_tx ( & spending_tx. txid ( ) , & Script :: new ( ) )
283+ if let Some ( tx_out) = spending_tx. output . first ( ) {
284+ filter. register_tx ( & spending_tx. txid ( ) , & tx_out. script_pubkey ) ;
285+ }
280286 }
281287 output_info. spending_tx = Some ( spending_tx) ;
282288 output_info. broadcast_height = Some ( height) ;
0 commit comments