/** Returns a testnet params modified to allow any difficulty target. */ @Deprecated public static NetworkParameters unitTests() { return UnitTestParams.get(); }
/** Returns a testnet params modified to allow any difficulty target. */ @Deprecated public static NetworkParameters unitTests() { return UnitTestParams.get(); }
/** Returns a testnet context modified to allow any difficulty target. */ @Deprecated public static NetworkParameters unitTests() { return UnitTestParams.get(); }
/** Returns a testnet params modified to allow any difficulty target. */ @Deprecated public static NetworkParameters unitTests() { return UnitTestParams.get(); }
/** Returns the network parameters for the given string ID or NULL if not recognized. */ @Nullable public static NetworkParameters fromID(String id) { if (id.equals(ID_MAINNET)) { return MainNetParams.get(); } else if (id.equals(ID_TESTNET)) { return TestNet3Params.get(); } else if (id.equals(ID_UNITTESTNET)) { return UnitTestParams.get(); } else if (id.equals(ID_REGTEST)) { return RegTestParams.get(); } else { return null; } }
/** Returns the network parameters for the given string ID or NULL if not recognized. */ @Nullable public static NetworkParameters fromID(String id) { if (id.equals(ID_MAINNET)) { return MainNetParams.get(); } else if (id.equals(ID_TESTNET)) { return TestNet3Params.get(); } else if (id.equals(ID_UNITTESTNET)) { return UnitTestParams.get(); } else if (id.equals(ID_REGTEST)) { return RegTestParams.get(); } else { return null; } }
/** Returns the network parameters for the given string paymentProtocolID or NULL if not recognized. */ @Nullable public static NetworkParameters fromPmtProtocolID(String pmtProtocolId) { if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_MAINNET)) { return MainNetParams.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_TESTNET)) { return TestNet3Params.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_UNIT_TESTS)) { return UnitTestParams.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_REGTEST)) { return RegTestParams.get(); } else { return null; } }
/** Returns the network parameters for the given string ID or NULL if not recognized. */ @Nullable public static NetworkParameters fromID(String id) { if (id.equals(ID_MAINNET)) { return MainNetParams.get(); } else if (id.equals(ID_TESTNET)) { return TestNet3Params.get(); } else if (id.equals(ID_UNITTESTNET)) { return UnitTestParams.get(); } else if (id.equals(ID_REGTEST)) { return RegTestParams.get(); } else { return null; } }
/** Returns the network parameters for the given string paymentProtocolID or NULL if not recognized. */ @Nullable public static NetworkParameters fromPmtProtocolID(String pmtProtocolId) { if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_MAINNET)) { return MainNetParams.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_TESTNET)) { return TestNet3Params.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_UNIT_TESTS)) { return UnitTestParams.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_REGTEST)) { return RegTestParams.get(); } else { return null; } }
/** Returns the network parameters for the given string paymentProtocolID or NULL if not recognized. */ @Nullable public static NetworkParameters fromPmtProtocolID(String pmtProtocolId) { if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_MAINNET)) { return MainNetParams.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_TESTNET)) { return TestNet3Params.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_UNIT_TESTS)) { return UnitTestParams.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_REGTEST)) { return RegTestParams.get(); } else { return null; } }
/** Returns the network parameters for the given string paymentProtocolID or NULL if not recognized. */ @Nullable public static NetworkParameters fromPmtProtocolID(String pmtProtocolId) { if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_MAINNET)) { return MainNetParams.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_TESTNET)) { return TestNet3Params.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_UNIT_TESTS)) { return UnitTestParams.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_REGTEST)) { return RegTestParams.get(); } else { return null; } }
/** Returns the network parameters for the given string ID or NULL if not recognized. */ @Nullable public static NetworkParameters fromID(String id) { if (id.equals(ID_MAINNET)) { return MainNetParams.get(); } else if (id.equals(ID_TESTNET)) { return TestNet3Params.get(); } else if (id.equals(ID_UNITTESTNET)) { return UnitTestParams.get(); } else if (id.equals(ID_REGTEST)) { return RegTestParams.get(); } else { return null; } }
public void setUp() throws Exception { setUp(new MemoryBlockStore(UnitTestParams.get())); }
@Test(expected = ProtocolException.class) public void readStrOfExtremeLength() throws Exception { NetworkParameters params = UnitTestParams.get(); VarInt length = new VarInt(Integer.MAX_VALUE); byte[] payload = length.encode(); new VarStrMessage(params, payload); }
@Test(expected = ProtocolException.class) public void readByteArrayOfExtremeLength() throws Exception { NetworkParameters params = UnitTestParams.get(); VarInt length = new VarInt(Integer.MAX_VALUE); byte[] payload = length.encode(); new VarBytesMessage(params, payload); }
@Test public void derive() throws Exception { ECKey key1 = chain.getKey(SimpleHDKeyChain.KeyPurpose.RECEIVE_FUNDS); ECKey key2 = chain.getKey(SimpleHDKeyChain.KeyPurpose.RECEIVE_FUNDS); final Address address = new Address(UnitTestParams.get(), "n1bQNoEx8uhmCzzA5JPG6sFdtsUQhwiQJV"); assertEquals(address, key1.toAddress(UnitTestParams.get())); assertEquals("mnHUcqUVvrfi5kAaXJDQzBb9HsWs78b42R", key2.toAddress(UnitTestParams.get()).toString()); assertEquals(key1, chain.findKeyFromPubHash(address.getHash160())); assertEquals(key2, chain.findKeyFromPubKey(key2.getPubKey())); key1.sign(Sha256Hash.ZERO_HASH); ECKey key3 = chain.getKey(SimpleHDKeyChain.KeyPurpose.CHANGE); assertEquals("mqumHgVDqNzuXNrszBmi7A2UpmwaPMx4HQ", key3.toAddress(UnitTestParams.get()).toString()); key3.sign(Sha256Hash.ZERO_HASH); }
@Test public void derive() throws Exception { ECKey key1 = chain.getKey(SimpleHDKeyChain.KeyPurpose.RECEIVE_FUNDS); ECKey key2 = chain.getKey(SimpleHDKeyChain.KeyPurpose.RECEIVE_FUNDS); final Address address = new Address(UnitTestParams.get(), "n1bQNoEx8uhmCzzA5JPG6sFdtsUQhwiQJV"); assertEquals(address, key1.toAddress(UnitTestParams.get())); assertEquals("mnHUcqUVvrfi5kAaXJDQzBb9HsWs78b42R", key2.toAddress(UnitTestParams.get()).toString()); assertEquals(key1, chain.findKeyFromPubHash(address.getHash160())); assertEquals(key2, chain.findKeyFromPubKey(key2.getPubKey())); key1.sign(Sha256Hash.ZERO_HASH); ECKey key3 = chain.getKey(SimpleHDKeyChain.KeyPurpose.CHANGE); assertEquals("mqumHgVDqNzuXNrszBmi7A2UpmwaPMx4HQ", key3.toAddress(UnitTestParams.get()).toString()); key3.sign(Sha256Hash.ZERO_HASH); }
@Test public void parentlessDeserialization() { NetworkParameters params = UnitTestParams.get(); DeterministicKey key1 = HDKeyDerivation.createMasterPrivateKey("satoshi lives!".getBytes()); DeterministicKey key2 = HDKeyDerivation.deriveChildKey(key1, ChildNumber.ZERO_HARDENED); DeterministicKey key3 = HDKeyDerivation.deriveChildKey(key2, ChildNumber.ZERO_HARDENED); DeterministicKey key4 = HDKeyDerivation.deriveChildKey(key3, ChildNumber.ZERO_HARDENED); assertEquals(key4.getPath().size(), 3); assertEquals(DeterministicKey.deserialize(params, key4.serializePrivate(params), key3).getPath().size(), 3); assertEquals(DeterministicKey.deserialize(params, key4.serializePrivate(params), null).getPath().size(), 1); assertEquals(DeterministicKey.deserialize(params, key4.serializePrivate(params)).getPath().size(), 1); }
@Test public void deriveAccountOne() throws Exception { long secs = 1389353062L; DeterministicKeyChain chain1 = new AccountOneChain(ENTROPY, "", secs); ECKey key1 = chain1.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS); ECKey key2 = chain1.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS); final Address address = Address.fromBase58(UnitTestParams.get(), "n2nHHRHs7TiZScTuVhZUkzZfTfVgGYwy6X"); assertEquals(address, key1.toAddress(UnitTestParams.get())); assertEquals("mnp2j9za5zMuz44vNxrJCXXhZsCdh89QXn", key2.toAddress(UnitTestParams.get()).toString()); assertEquals(key1, chain1.findKeyFromPubHash(address.getHash160())); assertEquals(key2, chain1.findKeyFromPubKey(key2.getPubKey())); key1.sign(Sha256Hash.ZERO_HASH); ECKey key3 = chain1.getKey(KeyChain.KeyPurpose.CHANGE); assertEquals("mpjRhk13rvV7vmnszcUQVYVQzy4HLTPTQU", key3.toAddress(UnitTestParams.get()).toString()); key3.sign(Sha256Hash.ZERO_HASH); }
@Test public void roundTripDumpedPrivKey() throws Exception { ECKey key = new ECKey(); assertTrue(key.isCompressed()); NetworkParameters params = UnitTestParams.get(); String base58 = key.getPrivateKeyEncoded(params).toString(); ECKey key2 = DumpedPrivateKey.fromBase58(params, base58).getKey(); assertTrue(key2.isCompressed()); assertTrue(Arrays.equals(key.getPrivKeyBytes(), key2.getPrivKeyBytes())); assertTrue(Arrays.equals(key.getPubKey(), key2.getPubKey())); }