@@ -231,12 +231,8 @@ export class MoneroEngine implements EdgeCurrencyEngine {
231231 ourReceiveAddresses . push ( this . walletInfo . keys . moneroAddress . toLowerCase ( ) )
232232 }
233233
234- let blockHeight = tx . height
235- if ( tx . mempool ) {
236- blockHeight = 0
237- }
238-
239- const date = Date . parse ( tx . timestamp ) / 1000
234+ const blockHeight = tx . height == null || tx . mempool ? 0 : tx . height
235+ const date = tx . timestamp == null ? new Date ( ) : new Date ( tx . timestamp )
240236
241237 // Expose legacy payment ID's to the GUI. This only applies
242238 // to really old transactions, before integrated addresses:
@@ -249,10 +245,10 @@ export class MoneroEngine implements EdgeCurrencyEngine {
249245 } )
250246 }
251247
252- let edgeTransaction : EdgeTransaction = {
248+ const edgeTransaction : EdgeTransaction = {
253249 blockHeight,
254250 currencyCode : 'XMR' ,
255- date,
251+ date : date . valueOf ( ) / 1000 ,
256252 isSend : lt ( netNativeAmount , '0' ) ,
257253 memos,
258254 nativeAmount : netNativeAmount ,
@@ -280,16 +276,14 @@ export class MoneroEngine implements EdgeCurrencyEngine {
280276 // Already have this tx in the database. See if anything changed
281277 const transactionsArray : EdgeTransaction [ ] =
282278 this . walletLocalData . transactionsObj [ PRIMARY_CURRENCY ]
283- const edgeTx = transactionsArray [ idx ]
279+ const oldTx = transactionsArray [ idx ]
284280
285- if ( edgeTx . blockHeight !== edgeTransaction . blockHeight ) {
281+ if ( oldTx . date < edgeTransaction . date ) edgeTransaction . date = oldTx . date
282+ if ( oldTx . blockHeight !== edgeTransaction . blockHeight ) {
286283 // The native amounts returned from the API take some time before they're accurate. We can trust the amounts we saved instead.
287- edgeTransaction = {
288- ...edgeTransaction ,
289- nativeAmount : edgeTx . nativeAmount
290- }
284+ edgeTransaction . nativeAmount = oldTx . nativeAmount
291285
292- this . log ( `Update transaction: ${ tx . hash } height:${ tx . height } ` )
286+ this . log ( `Update transaction: ${ tx . hash } height:${ blockHeight } ` )
293287 this . updateTransaction ( PRIMARY_CURRENCY , edgeTransaction , idx )
294288 this . edgeTxLibCallbacks . onTransactionsChanged (
295289 this . transactionsChangedArray
0 commit comments