<commit_before>angular.module("omniFactories")
	.factory("Address", ["BalanceSocket", "$rootScope", "AddressManager", "WHOLE_UNIT", 
		function AddressModelFactory(BalanceSocket, $rootScope, AddressManager, WHOLE_UNIT){
			var AddressModel = function(hash,privkey,pubkey){
				var self = this;

				self.initialize = function(){
					if(!BalanceSocket.connected)
						BalanceSocket.connect();
					self.loaded = false;
					self.hash = hash;
					self.privkey = privkey;
					self.pubkey = pubkey;
					self.keyCheck = self.checkKeys();
					self.balance = [];
					self.assets = [];
					self.qr = "https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl="+hash+"&choe=UTF-8";
					
					//AddressManager.getTransactions(hash).then(function(result){
					//	var data = result.data;
					//	self.transactions = data.transactions;
					//})

					BalanceSocket.on("address:book", function(data){
						if (typeof data[hash]!="undefined") {
							processBalanceData(data[hash].balance);
						} else {
							BalanceSocket.emit("address:add", {data:hash});
						}
					});
					BalanceSocket.on("address:"+hash, function(data){
						processBalanceData(data.balance);
					});

					BalanceSocket.emit("address:add", {data:hash});
				}

				var processBalanceData = function(serverBalance) {
					if(self.balance != serverBalance){
						var previousBalance = self.balance;
						serverBalance.forEach(function(balance,index){
							var found = previousBalance.filter(function(prevBalance){
								return prevBalance.symbol == balance.symbol
							})[0];

							var delta = found ? balance.value-found.value : balance.value;
							var dneg = found ? balance.pendingneg - found.pendingneg : balance.pendingneg;
							var dpos = found ? balance.pendingpos - found.pendingpos : balance.pendingpos;

							if (delta != 0 || dpos !=0 || dneg != 0)
								$rootScope.$broadcast('balance:'+balance.symbol, delta, dneg, dpos);
						});

						self.balance = serverBalance;
						$rootScope.$broadcast('balance:changed');
	
						if(!self.loaded){
							self.loaded=true;
							$rootScope.$broadcast("address:loaded", {hash:hash});
						}
					}
				}
				self.checkKeys = function(){
					hash=self.hash;
					pubkey=self.pubkey;
					privkey=self.privkey;
					check=false;
					if (privkey && privkey.length == 58) {
						var ecKey = Bitcoin.ECKey.decodeEncryptedFormat(privkey, hash);
						var addr = ecKey.getBitcoinAddress().toString();
						check = (addr == hash);
						if (!check) {
							console.log("ALERT! Private key/Address check MISMATCH. Expected",hash,"but received",addr,"Downgrading to watch-only");
						}
					} else if (pubkey and pubkey.length > 65) {
						var bitcore = require('bitcore-lib');
						var pub = bitcore.PublicKey(pubkey);
						var addr = pub.toAddress().toString();
						check = (addr == hash);
						if (!check) {
							console.log("ALERT! Armory Public key/Address check MISMATCH. Expected",hash,"but received",addr,"Downgrading to watch-only");
						}
					}
					return check
				}

				self.transactions = function(showtesteco){
					address=self.hash;
					//console.log("Starting "+address);
					return AddressManager.getTransactions(address).then(function(result){
						var data = result.data;
						//console.log("found data for "+data.address+" its length is "+data.transactions.length);
						txs=data.transactions;
						return txs.map(function(tx){
							if ((tx.currency.propertyid < 2147483648 && tx.currency.propertyid != 2) || showtesteco === 'true') {
								return tx;
							}<commit_msg>syntax fix<commit_after>angular.module("omniFactories")
	.factory("Address", ["BalanceSocket", "$rootScope", "AddressManager", "WHOLE_UNIT", 
		function AddressModelFactory(BalanceSocket, $rootScope, AddressManager, WHOLE_UNIT){
			var AddressModel = function(hash,privkey,pubkey){
				var self = this;

				self.initialize = function(){
					if(!BalanceSocket.connected)
						BalanceSocket.connect();
					self.loaded = false;
					self.hash = hash;
					self.privkey = privkey;
					self.pubkey = pubkey;
					self.keyCheck = self.checkKeys();
					self.balance = [];
					self.assets = [];
					self.qr = "https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl="+hash+"&choe=UTF-8";
					
					//AddressManager.getTransactions(hash).then(function(result){
					//	var data = result.data;
					//	self.transactions = data.transactions;
					//})

					BalanceSocket.on("address:book", function(data){
						if (typeof data[hash]!="undefined") {
							processBalanceData(data[hash].balance);
						} else {
							BalanceSocket.emit("address:add", {data:hash});
						}
					});
					BalanceSocket.on("address:"+hash, function(data){
						processBalanceData(data.balance);
					});

					BalanceSocket.emit("address:add", {data:hash});
				}

				var processBalanceData = function(serverBalance) {
					if(self.balance != serverBalance){
						var previousBalance = self.balance;
						serverBalance.forEach(function(balance,index){
							var found = previousBalance.filter(function(prevBalance){
								return prevBalance.symbol == balance.symbol
							})[0];

							var delta = found ? balance.value-found.value : balance.value;
							var dneg = found ? balance.pendingneg - found.pendingneg : balance.pendingneg;
							var dpos = found ? balance.pendingpos - found.pendingpos : balance.pendingpos;

							if (delta != 0 || dpos !=0 || dneg != 0)
								$rootScope.$broadcast('balance:'+balance.symbol, delta, dneg, dpos);
						});

						self.balance = serverBalance;
						$rootScope.$broadcast('balance:changed');
	
						if(!self.loaded){
							self.loaded=true;
							$rootScope.$broadcast("address:loaded", {hash:hash});
						}
					}
				}
				self.checkKeys = function(){
					hash=self.hash;
					pubkey=self.pubkey;
					privkey=self.privkey;
					check=false;
					if (privkey && privkey.length == 58) {
						var ecKey = Bitcoin.ECKey.decodeEncryptedFormat(privkey, hash);
						var addr = ecKey.getBitcoinAddress().toString();
						check = (addr == hash);
						if (!check) {
							console.log("ALERT! Private key/Address check MISMATCH. Expected",hash,"but received",addr,"Downgrading to watch-only");
						}
					} else if (pubkey && pubkey.length > 65) {
						var bitcore = require('bitcore-lib');
						var pub = bitcore.PublicKey(pubkey);
						var addr = pub.toAddress().toString();
						check = (addr == hash);
						if (!check) {
							console.log("ALERT! Armory Public key/Address check MISMATCH. Expected",hash,"but received",addr,"Downgrading to watch-only");
						}
					}
					return check
				}

				self.transactions = function(showtesteco){
					address=self.hash;
					//console.log("Starting "+address);
					return AddressManager.getTransactions(address).then(function(result){
						var data = result.data;
						//console.log("found data for "+data.address+" its length is "+data.transactions.length);
						txs=data.transactions;
						return txs.map(function(tx){
							if ((tx.currency.propertyid < 2147483648 && tx.currency.propertyid != 2) || showtesteco === 'true') {
								return tx;
							}
{'fraction_non_alphanumeric': 0.14750420639371845, 'fraction_numerical': 0.007291082445316881, 'mean_word_length': 3.0482406356413168, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4139032', 'n_tokens_mistral': 2977, 'n_tokens_neox': 2158, 'n_words': 398}