File tree Expand file tree Collapse file tree 2 files changed +22
-15
lines changed
Expand file tree Collapse file tree 2 files changed +22
-15
lines changed Original file line number Diff line number Diff line change @@ -257,7 +257,9 @@ fn payment_state_from_transactions(
257257 for tx in txs. iter ( ) . rev ( ) {
258258 for vout in tx. vout . iter ( ) {
259259 // sum up outputs towards the address to check
260- if vout. scriptpubkey_address == * address {
260+ if let Some ( ref addr) = vout. scriptpubkey_address
261+ && addr == address
262+ {
261263 total += vout. value ;
262264 }
263265 }
@@ -349,7 +351,7 @@ pub struct Tx {
349351#[ derive( Deserialize , Debug , Clone ) ]
350352pub struct Vout {
351353 pub value : u64 ,
352- pub scriptpubkey_address : String ,
354+ pub scriptpubkey_address : Option < String > ,
353355}
354356
355357#[ derive( Deserialize , Debug , Clone ) ]
@@ -388,7 +390,7 @@ pub mod tests {
388390 } ,
389391 vout : vec ! [ Vout {
390392 value: 500 ,
391- scriptpubkey_address: test_addr. to_owned( ) ,
393+ scriptpubkey_address: Some ( test_addr. to_owned( ) ) ,
392394 } ] ,
393395 } ;
394396
Original file line number Diff line number Diff line change @@ -46,12 +46,13 @@ impl BillService {
4646 let address_to_pay = self
4747 . bitcoin_client
4848 . get_address_to_pay ( & bill_keys. public_key , & holder_public_key. pub_key ( ) ) ?;
49- if let Ok ( payment_state ) = self
49+ match self
5050 . bitcoin_client
5151 . check_payment_for_address ( & address_to_pay, bill. sum )
5252 . await
5353 {
54- let should_update = match self
54+ Ok ( payment_state) => {
55+ let should_update = match self
5556 . store
5657 . get_payment_state ( bill_id)
5758 . await {
@@ -62,17 +63,21 @@ impl BillService {
6263 _ => true
6364 } ;
6465
65- if should_update {
66- debug ! (
67- "Updating bill payment state for {bill_id} to {payment_state:?} and invalidating cache"
68- ) ;
69- self . store
70- . set_payment_state ( bill_id, & payment_state)
71- . await ?;
72- // invalidate bill cache, so payment state is updated on next fetch
73- self . store . invalidate_bill_in_cache ( bill_id) . await ?;
66+ if should_update {
67+ debug ! (
68+ "Updating bill payment state for {bill_id} to {payment_state:?} and invalidating cache"
69+ ) ;
70+ self . store
71+ . set_payment_state ( bill_id, & payment_state)
72+ . await ?;
73+ // invalidate bill cache, so payment state is updated on next fetch
74+ self . store . invalidate_bill_in_cache ( bill_id) . await ?;
75+ }
7476 }
75- }
77+ Err ( e) => {
78+ log:: error!( "Error checking payment for {bill_id}: {e}" ) ;
79+ }
80+ } ;
7681 Ok ( ( ) )
7782 }
7883
You can’t perform that action at this time.
0 commit comments