@@ -11,7 +11,7 @@ use lightning::sign::{EntropySource, SpendableOutputDescriptor};
11
11
use lightning:: util:: ser:: Writeable ;
12
12
13
13
use bitcoin:: secp256k1:: Secp256k1 ;
14
- use bitcoin:: { BlockHash , BlockHeader , LockTime , PackedLockTime , Script , Transaction , Txid } ;
14
+ use bitcoin:: { BlockHash , BlockHeader , LockTime , PackedLockTime , Transaction , Txid } ;
15
15
16
16
use std:: ops:: Deref ;
17
17
use std:: sync:: { Arc , Mutex } ;
62
62
if let Some ( filter) = chain_source. as_ref ( ) {
63
63
for o in & outputs {
64
64
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
+ }
67
68
}
68
69
}
69
70
}
@@ -78,27 +79,30 @@ where
78
79
79
80
let cur_height = self . best_block . lock ( ) . unwrap ( ) . height ( ) ;
80
81
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) )
86
92
}
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
+ } ;
102
106
103
107
for descriptor in output_descriptors {
104
108
let id = self . keys_manager . get_secure_random_bytes ( ) ;
@@ -276,7 +280,9 @@ where
276
280
Ok ( Some ( spending_tx) ) => {
277
281
self . wallet . broadcast_transactions ( & [ & spending_tx] ) ;
278
282
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
+ }
280
286
}
281
287
output_info. spending_tx = Some ( spending_tx) ;
282
288
output_info. broadcast_height = Some ( height) ;
0 commit comments