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(
257
257
for tx in txs. iter ( ) . rev ( ) {
258
258
for vout in tx. vout . iter ( ) {
259
259
// 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
+ {
261
263
total += vout. value ;
262
264
}
263
265
}
@@ -349,7 +351,7 @@ pub struct Tx {
349
351
#[ derive( Deserialize , Debug , Clone ) ]
350
352
pub struct Vout {
351
353
pub value : u64 ,
352
- pub scriptpubkey_address : String ,
354
+ pub scriptpubkey_address : Option < String > ,
353
355
}
354
356
355
357
#[ derive( Deserialize , Debug , Clone ) ]
@@ -388,7 +390,7 @@ pub mod tests {
388
390
} ,
389
391
vout : vec ! [ Vout {
390
392
value: 500 ,
391
- scriptpubkey_address: test_addr. to_owned( ) ,
393
+ scriptpubkey_address: Some ( test_addr. to_owned( ) ) ,
392
394
} ] ,
393
395
} ;
394
396
Original file line number Diff line number Diff line change @@ -46,12 +46,13 @@ impl BillService {
46
46
let address_to_pay = self
47
47
. bitcoin_client
48
48
. get_address_to_pay ( & bill_keys. public_key , & holder_public_key. pub_key ( ) ) ?;
49
- if let Ok ( payment_state ) = self
49
+ match self
50
50
. bitcoin_client
51
51
. check_payment_for_address ( & address_to_pay, bill. sum )
52
52
. await
53
53
{
54
- let should_update = match self
54
+ Ok ( payment_state) => {
55
+ let should_update = match self
55
56
. store
56
57
. get_payment_state ( bill_id)
57
58
. await {
@@ -62,17 +63,21 @@ impl BillService {
62
63
_ => true
63
64
} ;
64
65
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
+ }
74
76
}
75
- }
77
+ Err ( e) => {
78
+ log:: error!( "Error checking payment for {bill_id}: {e}" ) ;
79
+ }
80
+ } ;
76
81
Ok ( ( ) )
77
82
}
78
83
You can’t perform that action at this time.
0 commit comments