@@ -906,19 +906,14 @@ AddressService.prototype.getAddressSummary = function(address, options, callback
906
906
907
907
var outputs ;
908
908
var inputs ;
909
- var mempoolInputs ;
910
909
911
910
async . parallel (
912
911
[
913
912
function ( next ) {
914
- if ( options . noTxList ) {
915
- setImmediate ( next ) ;
916
- } else {
917
- self . getInputs ( address , opt , function ( err , ins ) {
918
- inputs = ins ;
919
- next ( err ) ;
920
- } ) ;
921
- }
913
+ self . getInputs ( address , opt , function ( err , ins ) {
914
+ inputs = ins ;
915
+ next ( err ) ;
916
+ } ) ;
922
917
} ,
923
918
function ( next ) {
924
919
self . getOutputs ( address , opt , function ( err , outs ) {
@@ -936,8 +931,8 @@ AddressService.prototype.getAddressSummary = function(address, options, callback
936
931
var totalSpent = 0 ;
937
932
var balance = 0 ;
938
933
var unconfirmedBalance = 0 ;
939
- var appearances = 0 ;
940
- var unconfirmedAppearances = 0 ;
934
+ var appearanceIds = { } ;
935
+ var unconfirmedAppearanceIds = { } ;
941
936
var txids = [ ] ;
942
937
943
938
for ( var i = 0 ; i < outputs . length ; i ++ ) {
@@ -951,33 +946,38 @@ AddressService.prototype.getAddressSummary = function(address, options, callback
951
946
if ( outputs [ i ] . confirmations ) {
952
947
totalReceived += outputs [ i ] . satoshis ;
953
948
balance += outputs [ i ] . satoshis ;
954
- appearances ++ ;
949
+ appearanceIds [ outputs [ i ] . txid ] = true ;
955
950
} else {
956
- unconfirmedAppearances ++ ;
951
+ unconfirmedAppearanceIds [ outputs [ i ] . txid ] = true ;
957
952
}
958
953
959
954
if ( spentDB || spentMempool ) {
960
955
unconfirmedBalance -= outputs [ i ] . satoshis ;
961
956
if ( spentDB ) {
962
957
totalSpent += outputs [ i ] . satoshis ;
963
958
balance -= outputs [ i ] . satoshis ;
964
- appearances ++ ;
965
- } else {
966
- unconfirmedAppearances ++ ;
967
959
}
968
960
}
969
961
}
970
962
963
+ for ( var j = 0 ; j < inputs . length ; j ++ ) {
964
+ if ( inputs [ j ] . confirmations ) {
965
+ appearanceIds [ inputs [ j ] . txid ] = true ;
966
+ } else {
967
+ unconfirmedAppearanceIds [ outputs [ j ] . txid ] = true ;
968
+ }
969
+ }
970
+
971
971
var summary = {
972
972
totalReceived : totalReceived ,
973
973
totalSpent : totalSpent ,
974
974
balance : balance ,
975
975
unconfirmedBalance : unconfirmedBalance ,
976
- appearances : appearances ,
977
- unconfirmedAppearances : unconfirmedAppearances
976
+ appearances : Object . keys ( appearanceIds ) . length ,
977
+ unconfirmedAppearances : Object . keys ( unconfirmedAppearanceIds ) . length
978
978
} ;
979
979
980
- if ( inputs ) {
980
+ if ( ! options . noTxList ) {
981
981
for ( var i = 0 ; i < inputs . length ; i ++ ) {
982
982
txids . push ( inputs [ i ] ) ;
983
983
}
0 commit comments