本文整理汇总了Java中org.bitcoinj.crypto.DeterministicHierarchy.get方法的典型用法代码示例。如果您正苦于以下问题:Java DeterministicHierarchy.get方法的具体用法?Java DeterministicHierarchy.get怎么用?Java DeterministicHierarchy.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bitcoinj.crypto.DeterministicHierarchy
的用法示例。
在下文中一共展示了DeterministicHierarchy.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUserExternalAddress
import org.bitcoinj.crypto.DeterministicHierarchy; //导入方法依赖的package包/类
public static Address getUserExternalAddress(final String pubKey, final NetworkParameters networkParameters,
final long userIndex) {
DeterministicKey deterministicKey = DeterministicKey.deserializeB58(pubKey, networkParameters);
DeterministicHierarchy deterministicHierarchy = new DeterministicHierarchy(deterministicKey);
List<ChildNumber> child = null;
if (deterministicKey.getDepth() == 2) {
/* M/44'/0' node tpub */
child = ImmutableList.of(new ChildNumber(0, false), new ChildNumber(1/*user*/, false),
new ChildNumber(0/*external*/, false), new ChildNumber((int)userIndex, false));
} else if (deterministicKey.getDepth() == 3) {
/* M/44'/0'/X context tpub */
child = ImmutableList.of(new ChildNumber(1/*user*/, false),
new ChildNumber(0/*external*/, false), new ChildNumber((int)userIndex, false));
}
DeterministicKey imprintingKey = deterministicHierarchy.get(child, true, true);
return imprintingKey.toAddress(networkParameters);
}
示例2: getUserInternalAddress
import org.bitcoinj.crypto.DeterministicHierarchy; //导入方法依赖的package包/类
public static Address getUserInternalAddress(final String pubKey, final NetworkParameters networkParameters,
final long userIndex) {
DeterministicKey deterministicKey = DeterministicKey.deserializeB58(pubKey, networkParameters);
DeterministicHierarchy deterministicHierarchy = new DeterministicHierarchy(deterministicKey);
List<ChildNumber> child = null;
if (deterministicKey.getDepth() == 2) {
/* M/44'/0' node tpub */
child = ImmutableList.of(new ChildNumber(0, false), new ChildNumber(1/*user*/, false),
new ChildNumber(1/*internal*/, false), new ChildNumber((int)userIndex, false));
} else if (deterministicKey.getDepth() == 3) {
/* M/44'/0'/X context tpub */
child = ImmutableList.of(new ChildNumber(1/*user*/, false),
new ChildNumber(1/*internal*/, false), new ChildNumber((int)userIndex, false));
}
DeterministicKey imprintingKey = deterministicHierarchy.get(child, true, true);
return imprintingKey.toAddress(networkParameters);
}
示例3: getProviderExternalAddress
import org.bitcoinj.crypto.DeterministicHierarchy; //导入方法依赖的package包/类
public static Address getProviderExternalAddress(final String pubKey, final NetworkParameters networkParameters,
final long providerIndex) {
DeterministicKey deterministicKey = DeterministicKey.deserializeB58(pubKey, networkParameters);
DeterministicHierarchy deterministicHierarchy = new DeterministicHierarchy(deterministicKey);
List<ChildNumber> child = null;
if (deterministicKey.getDepth() == 2) {
/* M/44'/0' node tpub */
child = ImmutableList.of(new ChildNumber(0, false), new ChildNumber(0/*provider*/, false),
new ChildNumber(/*external*/0, false), new ChildNumber((int)providerIndex, false));
} else if (deterministicKey.getDepth() == 3) {
/* M/44'/0'/X context tpub */
child = ImmutableList.of(new ChildNumber(0/*provider*/, false),
new ChildNumber(/*external*/0, false), new ChildNumber((int)providerIndex, false));
}
DeterministicKey imprintingKey = deterministicHierarchy.get(child, true, true);
return imprintingKey.toAddress(networkParameters);
}
示例4: getProviderInternalAddress
import org.bitcoinj.crypto.DeterministicHierarchy; //导入方法依赖的package包/类
public static Address getProviderInternalAddress(final String pubKey, final NetworkParameters networkParameters,
final long providerIndex) {
DeterministicKey deterministicKey = DeterministicKey.deserializeB58(pubKey, networkParameters);
DeterministicHierarchy deterministicHierarchy = new DeterministicHierarchy(deterministicKey);
List<ChildNumber> child = null;
if (deterministicKey.getDepth() == 2) {
/* M/44'/0' node tpub */
child = ImmutableList.of(new ChildNumber(0, false), new ChildNumber(0/*provider*/, false),
new ChildNumber(1/*internal*/, false), new ChildNumber((int)providerIndex, false));
} else if (deterministicKey.getDepth() == 3) {
/* M/44'/0'/X context tpub */
child = ImmutableList.of(new ChildNumber(0/*provider*/, false),
new ChildNumber(1/*internal*/, false), new ChildNumber((int)providerIndex, false));
}
DeterministicKey imprintingKey = deterministicHierarchy.get(child, true, true);
return imprintingKey.toAddress(networkParameters);
}
示例5: deriveCoin
import org.bitcoinj.crypto.DeterministicHierarchy; //导入方法依赖的package包/类
@Test
public void deriveCoin() throws Exception {
DeterministicHierarchy hierarchy = new DeterministicHierarchy(masterKey);
DeterministicKey rootKey = hierarchy.get(BitcoinMain.get().getBip44Path(0), false, true);
chain = new SimpleHDKeyChain(rootKey);
ECKey key1 = chain.getKey(SimpleHDKeyChain.KeyPurpose.RECEIVE_FUNDS);
ECKey key2 = chain.getKey(SimpleHDKeyChain.KeyPurpose.RECEIVE_FUNDS);
final Address address = new Address(BitcoinMain.get(), "1Fp7CA7ZVqZNFVNQ9TpeqWUas7K28K9zig");
assertEquals(address, key1.toAddress(BitcoinMain.get()));
assertEquals("1AKqkQM4VqyVis6hscj8695WHPCCzgHNY3", key2.toAddress(BitcoinMain.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("18YvGiRqXKxrzB72ckfrRSizWeHgwRP94V", key3.toAddress(BitcoinMain.get()).toString());
key3.sign(Sha256Hash.ZERO_HASH);
ECKey key4 = chain.getKey(SimpleHDKeyChain.KeyPurpose.CHANGE);
assertEquals("1861TX2MbyPEUrxDQVWgV4Tp9991bK1zpy", key4.toAddress(BitcoinMain.get()).toString());
key4.sign(Sha256Hash.ZERO_HASH);
}
示例6: testHDAccountNxt
import org.bitcoinj.crypto.DeterministicHierarchy; //导入方法依赖的package包/类
@Test
public void testHDAccountNxt() throws MnemonicException, UnreadableWalletException {
DeterministicSeed seed = new DeterministicSeed(recoveryPhrase, null, "", 0);
DeterministicKey masterKey = HDKeyDerivation.createMasterPrivateKey(seed.getSeedBytes());
DeterministicHierarchy hierarchy = new DeterministicHierarchy(masterKey);
DeterministicKey entropy = hierarchy.get(NxtMain.get().getBip44Path(0), false, true);
NxtFamilyKey nxtKey = new NxtFamilyKey(entropy, null, null);
byte[] privateKey = nxtKey.getPrivateKey();
byte[] publicKey = nxtKey.getPublicKey();
NxtAddress address = new NxtAddress(NxtMain.get(), publicKey);
assertArrayEquals(nxtPrivateKey, privateKey);
assertArrayEquals(nxtPublicKey, publicKey);
assertEquals(nxtRsAddress, address.toString());
assertEquals(nxtAccountId, address.getAccountId());
}
示例7: getMasterKey
import org.bitcoinj.crypto.DeterministicHierarchy; //导入方法依赖的package包/类
/**
* Call to get the MasterKey for a new Channel.
* TODO: Change to request master node key..
*
* @param number Query the Database to get the latest unused number
* @return DeterministicKey for the new Channel
*/
public static DeterministicKey getMasterKey (int number) {
DeterministicKey hd = DeterministicKey.deserializeB58(SideConstants.KEY_B58, Constants.getNetwork());
// DeterministicKey hd = DeterministicKey.deserializeB58(null,KEY_B58);
// DeterministicKey hd = HDKeyDerivation.createMasterPrivateKey(KEY.getBytes());
DeterministicHierarchy hi = new DeterministicHierarchy(hd);
List<ChildNumber> childList = new ArrayList<ChildNumber>();
ChildNumber childNumber = new ChildNumber(number, true);
childList.add(childNumber);
DeterministicKey key = hi.get(childList, true, true);
return key;
}
示例8: initializeHierarchyUnencrypted
import org.bitcoinj.crypto.DeterministicHierarchy; //导入方法依赖的package包/类
private void initializeHierarchyUnencrypted(DeterministicKey baseKey) {
rootKey = baseKey;
addToBasicChain(rootKey);
hierarchy = new DeterministicHierarchy(rootKey);
externalKey = hierarchy.get(EXTERNAL_PATH, true, true);
internalKey = hierarchy.get(INTERNAL_PATH, true, true);
addToBasicChain(externalKey);
addToBasicChain(internalKey);
}
示例9: setup
import org.bitcoinj.crypto.DeterministicHierarchy; //导入方法依赖的package包/类
@Before
public void setup() {
BriefLogFormatter.init();
DeterministicSeed seed = new DeterministicSeed(ENTROPY, "", 0);
masterKey = HDKeyDerivation.createMasterPrivateKey(seed.getSeedBytes());
DeterministicHierarchy hierarchy = new DeterministicHierarchy(masterKey);
DeterministicKey rootKey = hierarchy.get(ImmutableList.of(ChildNumber.ZERO_HARDENED), false, true);
chain = new SimpleHDKeyChain(rootKey);
chain.setLookaheadSize(10);
}
示例10: serializeUnencryptedChildRoot
import org.bitcoinj.crypto.DeterministicHierarchy; //导入方法依赖的package包/类
@Test
public void serializeUnencryptedChildRoot() throws UnreadableWalletException {
DeterministicHierarchy hierarchy = new DeterministicHierarchy(masterKey);
DeterministicKey rootKey = hierarchy.get(BitcoinTest.get().getBip44Path(0), false, true);
SimpleHDKeyChain newChain = new SimpleHDKeyChain(rootKey);
serializeUnencrypted(newChain, DETERMINISTIC_WALLET_SERIALIZATION_TXT_CHILD_ROOT_KEY);
}
示例11: encryptionChildRoot
import org.bitcoinj.crypto.DeterministicHierarchy; //导入方法依赖的package包/类
@Test
public void encryptionChildRoot() throws UnreadableWalletException {
DeterministicHierarchy hierarchy = new DeterministicHierarchy(masterKey);
DeterministicKey rootKey = hierarchy.get(BitcoinTest.get().getBip44Path(0), false, true);
SimpleHDKeyChain newChain = new SimpleHDKeyChain(rootKey);
encryption(newChain);
}
示例12: setup
import org.bitcoinj.crypto.DeterministicHierarchy; //导入方法依赖的package包/类
@Before
public void setup() throws MnemonicException, UnreadableWalletException {
DeterministicSeed seed = new DeterministicSeed(recoveryPhrase, null, "", 0);
DeterministicKey masterKey = HDKeyDerivation.createMasterPrivateKey(seed.getSeedBytes());
hierarchy = new DeterministicHierarchy(masterKey);
wallet = new Wallet(recoveryPhrase);
nxtAccount = (NxtFamilyWallet)wallet.createAccount(NXT, null);
otherAccount = new NxtFamilyWallet(hierarchy.get(NXT.getBip44Path(1), false, true), NXT);
}
示例13: calculateImprintAddress
import org.bitcoinj.crypto.DeterministicHierarchy; //导入方法依赖的package包/类
/**
* Calculates the imprint address from a node's deterministic key
*
* @param deterministicKey the node's deterministicKey key
* @param networkParameters the network parameters to use
* @return the imprint address of the node
*/
public static Address calculateImprintAddress(final DeterministicKey deterministicKey, final NetworkParameters networkParameters) {
final DeterministicHierarchy deterministicHierarchy = new DeterministicHierarchy(deterministicKey);
List<ChildNumber> imprintingChild = null;
if (deterministicKey.getDepth() == 2) {
/* M/44'/0' node tpub */
imprintingChild = ImmutableList.of(new ChildNumber(0, false), new ChildNumber(0, false),
new ChildNumber(0, false), new ChildNumber(0, false));
} else if (deterministicKey.getDepth() == 3) {
/* M/44'/0'/X context tpub */
imprintingChild = ImmutableList.of(new ChildNumber(0, false), new ChildNumber(0, false),
new ChildNumber(0, false));
}
DeterministicKey imprintingKey = deterministicHierarchy.get(imprintingChild, true, true);
return imprintingKey.toAddress(networkParameters);
}
示例14: testSendingAndBalances
import org.bitcoinj.crypto.DeterministicHierarchy; //导入方法依赖的package包/类
@Test
public void testSendingAndBalances() throws Exception {
DeterministicHierarchy h = new DeterministicHierarchy(masterKey);
WalletPocketHD account1 = new WalletPocketHD(h.get(BTC.getBip44Path(0), false, true), BTC, null, null);
WalletPocketHD account2 = new WalletPocketHD(h.get(BTC.getBip44Path(1), false, true), BTC, null, null);
WalletPocketHD account3 = new WalletPocketHD(h.get(BTC.getBip44Path(2), false, true), BTC, null, null);
Transaction tx = new Transaction(BTC);
tx.addOutput(BTC.oneCoin().toCoin(), account1.getReceiveAddress());
tx.getConfidence().setSource(Source.SELF);
account1.addNewTransactionIfNeeded(tx);
assertEquals(BTC.value("1"), account1.getBalance());
assertEquals(BTC.value("0"), account2.getBalance());
assertEquals(BTC.value("0"), account3.getBalance());
Sha256Hash txId = send(BTC.value("0.05"), account1, account2);
assertEquals(BTC.value("0.94"), account1.getBalance());
assertEquals(BTC.value("0"), account2.getBalance());
assertEquals(BTC.value("0"), account3.getBalance());
setTrustedTransaction(account1, txId);
setTrustedTransaction(account2, txId);
assertEquals(BTC.value("0.94"), account1.getBalance());
assertEquals(BTC.value("0.05"), account2.getBalance());
txId = send(BTC.value("0.07"), account1, account3);
setTrustedTransaction(account1, txId);
setTrustedTransaction(account3, txId);
assertEquals(BTC.value("0.86"), account1.getBalance());
assertEquals(BTC.value("0.05"), account2.getBalance());
assertEquals(BTC.value("0.07"), account3.getBalance());
txId = send(BTC.value("0.03"), account2, account3);
setTrustedTransaction(account2, txId);
setTrustedTransaction(account3, txId);
assertEquals(BTC.value("0.86"), account1.getBalance());
assertEquals(BTC.value("0.01"), account2.getBalance());
assertEquals(BTC.value("0.1"), account3.getBalance());
}
示例15: deriveXpub
import org.bitcoinj.crypto.DeterministicHierarchy; //导入方法依赖的package包/类
private static final String deriveXpub(NetworkParameters networkParameters, DeterministicSeed detSeed) {
DeterministicKey deterministicKey = NodeUtils.createDeterministicKeyFromDeterministicSeed(detSeed);
DeterministicHierarchy deterministicHierarchy = new DeterministicHierarchy(deterministicKey);
ImmutableList<ChildNumber> IMPRINTING_PATH = ImmutableList.of(new ChildNumber(44, true),
new ChildNumber(0, true));
DeterministicKey imprintingKey = deterministicHierarchy.get(IMPRINTING_PATH, true, true);
return imprintingKey.serializePubB58(networkParameters);
}