当前位置: 首页>>代码示例>>Java>>正文


Java KeyChainGroup类代码示例

本文整理汇总了Java中org.bitcoinj.wallet.KeyChainGroup的典型用法代码示例。如果您正苦于以下问题:Java KeyChainGroup类的具体用法?Java KeyChainGroup怎么用?Java KeyChainGroup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


KeyChainGroup类属于org.bitcoinj.wallet包,在下文中一共展示了KeyChainGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: walletTest

import org.bitcoinj.wallet.KeyChainGroup; //导入依赖的package包/类
@Test
public void walletTest() throws Exception {
    NetworkParameters params = MainNetParams.get();
    Context.propagate(new Context(params));

    DumpedPrivateKey privKey = DumpedPrivateKey.fromBase58(params, "5Kg1gnAjaLfKiwhhPpGS3QfRg2m6awQvaj98JCZBZQ5SuS2F15C");

    Address addr = privKey.getKey().toAddress(params);
    assertTrue(addr.toString().equals("17Wx1GQfyPTNWpQMHrTwRSMTCAonSiZx9e"));

    KeyChainGroup group = new KeyChainGroup(params);
    // Add a random key which happens to have been used in a recent generation
    group.importKeys(ECKey.fromPublicOnly(privKey.getKey().getPubKeyPoint()), ECKey.fromPublicOnly(HEX.decode("03cb219f69f1b49468bd563239a86667e74a06fcba69ac50a08a5cbc42a5808e99")));
    Wallet wallet = new Wallet(params, group);
    wallet.commitTx(new Transaction(params, HEX.decode("01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0d038754030114062f503253482fffffffff01c05e559500000000232103cb219f69f1b49468bd563239a86667e74a06fcba69ac50a08a5cbc42a5808e99ac00000000")));
    
    // We should have 2 per pubkey, and one for the pay-2-pubkey output we have
    assertEquals(5, wallet.getBloomFilterElementCount());
    
    BloomFilter filter = wallet.getBloomFilter(wallet.getBloomFilterElementCount(), 0.001, 0);
    
    // Value generated by Bitcoin Core
    assertTrue(Arrays.equals(HEX.decode("082ae5edc8e51d4a03080000000000000002"), filter.unsafeBitcoinSerialize()));
}
 
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:25,代码来源:BloomFilterTest.java

示例2: setUp

import org.bitcoinj.wallet.KeyChainGroup; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    params = NetworkParameters.fromID(NetworkParameters.ID_UNITTESTNET);
    mapper = new ObjectMapper();

    DeterministicSeed seed = new DeterministicSeed("correct battery horse staple", null, "", 0);
    DeterministicKeyChain chain =
            DeterministicKeyChain.builder()
                    .seed(seed)
                    .build();
    KeyChainGroup group = new KeyChainGroup(params);
    group.addAndActivateHDChain(chain);
    wallet = new SmartWallet(params, group);
    wallet.setKeychainLookaheadSize(10);

    control = EasyMock.createStrictControl();
    client = control.createMock(StratumClient.class);
    expect(client.getConnectedAddresses()).andStubReturn(Lists.newArrayList(new InetSocketAddress(InetAddress.getLocalHost(), 0)));
    expect(client.getPeerVersion()).andStubReturn("1.0");
    store = control.createMock(HeadersStore.class);
    stratumChain = control.createMock(StratumChain.class);
    expect(stratumChain.getPeerHeight()).andStubReturn(100L);
    expect(store.get(340242)).andStubReturn(params.getGenesisBlock().cloneAsHeader());
    multiWallet = new ElectrumMultiWallet(wallet, BASE_DIRECTORY);
    multiWallet.start(client, stratumChain, store);
}
 
开发者ID:devrandom,项目名称:java-stratum,代码行数:27,代码来源:ElectrumMultiWalletTest.java

示例3: testMakeSigningKey

import org.bitcoinj.wallet.KeyChainGroup; //导入依赖的package包/类
@Test
public void testMakeSigningKey() throws Exception {

   // something to compare to
   KeyChainGroup keyChainTestGroup = new KeyChainGroup(bitcoinCryptoNoP.getParams());
  // KeyChainGroup keyChainMainGroup = new KeyChainGroup(bitcoinCryptoMain.getParams());

   // get one key to compare for each
   SigningKey signingKeyTest = bitcoinCryptoNoP.makeSigningKey();
  // SigningKey signingKeyMain = bitcoinCryptoMain.makeSigningKey();

   // compare
   assert (signingKeyTest instanceof SigningKey);
   // assert (signingKeyMain instanceof SigningKey);

}
 
开发者ID:DanielKrawisz,项目名称:Shufflepuff,代码行数:17,代码来源:BitcoinCryptoTest.java

示例4: walletTest

import org.bitcoinj.wallet.KeyChainGroup; //导入依赖的package包/类
@Test
public void walletTest() throws Exception {
    NetworkParameters params = MainNetParams.get();

    DumpedPrivateKey privKey = new DumpedPrivateKey(params, "5Kg1gnAjaLfKiwhhPpGS3QfRg2m6awQvaj98JCZBZQ5SuS2F15C");
    
    Address addr = privKey.getKey().toAddress(params);
    assertTrue(addr.toString().equals("17Wx1GQfyPTNWpQMHrTwRSMTCAonSiZx9e"));

    KeyChainGroup group = new KeyChainGroup(params);
    // Add a random key which happens to have been used in a recent generation
    group.importKeys(privKey.getKey(), ECKey.fromPublicOnly(HEX.decode("03cb219f69f1b49468bd563239a86667e74a06fcba69ac50a08a5cbc42a5808e99")));
    Wallet wallet = new Wallet(params, group);
    wallet.commitTx(new Transaction(params, HEX.decode("01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0d038754030114062f503253482fffffffff01c05e559500000000232103cb219f69f1b49468bd563239a86667e74a06fcba69ac50a08a5cbc42a5808e99ac00000000")));
    
    // We should have 2 per pubkey, and one for the pay-2-pubkey output we have
    assertEquals(5, wallet.getBloomFilterElementCount());
    
    BloomFilter filter = wallet.getBloomFilter(wallet.getBloomFilterElementCount(), 0.001, 0);
    
    // Value generated by the reference client
    assertTrue(Arrays.equals(HEX.decode("082ae5edc8e51d4a03080000000000000002"), filter.bitcoinSerialize()));
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:24,代码来源:BloomFilterTest.java

示例5: walletTest

import org.bitcoinj.wallet.KeyChainGroup; //导入依赖的package包/类
@Test
public void walletTest() throws Exception {
    NetworkParameters params = MainNetParams.get();
    Context.propagate(new Context(params));

    DumpedPrivateKey privKey = DumpedPrivateKey.fromBase58(params, "7qe1ZjCD5CPCb7ejQKhdVxaYFSQTKSFtM41qcx1Jx5bGa9cctsr");

    Address addr = privKey.getKey().toAddress(params);
    assertTrue(addr.toString().equals("XjQyaruHpygL6ephPqVPCjg83qzfnZ2Epf"));

    KeyChainGroup group = new KeyChainGroup(params);
    // Add a random key which happens to have been used in a recent generation
    group.importKeys(ECKey.fromPublicOnly(privKey.getKey().getPubKeyPoint()), ECKey.fromPublicOnly(HEX.decode("03cb219f69f1b49468bd563239a86667e74a06fcba69ac50a08a5cbc42a5808e99")));
    Wallet wallet = new Wallet(params, group);
    wallet.commitTx(new Transaction(params, HEX.decode("01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0d038754030114062f503253482fffffffff01c05e559500000000232103cb219f69f1b49468bd563239a86667e74a06fcba69ac50a08a5cbc42a5808e99ac00000000")));
    
    // We should have 2 per pubkey, and one for the pay-2-pubkey output we have
    assertEquals(5, wallet.getBloomFilterElementCount());
    
    BloomFilter filter = wallet.getBloomFilter(wallet.getBloomFilterElementCount(), 0.001, 0);
    
    // Value generated by Bitcoin Core
    assertTrue(Arrays.equals(HEX.decode("08a8e52498e51f0bc2080000000000000002"), filter.unsafeBitcoinSerialize()));
}
 
开发者ID:HashEngineering,项目名称:dashj,代码行数:25,代码来源:BloomFilterTest.java

示例6: restorePrivateKeysFromBase58

import org.bitcoinj.wallet.KeyChainGroup; //导入依赖的package包/类
public static Wallet restorePrivateKeysFromBase58(final InputStream is,
                                                  final NetworkParameters expectedNetworkParameters) throws IOException {
    final BufferedReader keyReader = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));

    // create non-HD wallet
    final KeyChainGroup group = new KeyChainGroup(expectedNetworkParameters);
    group.importKeys(WalletUtils.readKeys(keyReader, expectedNetworkParameters));
    return new Wallet(expectedNetworkParameters, group);
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:10,代码来源:WalletUtils.java

示例7: testWallet

import org.bitcoinj.wallet.KeyChainGroup; //导入依赖的package包/类
@Test
public void testWallet() throws UnreadableWalletException {
	long creationTimeSeconds = System.currentTimeMillis() / 1000;
	NetworkParameters params = MainNetParams.get();
	String [] MNEMONIC = new String [] {"sword","acquire","little","despair","wave","swear","during","expect","target","science","banana","eyebrow"};
	String RECEIVE_ADDRESS = "13w74gmmSjb2DWit5iRQbCKPZj89FkCidH";
	String CHANGE_ADDRESS = "1hF37FtrcSyEFkyxo2Q3541aGfWRqsuLV";
	
	List<String> fixedMnemonic = toMnemonic(MNEMONIC);
	printMnemonic(fixedMnemonic);
	
	DeterministicSeed ds2 = new DeterministicSeed(fixedMnemonic, null, "", creationTimeSeconds);
	
	KeyChainGroup fixedKeyChainFromSeed = new KeyChainGroup(params, ds2);
	Wallet fixedWallet = new Wallet(params, fixedKeyChainFromSeed);
	
	String fixedReceiveAddress = fixedWallet.currentReceiveAddress().toString();
	String fixedChangeAddress = fixedWallet.currentChangeAddress().toString();

	Assert.assertEquals(RECEIVE_ADDRESS, fixedReceiveAddress);
	Assert.assertEquals(CHANGE_ADDRESS, fixedChangeAddress);
	
	printAddress(fixedKeyChainFromSeed.currentAddress(KeyPurpose.AUTHENTICATION), "current auth address");
	printAddress(fixedKeyChainFromSeed.currentAddress(KeyPurpose.CHANGE), "current change address");
	printAddress(fixedKeyChainFromSeed.currentAddress(KeyPurpose.RECEIVE_FUNDS), "current receive address");
	printAddress(fixedKeyChainFromSeed.currentAddress(KeyPurpose.REFUND), "current refund address");
	
	for(int i = 0; i < 10; i++) {
		System.out.println("address[" + i + "]: "+ fixedKeyChainFromSeed.freshAddress(KeyPurpose.RECEIVE_FUNDS).toString());
	}
	
	System.out.println("---------------");
	
	String MNEMONIC_STRING = "sword acquire little despair wave swear during expect target science banana eyebrow";
	DeterministicSeed seed = new DeterministicSeed(MNEMONIC_STRING, null, "", creationTimeSeconds);
	Wallet wallet = Wallet.fromSeed(params, seed);
	
	System.out.println("wallet receive address: " + wallet.currentReceiveAddress().toString());
}
 
开发者ID:matthiaszimmermann,项目名称:bitcoin-paper-wallet,代码行数:40,代码来源:BitcoinjTest.java

示例8: askConfirmSweep

import org.bitcoinj.wallet.KeyChainGroup; //导入依赖的package包/类
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);
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:12,代码来源:SweepWalletFragment.java

示例9: restorePrivateKeysFromBase58

import org.bitcoinj.wallet.KeyChainGroup; //导入依赖的package包/类
public static Wallet restorePrivateKeysFromBase58(final InputStream is,
        final NetworkParameters expectedNetworkParameters) throws IOException {
    final BufferedReader keyReader = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));

    // create non-HD wallet
    final KeyChainGroup group = new KeyChainGroup(expectedNetworkParameters);
    group.importKeys(WalletUtils.readKeys(keyReader, expectedNetworkParameters));
    return new Wallet(expectedNetworkParameters, group);
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:10,代码来源:WalletUtils.java

示例10: sweepUtxo

import org.bitcoinj.wallet.KeyChainGroup; //导入依赖的package包/类
private String sweepUtxo(Map<Sha256Hash, Transaction> transactions) {
    final KeyChainGroup group = new KeyChainGroup(param);
    String ret = "";
    group.importKeys(ecKey);
    Wallet walletToSweep = new Wallet(param, group);

    walletToSweep.clearTransactions(0);
    for (final Transaction tx : transactions.values())
        walletToSweep.addWalletTransaction(new WalletTransaction(WalletTransaction.Pool.UNSPENT, tx));

    Coin dust = Transaction.MIN_NONDUST_OUTPUT;
    Coin balance = walletToSweep.getBalance();

    if (dust.isLessThan(balance.multiply(2))) {
        SendRequest sr = SendRequest.emptyWallet(Address.fromBase58(param, "mzM2i82Y9e4ZDwQVWqY4HcJbuAHYQdXd7A"));
        sr.feePerKb = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE;
        try {
            final Transaction transaction;
            transaction = walletToSweep.sendCoinsOffline(sr);
            ret = BaseEncoding.base16().lowerCase().encode(transaction.bitcoinSerialize());
        } catch (InsufficientMoneyException e) {
            e.printStackTrace();
        }
    } else {
        System.out.println("Too few coins in wallet: " + walletToSweep.getBalance().toFriendlyString());
    }
    return ret;
}
 
开发者ID:IUNO-TDM,项目名称:CouponGenerator,代码行数:29,代码来源:CouponRedemption.java

示例11: askConfirmSweep

import org.bitcoinj.wallet.KeyChainGroup; //导入依赖的package包/类
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);
}
 
开发者ID:soapboxsys,项目名称:ombuds-android,代码行数:13,代码来源:SweepWalletFragment.java

示例12: restorePrivateKeysFromBase58

import org.bitcoinj.wallet.KeyChainGroup; //导入依赖的package包/类
public static Wallet restorePrivateKeysFromBase58(final InputStream is, final NetworkParameters expectedNetworkParameters) throws IOException
{
    final BufferedReader keyReader = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));

    // create non-HD wallet
    final KeyChainGroup group = new KeyChainGroup(expectedNetworkParameters);
    group.importKeys(WalletUtils.readKeys(keyReader, expectedNetworkParameters));
    return new Wallet(expectedNetworkParameters, group);
}
 
开发者ID:soapboxsys,项目名称:ombuds-android,代码行数:10,代码来源:WalletUtils.java

示例13: BitcoinCrypto

import org.bitcoinj.wallet.KeyChainGroup; //导入依赖的package包/类
public BitcoinCrypto(NetworkParameters networkParameters) throws NoSuchAlgorithmException, Exception {
   this.params = NetworkParameters.fromID(networkParameters.getId());
   this.keyChainGroup = new KeyChainGroup(networkParameters);
   Security.insertProviderAt(new BouncyCastleProvider(), 1);
   crashIfJCEMissing();
   //this.sr = SecureRandom.getInstance("SHA1PRNG", new BouncyCastleProvider());
   this.sr = SecureRandom.getInstance("SHA1PRNG");
   this.keyPG = KeyPairGenerator.getInstance("ECIES", new BouncyCastleProvider());
   //this.kit = getKit();
   //this.wallet = getKit().wallet();

}
 
开发者ID:DanielKrawisz,项目名称:Shufflepuff,代码行数:13,代码来源:BitcoinCrypto.java

示例14: WalletProtobufSerializer

import org.bitcoinj.wallet.KeyChainGroup; //导入依赖的package包/类
public WalletProtobufSerializer() {
    this(new WalletFactory() {
        @Override
        public Wallet create(NetworkParameters params, KeyChainGroup keyChainGroup) {
            return new Wallet(params, keyChainGroup);
        }
    });
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:9,代码来源:WalletProtobufSerializer.java

示例15: MockWallet

import org.bitcoinj.wallet.KeyChainGroup; //导入依赖的package包/类
public MockWallet (NetworkParameters params, KeyChainGroup keyChainGroup) {
    super(params, keyChainGroup);
}
 
开发者ID:blockchain,项目名称:thunder,代码行数:4,代码来源:MockWallet.java


注:本文中的org.bitcoinj.wallet.KeyChainGroup类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。