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);
}
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);
}
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);
}
Aggregations