// Path: src/com/blochstech/bitcoincardterminal/Model/AppSettings.java
// public class AppSettings {
// 	public static final double DUST_LIMIT = 0.00005460;
// 	public static final double MIN_FEE_BITCOINS = 0.0001;
// }
// 
// Path: src/com/blochstech/bitcoincardterminal/Utils/ShortNumberConverter.java
// public class ShortNumberConverter {
// 	
// 	public static String ToShort(Double value){
// 		NumberFormat formatter = new DecimalFormat();
// 
// 	    formatter = new DecimalFormat("0.000E00");
// 	    String temp = formatter.format(value);
// 	    
// 	    String temp2 = temp.substring(0, 5);
// 	    temp2 = temp2.replace(",", ".");
// 	    Double temp3 = Double.parseDouble(temp2);
// 	    formatter = new DecimalFormat("0.00");
// 	    formatter.setRoundingMode(RoundingMode.HALF_UP);
// 	    temp = formatter.format(temp3) + temp.substring(5);
// 	    
// 	    if(!temp.contains("E-")){
// 	    	temp = temp.substring(0, temp.indexOf("E")+1) + "0" + temp.substring(temp.indexOf("E")+1, temp.length());
// 	    }
// 
// 	    return temp.toLowerCase(Locale.ENGLISH);
// 	}
// 	/*public static Double FromShort(String value){
// 		
// 	}*/
// }
// 
// Path: src/com/blochstech/bitcoincardterminal/Utils/SyntacticSugar.java
// public class SyntacticSugar {
// 	@SuppressWarnings("unchecked")
// 	public static <T> T castAs(Object castee){
// 		try{
// 			return (T) castee;
// 		}catch(Exception ex){
// 			return null;
// 		}
// 	}
// 	
// 	public static boolean EqualWithinMargin(Double value1, Double value2, Double margin){
// 		return value1 * (1+margin) >= value2 && value2 * (1+margin) >= value1;
// 	}
// }


import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Locale;
import com.blochstech.bitcoincardterminal.Model.AppSettings;
import com.blochstech.bitcoincardterminal.Utils.ShortNumberConverter;
import com.blochstech.bitcoincardterminal.Utils.SyntacticSugar;
			if(knownSources.get(i).TXHash.toLowerCase(Locale.ENGLISH).equals(txHash.toLowerCase(Locale.ENGLISH)))
				return knownSources.get(i).Verified;
		}
		return false;
	}
	//TODO: This is becomming too complex to understand, consider moving logic into separated self-contained "steps"...
	//basically what we are doing with ProcessStateChange... CONSIDER solutions
	
	void addKnownSource(TXSourceId source){
		if(!knownSource(source)){
			knownSources.add(source);
		}else{
			for(int i = 0; i < knownSources.size(); i++){
				if(knownSources.get(i).TXHash.toLowerCase(Locale.ENGLISH).equals(source.TXHash.toLowerCase(Locale.ENGLISH))){
					source.Unusable = knownSources.get(i).Unusable || source.Unusable;
					knownSources.set(i, source);
				}
			}
		}
	}
	
	//This method does not handle the "Purchase complete."-message. TODO: Make sure the charge gets cleared etc. to prevent accidental auto double-charge..
	String updateCardMessageFromState(){
		if(!isConnected || cardNetworkType != 0 || cardProtocolType != 0)
			return "No card.";
		
		if (paymentComplete != 0){
			return paymentComplete == 1 ? "Payment complete." : "Error";
		}
		
// Path: src/com/blochstech/bitcoincardterminal/Model/AppSettings.java
// public class AppSettings {
// 	public static final double DUST_LIMIT = 0.00005460;
// 	public static final double MIN_FEE_BITCOINS = 0.0001;
// }
// 
// Path: src/com/blochstech/bitcoincardterminal/Utils/ShortNumberConverter.java
// public class ShortNumberConverter {
// 	
// 	public static String ToShort(Double value){
// 		NumberFormat formatter = new DecimalFormat();
// 
// 	    formatter = new DecimalFormat("0.000E00");
// 	    String temp = formatter.format(value);
// 	    
// 	    String temp2 = temp.substring(0, 5);
// 	    temp2 = temp2.replace(",", ".");
// 	    Double temp3 = Double.parseDouble(temp2);
// 	    formatter = new DecimalFormat("0.00");
// 	    formatter.setRoundingMode(RoundingMode.HALF_UP);
// 	    temp = formatter.format(temp3) + temp.substring(5);
// 	    
// 	    if(!temp.contains("E-")){
// 	    	temp = temp.substring(0, temp.indexOf("E")+1) + "0" + temp.substring(temp.indexOf("E")+1, temp.length());
// 	    }
// 
// 	    return temp.toLowerCase(Locale.ENGLISH);
// 	}
// 	/*public static Double FromShort(String value){
// 		
// 	}*/
// }
// 
// Path: src/com/blochstech/bitcoincardterminal/Utils/SyntacticSugar.java
// public class SyntacticSugar {
// 	@SuppressWarnings("unchecked")
// 	public static <T> T castAs(Object castee){
// 		try{
// 			return (T) castee;
// 		}catch(Exception ex){
// 			return null;
// 		}
// 	}
// 	
// 	public static boolean EqualWithinMargin(Double value1, Double value2, Double margin){
// 		return value1 * (1+margin) >= value2 && value2 * (1+margin) >= value1;
// 	}
// }


// Path: src/com/blochstech/bitcoincardterminal/Model/Communication/BitcoinCardStateObject.java
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Locale;
import com.blochstech.bitcoincardterminal.Model.AppSettings;
import com.blochstech.bitcoincardterminal.Utils.ShortNumberConverter;
import com.blochstech.bitcoincardterminal.Utils.SyntacticSugar;

			if(knownSources.get(i).TXHash.toLowerCase(Locale.ENGLISH).equals(txHash.toLowerCase(Locale.ENGLISH)))
				return knownSources.get(i).Verified;
		}
		return false;
	}
	//TODO: This is becomming too complex to understand, consider moving logic into separated self-contained "steps"...
	//basically what we are doing with ProcessStateChange... CONSIDER solutions
	
	void addKnownSource(TXSourceId source){
		if(!knownSource(source)){
			knownSources.add(source);
		}else{
			for(int i = 0; i < knownSources.size(); i++){
				if(knownSources.get(i).TXHash.toLowerCase(Locale.ENGLISH).equals(source.TXHash.toLowerCase(Locale.ENGLISH))){
					source.Unusable = knownSources.get(i).Unusable || source.Unusable;
					knownSources.set(i, source);
				}
			}
		}
	}
	
	//This method does not handle the "Purchase complete."-message. TODO: Make sure the charge gets cleared etc. to prevent accidental auto double-charge..
	String updateCardMessageFromState(){
		if(!isConnected || cardNetworkType != 0 || cardProtocolType != 0)
			return "No card.";
		
		if (paymentComplete != 0){
			return paymentComplete == 1 ? "Payment complete." : "Error";
		}
		
		if(amount < AppSettings.DUST_LIMIT)