@@ -1106,7 +1106,7 @@ WalletService.prototype._getUtxos = function(coin, addresses, cb) {
11061106 var bc = self . _getBlockchainExplorer ( coin , networkName ) ;
11071107 if ( ! bc ) return cb ( new Error ( 'Could not get blockchain explorer instance' ) ) ;
11081108
1109- self . logi ( '' , ' Querying utxos: %s addrs', addresses . length ) ;
1109+ self . logi ( 'Querying utxos: %s addrs' , addresses . length ) ;
11101110
11111111 bc . getUtxos ( addresses , function ( err , utxos ) {
11121112 if ( err ) return cb ( err ) ;
@@ -3010,7 +3010,7 @@ WalletService.prototype.getTxHistory = function(opts, cb) {
30103010
30113011 var amountIn , amountOut , amountOutChange ;
30123012 var amount , action , addressTo ;
3013- var inputs , outputs ;
3013+ var inputs , outputs , foreignCrafted ;
30143014
30153015 if ( tx . outputs . length || tx . inputs . length ) {
30163016
@@ -3024,7 +3024,9 @@ WalletService.prototype.getTxHistory = function(opts, cb) {
30243024 amount = amountOut ;
30253025 action = 'moved' ;
30263026 } else {
3027- amount = amountIn - amountOut - amountOutChange - ( amountIn > 0 ? tx . fees : 0 ) ;
3027+ // BWS standard sent
3028+ //(amountIn > 0 && amountOutChange >0 && outputs.length <= 2)
3029+ amount = amountIn - amountOut - amountOutChange - ( ( amountIn > 0 && amountOutChange > 0 ) ? tx . fees : 0 ) ;
30283030 action = amount > 0 ? 'sent' : 'received' ;
30293031 }
30303032
@@ -3035,6 +3037,11 @@ WalletService.prototype.getTxHistory = function(opts, cb) {
30353037 } ) ;
30363038 addressTo = firstExternalOutput ? firstExternalOutput . address : 'N/A' ;
30373039 } ;
3040+
3041+ if ( action == 'sent' && inputs . length != ( _ . filter ( inputs , 'isMine' ) ) . length ) {
3042+ foreignCrafted = true ;
3043+ }
3044+
30383045 } else {
30393046 action = 'invalid' ;
30403047 amount = 0 ;
@@ -3055,6 +3062,7 @@ WalletService.prototype.getTxHistory = function(opts, cb) {
30553062 time : tx . time ,
30563063 addressTo : addressTo ,
30573064 confirmations : tx . confirmations ,
3065+ foreignCrafted : foreignCrafted ,
30583066 } ;
30593067
30603068 if ( _ . isNumber ( tx . size ) && tx . size > 0 ) {
@@ -3139,7 +3147,7 @@ WalletService.prototype.getTxHistory = function(opts, cb) {
31393147 var bc = self . _getBlockchainExplorer ( wallet . coin , wallet . network ) ;
31403148 if ( ! bc ) return next ( new Error ( 'Could not get blockchain explorer instance' ) ) ;
31413149
3142- self . logi ( '' , ' Querying tx for: %s addrs', addresses . length ) ;
3150+ self . logi ( 'Querying tx for: %s addrs' , addresses . length ) ;
31433151
31443152 bc . getTransactions ( addressStrs , from , to , function ( err , rawTxs , total ) {
31453153 if ( err ) return next ( err ) ;
0 commit comments