Java Code Examples for org.bitcoinj.core.DumpedPrivateKey#fromBase58()
The following examples show how to use
org.bitcoinj.core.DumpedPrivateKey#fromBase58() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WalletManager.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
public void restoreFromBlock2(String mnemonicCode, Runnable callback) { if (mnemonicCode.charAt(mnemonicCode.length() - 1) == ' ') { mnemonicCode = mnemonicCode.substring(0, mnemonicCode.length() - 1); } DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, anyToWif(mnemonicCode)); ECKey key = dumpedPrivateKey.getKey(); wallet = new Wallet(params); wallet.importKey(key); mnemonicKey = mnemonicCode; sharedManager.setLastSyncedBlock(Coders.encodeBase64(mnemonicKey)); walletFriendlyAddress = wallet.getImportedKeys().get(0).toAddress(params).toBase58(); walletFriendlyAddress = testReadonlyAddress == null ? walletFriendlyAddress : testReadonlyAddress; callback.run(); RequestorBtc.getUTXOListKmdNew(walletFriendlyAddress, new ApiMethods.RequestListener() { @Override public void onSuccess(Object response) { List<UTXOItem> utxos = (List<UTXOItem>)response; setUTXO(utxos); } @Override public void onFailure(String msg) { } }); }
Example 2
Source File: WalletManager.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
public void restoreFromBlockByWif2(String wif, Runnable callback) { wif = wif.trim(); try { DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, wif); ECKey key = dumpedPrivateKey.getKey(); wallet = new Wallet(params); wallet.importKey(key); restFromWif = true; sharedManager.setLastSyncedBlock(Coders.encodeBase64(wif)); walletFriendlyAddress = wallet.getImportedKeys().get(0).toAddress(params).toString(); wifKey = wif; } catch (WrongNetworkException wne) { Log.e("psd", "restoreFromBlockByWif2: " + wne.toString()); callback.run(); return; } catch (IllegalArgumentException iae) { FirebaseCrash.report(iae); Log.e("psd", "restoreFromBlockByWif2: " + iae.toString()); callback.run(); return; } callback.run(); RequestorBtc.getUTXOListBch(walletFriendlyAddress, new ApiMethods.RequestListener() { @Override public void onSuccess(Object response) { List<UTXOItem> utxos = (List<UTXOItem>)response; setUTXO(utxos); } @Override public void onFailure(String msg) { } }); }
Example 3
Source File: WalletManager.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
public void restoreFromBlockByWif2(String wif, Runnable callback) { wif = wif.trim(); try { DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, wif); ECKey key = dumpedPrivateKey.getKey(); wallet = new Wallet(params); wallet.importKey(key); restFromWif = true; sharedManager.setLastSyncedBlock(Coders.encodeBase64(wif)); walletFriendlyAddress = wallet.getImportedKeys().get(0).toAddress(params).toString(); wifKey = wif; } catch (WrongNetworkException wne) { Log.e("psd", "restoreFromBlockByWif2: " + wne.toString()); callback.run(); return; } catch (IllegalArgumentException iae) { FirebaseCrash.report(iae); Log.e("psd", "restoreFromBlockByWif2: " + iae.toString()); callback.run(); return; } callback.run(); RequestorBtc.getUTXOListBtgNew(walletFriendlyAddress, new ApiMethods.RequestListener() { @Override public void onSuccess(Object response) { List<UTXOItem> utxos = (List<UTXOItem>)response; setUTXO(utxos); } @Override public void onFailure(String msg) { } }); }
Example 4
Source File: WalletManager.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
public void restoreFromBlockByWif(String wif, WalletCreationCallback callback) { wif = wif.trim(); try { DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, wif); ECKey key = dumpedPrivateKey.getKey(); wallet = new Wallet(params); wallet.importKey(key); restFromWif = true; walletFriendlyAddress = wallet.getImportedKeys().get(0).toAddress(params).toString(); wifKey = wif; } catch (IllegalArgumentException iae) { FirebaseCrash.report(iae); Log.e("psd", "restoreFromBlockByWif: " + iae.toString()); callback.onWalletCreated(wallet); return; } callback.onWalletCreated(wallet); RequestorBtc.getUTXOListBtgNew(walletFriendlyAddress, new ApiMethods.RequestListener() { @Override public void onSuccess(Object response) { List<UTXOItem> utxos = (List<UTXOItem>)response; setUTXO(utxos); } @Override public void onFailure(String msg) { } }); }
Example 5
Source File: WalletManager.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
public void restoreFromBlockByWif(String wif, WalletCreationCallback callback) { wif = wif.trim(); try { DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, wif); ECKey key = dumpedPrivateKey.getKey(); wallet = new Wallet(params); wallet.importKey(key); restFromWif = true; walletFriendlyAddress = wallet.getImportedKeys().get(0).toAddress(params).toString(); wifKey = wif; } catch (IllegalArgumentException iae) { FirebaseCrash.report(iae); Log.e("psd", "restoreFromBlockByWif: " + iae.toString()); callback.onWalletCreated(wallet); return; } callback.onWalletCreated(wallet); RequestorBtc.getUTXOList(walletFriendlyAddress, new ApiMethods.RequestListener() { @Override public void onSuccess(Object response) { UTXOListResponse utxoResponse = (UTXOListResponse) response; setUTXO(utxoResponse.getUTXOList()); } @Override public void onFailure(String msg) { } }); }
Example 6
Source File: WalletManager.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
public void restoreFromBlockByWif2(String wif, Runnable callback) { wif = wif.trim(); try { DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, wif); ECKey key = dumpedPrivateKey.getKey(); wallet = new Wallet(params); wallet.importKey(key); restFromWif = true; sharedManager.setLastSyncedBlock(Coders.encodeBase64(wif)); walletFriendlyAddress = wallet.getImportedKeys().get(0).toAddress(params).toString(); wifKey = wif; } catch (WrongNetworkException wne) { Log.e("psd", "restoreFromBlockByWif2: " + wne.toString()); callback.run(); return; } catch (IllegalArgumentException iae) { FirebaseCrash.report(iae); Log.e("psd", "restoreFromBlockByWif2: " + iae.toString()); callback.run(); return; } callback.run(); RequestorBtc.getUTXOListQtum(walletFriendlyAddress, new ApiMethods.RequestListener() { @Override public void onSuccess(Object response) { List<UTXOItem> utxos = (List<UTXOItem>)response; setUTXO(utxos); } @Override public void onFailure(String msg) { } }); }
Example 7
Source File: WalletManager.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
public void restoreFromBlockByWif(String wif, WalletCreationCallback callback) { wif = wif.trim(); try { DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, wif); ECKey key = dumpedPrivateKey.getKey(); wallet = new Wallet(params); wallet.importKey(key); restFromWif = true; walletFriendlyAddress = wallet.getImportedKeys().get(0).toAddress(params).toString(); wifKey = wif; } catch (IllegalArgumentException iae) { FirebaseCrash.report(iae); Log.e("psd", "restoreFromBlockByWif: " + iae.toString()); callback.onWalletCreated(wallet); return; } callback.onWalletCreated(wallet); RequestorBtc.getUTXOListQtum(walletFriendlyAddress, new ApiMethods.RequestListener() { @Override public void onSuccess(Object response) { List<UTXOItem> utxos = (List<UTXOItem>)response; setUTXO(utxos); } @Override public void onFailure(String msg) { } }); }
Example 8
Source File: WalletManager.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
public void restoreFromBlockByWif2(String wif, Runnable callback) { wif = wif.trim(); try { DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, wif); ECKey key = dumpedPrivateKey.getKey(); wallet = new Wallet(params); wallet.importKey(key); restFromWif = true; sharedManager.setLastSyncedBlock(Coders.encodeBase64(wif)); walletFriendlyAddress = wallet.getImportedKeys().get(0).toAddress(params).toString(); wifKey = wif; } catch (WrongNetworkException wne) { Log.e("psd", "restoreFromBlockByWif2: " + wne.toString()); callback.run(); return; } catch (IllegalArgumentException iae) { FirebaseCrash.report(iae); Log.e("psd", "restoreFromBlockByWif2: " + iae.toString()); callback.run(); return; } callback.run(); RequestorBtc.getUTXOListLtcNew(walletFriendlyAddress, new ApiMethods.RequestListener() { @Override public void onSuccess(Object response) { List<UTXOItem> utxos = (List<UTXOItem>)response; setUTXO(utxos); } @Override public void onFailure(String msg) { } }); }
Example 9
Source File: PrivateKey.java From evt4j with MIT License | 5 votes |
private PrivateKey(@NotNull String wif) throws WifFormatException { NetworkParameters networkParam = MainNetParams.get(); if (wif.length() != 51 && wif.length() != 52) { throw new WifFormatException("Wif length must be 51 or 52"); } try { DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(networkParam, wif); key = dumpedPrivateKey.getKey(); } catch (AddressFormatException ex) { throw new WifFormatException(ex.getMessage(), ex); } }
Example 10
Source File: WIFValidator.java From token-core-android with Apache License 2.0 | 5 votes |
@Override public String validate() { try { DumpedPrivateKey.fromBase58(network, wif); } catch (WrongNetworkException addressException) { throw new TokenException(Messages.WIF_WRONG_NETWORK); } catch (AddressFormatException addressFormatException) { throw new TokenException(Messages.WIF_INVALID); } if (requireCompressed && !DumpedPrivateKey.fromBase58(network, wif).getKey().isCompressed()) { throw new TokenException(Messages.SEGWIT_NEEDS_COMPRESS_PUBLIC_KEY); } return this.wif; }
Example 11
Source File: WalletManager.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
public void restoreFromBlock(String mnemonicCode, WalletCreationCallback callback) { mnemonicCode = mnemonicCode.trim(); if (mnemonicCode.equals("")) { callback.onWalletCreated(null); return; } DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, anyToWif(mnemonicCode)); ECKey key = dumpedPrivateKey.getKey(); wallet = new Wallet(params); wallet.importKey(key); mnemonicKey = mnemonicCode; // sharedManager.setLastSyncedBlock(Coders.encodeBase64(mnemonicKey)); walletFriendlyAddress = wallet.getImportedKeys().get(0).toAddress(params).toBase58(); walletFriendlyAddress = testReadonlyAddress == null ? walletFriendlyAddress : testReadonlyAddress; callback.onWalletCreated(wallet); RequestorBtc.getUTXOListKmdNew(walletFriendlyAddress, new ApiMethods.RequestListener() { @Override public void onSuccess(Object response) { List<UTXOItem> utxos = (List<UTXOItem>)response; setUTXO(utxos); } @Override public void onFailure(String msg) { } }); }
Example 12
Source File: WalletManager.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
public void createWallet2_wif(String passphrase, Runnable callback) { wallet = new Wallet(params); // DeterministicSeed seed = wallet.getKeyChainSeed(); // // mnemonicKey = Joiner.on(" ").join(seed.getMnemonicCode()); mnemonicKey = wallet.freshReceiveKey().getPrivateKeyAsWiF(params); sharedManager.setLastSyncedBlock(Coders.encodeBase64(mnemonicKey)); DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, mnemonicKey); ECKey key = dumpedPrivateKey.getKey(); wallet.importKey(key); walletFriendlyAddress = wallet.getImportedKeys().get(0).toAddress(params).toString(); walletFriendlyAddress = testReadonlyAddress == null ? walletFriendlyAddress : testReadonlyAddress; callback.run(); }
Example 13
Source File: WalletManager.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
public void restoreFromBlockByWif(String wif, WalletCreationCallback callback) { wif = wif.trim(); try { DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, wif); ECKey key = dumpedPrivateKey.getKey(); wallet = new Wallet(params); wallet.importKey(key); restFromWif = true; walletFriendlyAddress = wallet.getImportedKeys().get(0).toAddress(params).toString(); wifKey = wif; } catch (IllegalArgumentException iae) { FirebaseCrash.report(iae); Log.e("psd", "restoreFromBlockByWif: " + iae.toString()); callback.onWalletCreated(wallet); return; } callback.onWalletCreated(wallet); RequestorBtc.getUTXOListSbtcNew(walletFriendlyAddress, new ApiMethods.RequestListener() { @Override public void onSuccess(Object response) { try { List<UTXOItem> utxos = (List<UTXOItem>) response; setUTXO(utxos); } catch (ClassCastException cce) { Log.d("psd", "restoreFromBlockByWif - getUTXOList ClassCastException: " + cce.getMessage()); cce.printStackTrace(); } } @Override public void onFailure(String msg) { } }); }
Example 14
Source File: WalletManager.java From guarda-android-wallets with GNU General Public License v3.0 | 5 votes |
public void restoreFromBlockByWif(String wif, WalletCreationCallback callback) { wif = wif.trim(); try { DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, wif); ECKey key = dumpedPrivateKey.getKey(); wallet = new Wallet(params); wallet.importKey(key); restFromWif = true; walletFriendlyAddress = wallet.getImportedKeys().get(0).toAddress(params).toString(); wifKey = wif; } catch (IllegalArgumentException iae) { FirebaseCrash.report(iae); Log.e("psd", "restoreFromBlockByWif: " + iae.toString()); callback.onWalletCreated(wallet); return; } callback.onWalletCreated(wallet); RequestorBtc.getUTXOListDgbNew(walletFriendlyAddress, new ApiMethods.RequestListener() { @Override public void onSuccess(Object response) { List<UTXOItemDgb> utxos = (List<UTXOItemDgb>)response; setUTXO(utxos); } @Override public void onFailure(String msg) { } }); }
Example 15
Source File: BitcoinAddressCreator.java From token-core-android with Apache License 2.0 | 5 votes |
@Override public String fromPrivateKey(String prvKeyHex) { ECKey key; if (prvKeyHex.length() == 51 || prvKeyHex.length() == 52) { DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(networkParameters, prvKeyHex); key = dumpedPrivateKey.getKey(); } else { key = ECKey.fromPrivate(NumericUtil.hexToBytes(prvKeyHex)); } return key.toAddress(this.networkParameters).toBase58(); }
Example 16
Source File: SegWitBitcoinAddressCreator.java From token-core-android with Apache License 2.0 | 5 votes |
@Override public String fromPrivateKey(String prvKeyHex) { ECKey key; if (prvKeyHex.length() == 51 || prvKeyHex.length() == 52) { DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(networkParameters, prvKeyHex); key = dumpedPrivateKey.getKey(); if (!key.isCompressed()) { throw new TokenException(Messages.SEGWIT_NEEDS_COMPRESS_PUBLIC_KEY); } } else { key = ECKey.fromPrivate(NumericUtil.hexToBytes(prvKeyHex), true); } return calcSegWitAddress(key.getPubKeyHash()); }
Example 17
Source File: PrivateKey.java From balzac with Apache License 2.0 | 4 votes |
public static PrivateKey fromBase58(String wif) { DumpedPrivateKey key = DumpedPrivateKey.fromBase58(null, wif); return from(key.getKey().getPrivKeyBytes(), NetworkType.from(key.getParameters())); }
Example 18
Source File: WalletManager.java From guarda-android-wallets with GNU General Public License v3.0 | 4 votes |
public void restoreFromBlockByWif2(String wif, Runnable callback) { wif = wif.trim(); try { DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, wif); ECKey key = dumpedPrivateKey.getKey(); wallet = new Wallet(params); wallet.importKey(key); restFromWif = true; sharedManager.setLastSyncedBlock(Coders.encodeBase64(wif)); walletFriendlyAddress = wallet.getImportedKeys().get(0).toAddress(params).toString(); wifKey = wif; } catch (WrongNetworkException wne) { Log.e("psd", "restoreFromBlockByWif2: " + wne.toString()); callback.run(); return; } catch (IllegalArgumentException iae) { FirebaseCrash.report(iae); Log.e("psd", "restoreFromBlockByWif2: " + iae.toString()); callback.run(); return; } callback.run(); RequestorBtc.getUTXOListSbtcNew(walletFriendlyAddress, new ApiMethods.RequestListener() { @Override public void onSuccess(Object response) { try { List<UTXOItem> utxos = (List<UTXOItem>)response; setUTXO(utxos); } catch (ClassCastException cce) { Log.d("psd", "restoreFromBlockByWif2 - getUTXOList ClassCastException: " + cce.getMessage()); } } @Override public void onFailure(String msg) { } }); }
Example 19
Source File: WalletManager.java From guarda-android-wallets with GNU General Public License v3.0 | 4 votes |
public void restoreFromBlockByWif2(String wif, Runnable callback) { wif = wif.trim(); try { DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, wif); ECKey key = dumpedPrivateKey.getKey(); wallet = new Wallet(params); wallet.importKey(key); restFromWif = true; sharedManager.setLastSyncedBlock(Coders.encodeBase64(wif)); walletFriendlyAddress = wallet.getImportedKeys().get(0).toAddress(params).toString(); wifKey = wif; } catch (WrongNetworkException wne) { Log.e("psd", "restoreFromBlockByWif2: " + wne.toString()); callback.run(); return; } catch (AddressFormatException afe) { Log.e("psd", "restoreFromBlockByWif2: " + afe.toString()); callback.run(); return; } catch (IllegalArgumentException iae) { FirebaseCrash.report(iae); Log.e("psd", "restoreFromBlockByWif2: " + iae.toString()); callback.run(); return; } callback.run(); RequestorBtc.getUTXOListDgbNew(walletFriendlyAddress, new ApiMethods.RequestListener() { @Override public void onSuccess(Object response) { List<UTXOItemDgb> utxos = (List<UTXOItemDgb>)response; setUTXO(utxos); } @Override public void onFailure(String msg) { } }); }
Example 20
Source File: WalletManager.java From guarda-android-wallets with GNU General Public License v3.0 | 4 votes |
public void restoreFromBlockByWif2(String wif, Runnable callback) { wif = wif.trim(); try { DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, wif); ECKey key = dumpedPrivateKey.getKey(); wallet = new Wallet(params); wallet.importKey(key); restFromWif = true; sharedManager.setLastSyncedBlock(Coders.encodeBase64(wif)); walletFriendlyAddress = wallet.getImportedKeys().get(0).toAddress(params).toString(); wifKey = wif; } catch (WrongNetworkException wne) { FirebaseCrash.report(wne); Log.e("psd", "restoreFromBlockByWif2: " + wne.toString()); callback.run(); return; } catch (IllegalArgumentException iae) { FirebaseCrash.report(iae); Log.e("psd", "restoreFromBlockByWif2: " + iae.toString()); callback.run(); return; } catch (NullPointerException npe) { FirebaseCrash.report(npe); Log.e("psd", "restoreFromBlockByWif2: " + npe.toString()); callback.run(); return; } callback.run(); RequestorBtc.getUTXOList(walletFriendlyAddress, new ApiMethods.RequestListener() { @Override public void onSuccess(Object response) { UTXOListResponse utxoResponse = (UTXOListResponse) response; setUTXO(utxoResponse.getUTXOList()); } @Override public void onFailure(String msg) { } }); }