@ -28,8 +28,62 @@
//
"use strict" ;
//
const JSBigInt = require ( "../cryptonote_utils/biginteger" ) . BigInteger ;
const monero _config = require ( "./monero_config" ) ;
const moment = require ( "../cryptonote_utils/moment" )
const monero _keyImage _cache _utils = require ( "./monero_keyImage_cache_utils" ) ;
const monero _amount _format _utils = require ( "./monero_amount_format_utils" ) ;
//
function ownedParsedTxFrom _ _orNil (
raw _tx ,
address ,
view _key _ _private ,
spend _key _ _public ,
spend _key _ _private ,
keyImage _cache ,
coreBridge _instance
) {
var tx = JSON . parse ( JSON . stringify ( raw _tx ) ) // copy ... do we need/want to do this?
//
if ( ( tx . spent _outputs || [ ] ) . length > 0 ) {
for ( var j = 0 ; j < tx . spent _outputs . length ; ++ j ) {
var key _image = monero _keyImage _cache _utils . Lazy _KeyImage (
keyImage _cache ,
tx . spent _outputs [ j ] . tx _pub _key ,
tx . spent _outputs [ j ] . out _index ,
address ,
view _key _ _private ,
spend _key _ _public ,
spend _key _ _private ,
coreBridge _instance
) ;
if ( tx . spent _outputs [ j ] . key _image !== key _image ) {
// console.log('Output used as mixin, ignoring (' + transactions[i].spent_outputs[j].key_image + '/' + key_image + ')')
tx . total _sent = ( new JSBigInt ( tx . total _sent ) ) . subtract ( tx . spent _outputs [ j ] . amount ) . toString ( ) // TODO: probably faster to keep it as a JSBigInt til we're done calculating
tx . spent _outputs . splice ( j , 1 ) // remove
j --
}
}
}
if ( new JSBigInt ( tx . total _received || 0 ) . add ( tx . total _sent || 0 ) . compare ( 0 ) <= 0 ) {
return null // not own tx - discard
}
tx . amount = new JSBigInt ( tx . total _received || 0 ) . subtract ( tx . total _sent || 0 ) . toString ( )
tx . approx _float _amount = parseFloat ( monero _amount _format _utils . formatMoney ( tx . amount ) ) ;
// tx.timestamp = tx.timestamp;
//
if ( typeof tx . payment _id !== "undefined" && tx . payment _id ) {
if ( tx . payment _id . length == 16 ) {
// short (encrypted) pid
if ( tx . approx _float _amount < 0 ) {
// outgoing
delete tx [ "payment_id" ] ; // need to filter these out .. because the server can't filter out short (encrypted) pids on outgoing txs
}
}
}
return tx
}
exports . ownedParsedTxFrom _ _orNil = ownedParsedTxFrom _ _orNil
//
function IsTransactionConfirmed ( tx , blockchain _height )
{