@@ -64,10 +64,9 @@ ewmHandleAnnounceBalance (BREthereumEWM ewm,
6464 BREthereumWallet wallet ,
6565 UInt256 value ,
6666 int rid ) {
67- BREthereumAmount amount =
68- (AMOUNT_ETHER == walletGetAmountType (wallet )
69- ? amountCreateEther (etherCreate (value ))
70- : amountCreateToken (createTokenQuantity (walletGetToken (wallet ), value )));
67+ BREthereumAmount amount = (AMOUNT_ETHER == walletGetAmountType (wallet )
68+ ? amountCreateEther (etherCreate (value ))
69+ : amountCreateToken (createTokenQuantity (walletGetToken (wallet ), value )));
7170
7271 ewmSignalBalance (ewm , amount );
7372}
@@ -136,10 +135,12 @@ ewmUpdateGasPrice (BREthereumEWM ewm,
136135 switch (ewm -> mode ) {
137136 case SYNC_MODE_BRD_ONLY :
138137 case SYNC_MODE_BRD_WITH_P2P_SEND : {
138+ pthread_mutex_lock (& ewm -> lock );
139139 ewm -> client .funcGetGasPrice (ewm -> client .context ,
140140 ewm ,
141141 wallet ,
142142 ++ ewm -> requestId );
143+ pthread_mutex_unlock (& ewm -> lock );
143144 break ;
144145 }
145146
@@ -194,6 +195,8 @@ ewmGetGasEstimate (BREthereumEWM ewm,
194195 switch (ewm -> mode ) {
195196 case SYNC_MODE_BRD_ONLY :
196197 case SYNC_MODE_BRD_WITH_P2P_SEND : {
198+ pthread_mutex_lock (& ewm -> lock );
199+
197200 // This will be ZERO if transaction amount is in TOKEN.
198201 BREthereumEther amountInEther = transferGetEffectiveAmountInEther (transfer );
199202 BREthereumFeeBasis feeBasis = transferGetFeeBasis (transfer );
@@ -216,6 +219,7 @@ ewmGetGasEstimate (BREthereumEWM ewm,
216219 price ,
217220 data ,
218221 ++ ewm -> requestId );
222+ pthread_mutex_unlock (& ewm -> lock );
219223
220224 free (from );
221225 free (to );
@@ -353,6 +357,7 @@ ewmHandleAnnounceNonce (BREthereumEWM ewm,
353357 BREthereumAddress address ,
354358 uint64_t newNonce ,
355359 int rid ) {
360+ pthread_mutex_lock (& ewm -> lock );
356361 uint64_t oldNonce = accountGetAddressNonce (ewm -> account , address );
357362 if (oldNonce != newNonce ) {
358363 // This may not change the nonce
@@ -361,6 +366,7 @@ ewmHandleAnnounceNonce (BREthereumEWM ewm,
361366 if (oldNonce != accountGetAddressNonce (ewm -> account , address ))
362367 ewmHandleSaveWallet (ewm , ewmGetWallet (ewm ), CLIENT_CHANGE_UPD );
363368 }
369+ pthread_mutex_unlock (& ewm -> lock );
364370}
365371
366372// ==============================================================================================
@@ -642,6 +648,7 @@ ewmWalletSubmitTransfer(BREthereumEWM ewm,
642648 // assert: wallet-has-transfer
643649 // assert: signed
644650 // assert: originatingTransaction
651+ pthread_mutex_lock (& ewm -> lock );
645652
646653 BREthereumTransaction transaction = transferGetOriginatingTransaction (transfer );
647654 BREthereumBoolean isSigned = transactionIsSigned (transaction );
@@ -677,6 +684,7 @@ ewmWalletSubmitTransfer(BREthereumEWM ewm,
677684 bcsSendTransaction (ewm -> bcs , transaction );
678685 break ;
679686 }
687+ pthread_mutex_unlock (& ewm -> lock );
680688}
681689
682690extern void
@@ -734,7 +742,7 @@ ewmAnnounceSubmitTransfer (BREthereumEWM ewm,
734742 BREthereumHash hash = hashCreate (strHash );
735743 // We announce a submitted transfer => there is an originating transaction.
736744 if (ETHEREUM_BOOLEAN_IS_TRUE (hashEqual (hash , EMPTY_HASH_INIT ))
737- || ETHEREUM_BOOLEAN_IS_FALSE (hashEqual (hash , transferGetOriginatingTransactionHash ( transfer ))))
745+ || ETHEREUM_BOOLEAN_IS_FALSE (hashEqual (hash , ewmTransferGetOriginatingTransactionHash ( ewm , transfer ))))
738746 return ERROR_TRANSACTION_HASH_MISMATCH ;
739747 }
740748
0 commit comments