// Path: app/src/main/java/com/bytetobyte/xwallet/service/Constants.java
// public class Constants {
//    // public static final org.bitcoinj.core.NetworkParameters NETWORK_PARAMETERS = TestNet3Params.get();
//     public static final org.bitcoinj.core.NetworkParameters NETWORK_PARAMETERS = MainNetParams.get();
// 
//     public static final char CHAR_HAIR_SPACE = '\u200a';
//     public static final char CHAR_THIN_SPACE = '\u2009';
//     public static final char CHAR_ALMOST_EQUAL_TO = '\u2248';
//     public static final char CHAR_CHECKMARK = '\u2713';
//     public static final char CURRENCY_PLUS_SIGN = '\uff0b';
//     public static final char CURRENCY_MINUS_SIGN = '\uff0d';
//     public static final String PREFIX_ALMOST_EQUAL_TO = Character.toString(CHAR_ALMOST_EQUAL_TO) + CHAR_THIN_SPACE;
//     public static final int ADDRESS_FORMAT_GROUP_SIZE = 36;
//     public static final int ADDRESS_FORMAT_LINE_SIZE = 36;
// 
//     public static final MonetaryFormat LOCAL_FORMAT = new MonetaryFormat().noCode().minDecimals(2).optionalDecimals();
// 
//     public static final BaseEncoding HEX = BaseEncoding.base16().lowerCase();
// 
//     /** Maximum size of backups. Files larger will be rejected. */
//     public static final long BACKUP_MAX_CHARS = 10000000;
// 
//     /** Currency code for the wallet name resolver. */
//     public static final String WALLET_NAME_CURRENCY_CODE = NETWORK_PARAMETERS.getId().equals(NetworkParameters.ID_MAINNET) ? "btc" : "tbtc";
// 
//     /**
//      * The earliest possible HD wallet.
//      * This is taken as the date of the last edit of the BIP39 word list: Oct 16 2014:
//      * https://github.com/bitcoin/bips/commits/master/bip-0039/bip-0039-wordlists.md
//      */
//     public static final String EARLIEST_HD_WALLET_DATE = "2014-10-16";
// }
// 
// Path: app/src/main/java/com/bytetobyte/xwallet/util/Iso8601Format.java
// @SuppressLint("SimpleDateFormat")
// public class Iso8601Format extends SimpleDateFormat {
//     private static final TimeZone UTC = TimeZone.getTimeZone("UTC");
// 
//     private Iso8601Format(final String formatString) {
//         super(formatString);
// 
//         setTimeZone(UTC);
//     }
// 
//     public static DateFormat newTimeFormat() {
//         return new Iso8601Format("HH:mm:ss");
//     }
// 
//     public static DateFormat newDateFormat() {
//         return new Iso8601Format("yyyy-MM-dd");
//     }
// 
//     public static DateFormat newDateTimeFormat() {
//         return new Iso8601Format("yyyy-MM-dd HH:mm:ss");
//     }
// 
//     public static String formatDateTime(final Date date) {
//         return newDateTimeFormat().format(date);
//     }
// 
//     public static Date parseDateTime(final String source) throws ParseException {
//         return newDateTimeFormat().parse(source);
//     }
// 
//     public static DateFormat newDateTimeFormatT() {
//         return new Iso8601Format("yyyy-MM-dd'T'HH:mm:ss'Z'");
//     }
// 
//     public static String formatDateTimeT(final Date date) {
//         return newDateTimeFormatT().format(date);
//     }
// 
//     public static Date parseDateTimeT(final String source) throws ParseException {
//         return newDateTimeFormatT().parse(source);
//     }
// }


import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.format.DateUtils;
import android.text.style.TypefaceSpan;
import com.bytetobyte.xwallet.service.Constants;
import com.bytetobyte.xwallet.util.Iso8601Format;
import com.google.common.base.Charsets;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.core.DumpedPrivateKey;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.ScriptException;
import org.bitcoinj.core.Sha256Hash;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.core.TransactionInput;
import org.bitcoinj.core.TransactionOutput;
import org.bitcoinj.script.Script;
import org.bitcoinj.wallet.KeyChainGroup;
import org.bitcoinj.wallet.UnreadableWalletException;
import org.bitcoinj.wallet.Wallet;
import org.bitcoinj.wallet.WalletProtobufSerializer;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Writer;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import javax.annotation.Nullable;
    }

    public static Wallet restorePrivateKeysFromBase58(final InputStream is,
                                                      final NetworkParameters expectedNetworkParameters) throws IOException {
        final BufferedReader keyReader = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));

        // create non-HD wallet
        final KeyChainGroup group = new KeyChainGroup(expectedNetworkParameters);
        group.importKeys(WalletUtils.readKeys(keyReader, expectedNetworkParameters));
        return new Wallet(expectedNetworkParameters, group);
    }

    public static void writeKeys(final Writer out, final List<ECKey> keys) throws IOException {
        final DateFormat format = Iso8601Format.newDateTimeFormatT();

        out.write("# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins.\n");

        for (final ECKey key : keys) {
            out.write(key.getPrivateKeyEncoded(Constants.NETWORK_PARAMETERS).toBase58());
            if (key.getCreationTimeSeconds() != 0) {
                out.write(' ');
                out.write(format.format(new Date(key.getCreationTimeSeconds() * DateUtils.SECOND_IN_MILLIS)));
            }
            out.write('\n');
        }
    }

    public static List<ECKey> readKeys(final BufferedReader in, final NetworkParameters expectedNetworkParameters)
            throws IOException {
        try {
// Path: app/src/main/java/com/bytetobyte/xwallet/service/Constants.java
// public class Constants {
//    // public static final org.bitcoinj.core.NetworkParameters NETWORK_PARAMETERS = TestNet3Params.get();
//     public static final org.bitcoinj.core.NetworkParameters NETWORK_PARAMETERS = MainNetParams.get();
// 
//     public static final char CHAR_HAIR_SPACE = '\u200a';
//     public static final char CHAR_THIN_SPACE = '\u2009';
//     public static final char CHAR_ALMOST_EQUAL_TO = '\u2248';
//     public static final char CHAR_CHECKMARK = '\u2713';
//     public static final char CURRENCY_PLUS_SIGN = '\uff0b';
//     public static final char CURRENCY_MINUS_SIGN = '\uff0d';
//     public static final String PREFIX_ALMOST_EQUAL_TO = Character.toString(CHAR_ALMOST_EQUAL_TO) + CHAR_THIN_SPACE;
//     public static final int ADDRESS_FORMAT_GROUP_SIZE = 36;
//     public static final int ADDRESS_FORMAT_LINE_SIZE = 36;
// 
//     public static final MonetaryFormat LOCAL_FORMAT = new MonetaryFormat().noCode().minDecimals(2).optionalDecimals();
// 
//     public static final BaseEncoding HEX = BaseEncoding.base16().lowerCase();
// 
//     /** Maximum size of backups. Files larger will be rejected. */
//     public static final long BACKUP_MAX_CHARS = 10000000;
// 
//     /** Currency code for the wallet name resolver. */
//     public static final String WALLET_NAME_CURRENCY_CODE = NETWORK_PARAMETERS.getId().equals(NetworkParameters.ID_MAINNET) ? "btc" : "tbtc";
// 
//     /**
//      * The earliest possible HD wallet.
//      * This is taken as the date of the last edit of the BIP39 word list: Oct 16 2014:
//      * https://github.com/bitcoin/bips/commits/master/bip-0039/bip-0039-wordlists.md
//      */
//     public static final String EARLIEST_HD_WALLET_DATE = "2014-10-16";
// }
// 
// Path: app/src/main/java/com/bytetobyte/xwallet/util/Iso8601Format.java
// @SuppressLint("SimpleDateFormat")
// public class Iso8601Format extends SimpleDateFormat {
//     private static final TimeZone UTC = TimeZone.getTimeZone("UTC");
// 
//     private Iso8601Format(final String formatString) {
//         super(formatString);
// 
//         setTimeZone(UTC);
//     }
// 
//     public static DateFormat newTimeFormat() {
//         return new Iso8601Format("HH:mm:ss");
//     }
// 
//     public static DateFormat newDateFormat() {
//         return new Iso8601Format("yyyy-MM-dd");
//     }
// 
//     public static DateFormat newDateTimeFormat() {
//         return new Iso8601Format("yyyy-MM-dd HH:mm:ss");
//     }
// 
//     public static String formatDateTime(final Date date) {
//         return newDateTimeFormat().format(date);
//     }
// 
//     public static Date parseDateTime(final String source) throws ParseException {
//         return newDateTimeFormat().parse(source);
//     }
// 
//     public static DateFormat newDateTimeFormatT() {
//         return new Iso8601Format("yyyy-MM-dd'T'HH:mm:ss'Z'");
//     }
// 
//     public static String formatDateTimeT(final Date date) {
//         return newDateTimeFormatT().format(date);
//     }
// 
//     public static Date parseDateTimeT(final String source) throws ParseException {
//         return newDateTimeFormatT().parse(source);
//     }
// }


// Path: app/src/main/java/com/bytetobyte/xwallet/service/coin/bitcoin/WalletUtils.java
import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.format.DateUtils;
import android.text.style.TypefaceSpan;
import com.bytetobyte.xwallet.service.Constants;
import com.bytetobyte.xwallet.util.Iso8601Format;
import com.google.common.base.Charsets;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.core.DumpedPrivateKey;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.ScriptException;
import org.bitcoinj.core.Sha256Hash;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.core.TransactionInput;
import org.bitcoinj.core.TransactionOutput;
import org.bitcoinj.script.Script;
import org.bitcoinj.wallet.KeyChainGroup;
import org.bitcoinj.wallet.UnreadableWalletException;
import org.bitcoinj.wallet.Wallet;
import org.bitcoinj.wallet.WalletProtobufSerializer;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Writer;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import javax.annotation.Nullable;

    }

    public static Wallet restorePrivateKeysFromBase58(final InputStream is,
                                                      final NetworkParameters expectedNetworkParameters) throws IOException {
        final BufferedReader keyReader = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));

        // create non-HD wallet
        final KeyChainGroup group = new KeyChainGroup(expectedNetworkParameters);
        group.importKeys(WalletUtils.readKeys(keyReader, expectedNetworkParameters));
        return new Wallet(expectedNetworkParameters, group);
    }

    public static void writeKeys(final Writer out, final List<ECKey> keys) throws IOException {
        final DateFormat format = Iso8601Format.newDateTimeFormatT();

        out.write("# KEEP YOUR PRIVATE KEYS SAFE! Anyone who can read this can spend your Bitcoins.\n");

        for (final ECKey key : keys) {
            out.write(key.getPrivateKeyEncoded(Constants.NETWORK_PARAMETERS).toBase58());
            if (key.getCreationTimeSeconds() != 0) {
                out.write(' ');
                out.write(format.format(new Date(key.getCreationTimeSeconds() * DateUtils.SECOND_IN_MILLIS)));
            }
            out.write('\n');
        }
    }

    public static List<ECKey> readKeys(final BufferedReader in, final NetworkParameters expectedNetworkParameters)
            throws IOException {
        try {
            final DateFormat format = Iso8601Format.newDateTimeFormatT();