use of org.bitcoinj.core.NetworkParameters in project cryptoputty by alokmenghrajani.
the class CryptoputtyApplication method initialize.
@Override
public void initialize(final Bootstrap<CryptoputtyConfiguration> bootstrap) {
bootstrap.addBundle(new ViewBundle<>());
NetworkParameters params = TestNet3Params.get();
File tempDir = Files.createTempDir();
tempDir.deleteOnExit();
kit = new WalletAppKit(params, tempDir, "cryptoputty");
try {
kit.restoreWalletFromSeed(new DeterministicSeed("office suit release flame robust know depth truly swim bird quality reopen", null, "", 1522261414L));
kit.setBlockingStartup(false);
kit.setAutoSave(true);
kit.startAsync();
kit.awaitRunning();
// Perhaps having bloom filters doesn't hurt since we don't plan to do anything
// kit.peerGroup().setBloomFilteringEnabled(false);
// I have no idea what I'm doing, but let's increase these max values.
kit.peerGroup().setMaxPeersToDiscoverCount(10000);
kit.peerGroup().setMaxConnections(5000);
log.info(format("send money to: %s", kit.wallet().freshReceiveAddress().toString()));
log.info("done initializing");
} catch (UnreadableWalletException e) {
e.printStackTrace();
}
}
use of org.bitcoinj.core.NetworkParameters in project sentinel-android by Samourai-Wallet.
the class HD_WalletFactory method restoreWallet.
public HD_Wallet restoreWallet(String data, String passphrase, int nbAccounts) throws AddressFormatException, DecoderException {
HD_Wallet hdw = null;
if (passphrase == null) {
passphrase = "";
}
NetworkParameters params = MainNetParams.get();
if (data.startsWith("xpub") || data.startsWith("ypub")) {
String[] xpub = data.split(":");
// Log.i("HD_WalletFactory", "xpubs:" + xpub.length);
hdw = new HD_Wallet(params, xpub);
}
if (hdw == null) {
PrefsUtil.getInstance(context).clear();
return null;
}
wallets.clear();
wallets.add(hdw);
return hdw;
}
use of org.bitcoinj.core.NetworkParameters in project catena-java by alinush.
the class WrongPkTest method testWrongPk.
/**
* Couldn't make this test work initially, not easily at least. Because the root-of-trust TXN is not saved in the wallet
* when the wallet is initialized with the wrong PK, since the TXN doesn't transfer any funds and seems irrelevant
* to the wallet. As a result, processRootOfTrustTxn fails because there's no TXN in the wallet. So we had to call
* processRootOfTrustTxn manually here.
*
* @throws InsufficientMoneyException
* @throws IOException
* @throws InterruptedException
* @throws TimeoutException
*/
@Test
public void testWrongPk() throws InsufficientMoneyException, IOException, InterruptedException, TimeoutException {
log.info("Test: Fail if the chain PK in the root-of-trust TX differs from the expected one");
// Replace the expected chain PK with a random one.
ECKey key = new ECKey();
super.expectedChainAddr = key.toAddress(params);
// The Catena client should stop when it encounters a different PK in the root-of-trust TX
final Semaphore sem = new Semaphore(0);
walletFactory = new WalletFactory() {
@Override
public Wallet create(NetworkParameters params, KeyChainGroup keyChainGroup) {
log.info("Creating custom wallet that whistleblows on a wrong chain address...");
ClientWallet wallet = new ClientWallet.Factory().create(params, keyChainGroup);
wallet.addWhistleblowListener(new CatenaWhistleblowListener() {
@Override
public void onWhistleblow(Transaction tx, String message) {
log.info("Whistleblowing for tx {}: {}", tx.getHash(), message);
sem.release();
catenaClient.stopAsync();
}
});
return wallet;
}
};
createCatenaClient(txid, false);
catenaClient.startAsync();
catenaClient.awaitRunning();
// We are cheating here: We're feeding the Catena server-created root-of-trust TXN to the Catena client manually
catenaClient.getCatenaWallet().processRootOfTrustTxn(rootOfTrustTxn);
Assert.assertTrue("Catena client should have whistleblown due to wrong PK", sem.tryAcquire(5, TimeUnit.SECONDS));
catenaClient.stopAsync();
catenaClient.awaitTerminated(3, TimeUnit.SECONDS);
Assert.assertTrue(catenaClient.state() == State.TERMINATED);
}
use of org.bitcoinj.core.NetworkParameters in project Bitcoin-Brainwallet-PasswordCrackPlatform by Dimou-John.
the class AddressGenerator method AddressGenerator.
public static String AddressGenerator(String rest) throws IOException {
NetworkParameters mainNet = MainNetParams.get();
String newline = rest;
rest = getSha256(rest);
BigInteger big = new BigInteger(rest, 16);
// uncompressed
ECKey key = ECKey.fromPrivate(big, false);
byte[] priv = key.getPrivKeyBytes();
byte[] bytes = new byte[1 + 32 + 4];
bytes[0] = (byte) 0x80;
System.arraycopy(priv, 0, bytes, 1, 32);
byte[] checksum = Sha256Hash.hashTwice(bytes, 0, 33);
System.arraycopy(checksum, 0, bytes, 33, 4);
String wif3 = Base58.encode(bytes);
Address s = key.toAddress(mainNet);
String Stringed = s.toString();
return Stringed;
}
use of org.bitcoinj.core.NetworkParameters in project Bitcoin-Brainwallet-PasswordCrackPlatform by Dimou-John.
the class PrivateKeyGetter method PrivateKeyGetter.
public static String PrivateKeyGetter(String rest) throws IOException {
NetworkParameters mainNet = MainNetParams.get();
rest = getSha256(rest);
BigInteger big = new BigInteger(rest, 16);
// uncompressed
ECKey key = ECKey.fromPrivate(big, false);
byte[] priv = key.getPrivKeyBytes();
byte[] bytes = new byte[1 + 32 + 4];
bytes[0] = (byte) 0x80;
System.arraycopy(priv, 0, bytes, 1, 32);
byte[] checksum = Sha256Hash.hashTwice(bytes, 0, 33);
System.arraycopy(checksum, 0, bytes, 33, 4);
String wif3 = Base58.encode(bytes);
Address s = key.toAddress(mainNet);
String Stringed = s.toString();
return wif3;
}
Aggregations