File tree Expand file tree Collapse file tree
crates/webzjs-wallet/src/bindgen Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -297,7 +297,7 @@ impl WebWallet {
297297 match sync_handler. await {
298298 Ok ( Ok ( ( ) ) ) => Ok ( ( ) ) ,
299299 Ok ( Err ( err_string) ) => {
300- tracing:: error !( "Sync error: {}" , err_string) ;
300+ tracing:: warn !( "Sync error (will be retried by caller) : {}" , err_string) ;
301301 Err ( Error :: Sync ( err_string) )
302302 }
303303 Err ( panic_error) => {
@@ -396,7 +396,9 @@ impl WebWallet {
396396 } )
397397 . unwrap_throw ( )
398398 . join_async ( ) ;
399- let txids = sync_handler. await . unwrap ( ) ;
399+ let txids = sync_handler. await . map_err ( |e| {
400+ Error :: Generic ( format ! ( "Transaction creation thread panicked: {:?}" , e) )
401+ } ) ?;
400402
401403 let flattened_txid_bytes = txids. iter ( ) . flat_map ( |& x| x. as_ref ( ) . clone ( ) ) . collect ( ) ;
402404 Ok ( flattened_txid_bytes)
Original file line number Diff line number Diff line change @@ -488,15 +488,15 @@ export function useWebZjsActions(): WebzjsActions {
488488 }
489489 } catch ( syncErr ) {
490490 consecutiveFailures ++ ;
491- console . warn ( `Full resync: sync round ${ round } failed (${ consecutiveFailures } /${ MAX_CONSECUTIVE_FAILURES } ):` , syncErr ) ;
491+ console . debug ( `Full resync: sync round ${ round } failed (${ consecutiveFailures } /${ MAX_CONSECUTIVE_FAILURES } ):` , syncErr ) ;
492492
493493 if ( consecutiveFailures >= MAX_CONSECUTIVE_FAILURES ) {
494494 throw syncErr ; // give up after too many consecutive failures
495495 }
496496
497497 // Back off longer after failures
498498 const backoff = SYNC_ROUND_DELAY * Math . pow ( 2 , consecutiveFailures - 1 ) ;
499- console . info ( `Full resync: backing off ${ backoff } ms before retry` ) ;
499+ console . debug ( `Full resync: backing off ${ backoff } ms before retry` ) ;
500500 await new Promise ( r => setTimeout ( r , backoff ) ) ;
501501 }
502502 }
Original file line number Diff line number Diff line change @@ -7,12 +7,17 @@ function zatsToZec(zats: number): number {
77}
88
99function zecToZats ( zecAmount : string ) : bigint {
10+ const trimmed = zecAmount . trim ( ) ;
1011
11- if ( ! / ^ \d + ( \. \d + ) ? $ / . test ( zecAmount ) ) {
12+ if ( ! / ^ ( \d + \. ? \d * | \. \d + ) $ / . test ( trimmed ) ) {
1213 throw new Error ( 'Invalid ZEC format: must be positive number' ) ;
1314 }
1415
15- const amount = new Decimal ( zecAmount ) ;
16+ const amount = new Decimal ( trimmed ) ;
17+
18+ if ( ! amount . isPositive ( ) || amount . isZero ( ) ) {
19+ throw new Error ( 'Invalid ZEC format: must be positive number' ) ;
20+ }
1621
1722 if ( amount . decimalPlaces ( ) > 8 ) {
1823 throw new Error ( 'Maximum 8 decimal places allowed' ) ;
You can’t perform that action at this time.
0 commit comments