Search in sources :

Example 6 with Wallet

use of org.bitcoinj.wallet.Wallet in project bitcoin-wallet by bitcoin-wallet.

the class SweepWalletFragment method askConfirmSweep.

private void askConfirmSweep(final ECKey key) {
    // create non-HD wallet
    final KeyChainGroup group = new KeyChainGroup(Constants.NETWORK_PARAMETERS);
    group.importKeys(key);
    walletToSweep = new Wallet(Constants.NETWORK_PARAMETERS, group);
    setState(State.CONFIRM_SWEEP);
    // delay until fragment is resumed
    handler.post(requestWalletBalanceRunnable);
}
Also used : Wallet(org.bitcoinj.wallet.Wallet) KeyChainGroup(org.bitcoinj.wallet.KeyChainGroup)

Example 7 with Wallet

use of org.bitcoinj.wallet.Wallet in project bitcoin-wallet by bitcoin-wallet.

the class WalletUtils method restorePrivateKeysFromBase58.

public static Wallet restorePrivateKeysFromBase58(final InputStream is, final NetworkParameters expectedNetworkParameters) throws IOException {
    final BufferedReader keyReader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
    // create non-HD wallet
    final KeyChainGroup group = new KeyChainGroup(expectedNetworkParameters);
    group.importKeys(WalletUtils.readKeys(keyReader, expectedNetworkParameters));
    return new Wallet(expectedNetworkParameters, group);
}
Also used : InputStreamReader(java.io.InputStreamReader) Wallet(org.bitcoinj.wallet.Wallet) KeyChainGroup(org.bitcoinj.wallet.KeyChainGroup) BufferedReader(java.io.BufferedReader)

Example 8 with Wallet

use of org.bitcoinj.wallet.Wallet in project bitcoin-wallet by bitcoin-wallet.

the class ReportIssueDialogFragment method appendApplicationInfo.

private static void appendApplicationInfo(final Appendable report, final WalletApplication application) throws IOException {
    final PackageInfo pi = application.packageInfo();
    final Configuration configuration = application.getConfiguration();
    final Calendar calendar = new GregorianCalendar(UTC);
    report.append("Version: " + pi.versionName + " (" + pi.versionCode + ")\n");
    report.append("Package: " + pi.packageName + "\n");
    report.append("Installer: " + application.getPackageManager().getInstallerPackageName(pi.packageName) + "\n");
    report.append("Test/Prod: " + (Constants.TEST ? "test" : "prod") + "\n");
    report.append("Timezone: " + TimeZone.getDefault().getID() + "\n");
    calendar.setTimeInMillis(System.currentTimeMillis());
    report.append("Time: " + String.format(Locale.US, "%tF %tT %tZ", calendar, calendar, calendar) + "\n");
    calendar.setTimeInMillis(WalletApplication.TIME_CREATE_APPLICATION);
    report.append("Time of launch: " + String.format(Locale.US, "%tF %tT %tZ", calendar, calendar, calendar) + "\n");
    calendar.setTimeInMillis(pi.lastUpdateTime);
    report.append("Time of last update: " + String.format(Locale.US, "%tF %tT %tZ", calendar, calendar, calendar) + "\n");
    calendar.setTimeInMillis(pi.firstInstallTime);
    report.append("Time of first install: " + String.format(Locale.US, "%tF %tT %tZ", calendar, calendar, calendar) + "\n");
    final long lastBackupTime = configuration.getLastBackupTime();
    calendar.setTimeInMillis(lastBackupTime);
    report.append("Time of backup: " + (lastBackupTime > 0 ? String.format(Locale.US, "%tF %tT %tZ", calendar, calendar, calendar) : "none") + "\n");
    report.append("Network: " + Constants.NETWORK_PARAMETERS.getId() + "\n");
    final Wallet wallet = application.getWallet();
    report.append("Encrypted: " + wallet.isEncrypted() + "\n");
    report.append("Keychain size: " + wallet.getKeyChainGroupSize() + "\n");
    final Set<Transaction> transactions = wallet.getTransactions(true);
    int numInputs = 0;
    int numOutputs = 0;
    int numSpentOutputs = 0;
    for (final Transaction tx : transactions) {
        numInputs += tx.getInputs().size();
        final List<TransactionOutput> outputs = tx.getOutputs();
        numOutputs += outputs.size();
        for (final TransactionOutput txout : outputs) {
            if (!txout.isAvailableForSpending())
                numSpentOutputs++;
        }
    }
    report.append("Transactions: " + transactions.size() + "\n");
    report.append("Inputs: " + numInputs + "\n");
    report.append("Outputs: " + numOutputs + " (spent: " + numSpentOutputs + ")\n");
    report.append("Last block seen: " + wallet.getLastBlockSeenHeight() + " (" + wallet.getLastBlockSeenHash() + ")\n");
    report.append("Databases:");
    for (final String db : application.databaseList()) report.append(" " + db);
    report.append("\n");
    final File filesDir = application.getFilesDir();
    report.append("\nContents of FilesDir " + filesDir + ":\n");
    appendDir(report, filesDir, 0);
}
Also used : TransactionOutput(org.bitcoinj.core.TransactionOutput) Configuration(de.schildbach.wallet.Configuration) PackageInfo(android.content.pm.PackageInfo) Wallet(org.bitcoinj.wallet.Wallet) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) Transaction(org.bitcoinj.core.Transaction) File(java.io.File)

Aggregations

Wallet (org.bitcoinj.wallet.Wallet)8 IOException (java.io.IOException)4 Stopwatch (com.google.common.base.Stopwatch)3 WalletProtobufSerializer (org.bitcoinj.wallet.WalletProtobufSerializer)3 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 KeyChainGroup (org.bitcoinj.wallet.KeyChainGroup)2 UnreadableWalletException (org.bitcoinj.wallet.UnreadableWalletException)2 IntentFilter (android.content.IntentFilter)1 PackageInfo (android.content.pm.PackageInfo)1 PowerManager (android.os.PowerManager)1 Configuration (de.schildbach.wallet.Configuration)1 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 OutputStream (java.io.OutputStream)1 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1 BlockChain (org.bitcoinj.core.BlockChain)1 Transaction (org.bitcoinj.core.Transaction)1