hello everyone, I Have a backend service this sync wallets whit cron, today 
I try to update dependency to 0.15.1 all fine but the sync not found when 
use Wallet.creeateBasic, the wallet alwais show 0 BTC, but if use new 
Wallet this work fine and show the balance

I need this to sync over 100 wallets simultaneously,

Create Basic

@Test
public void SyncBasicWallet0151() throws Exception {

    Context.propagate(new Context(netParams));

    File chainFileSeed = new File("seed.spvchain");
    File chainFile = new File(System.currentTimeMillis() + ".spvchain");
    byte[] allBytes = Files.readAllBytes(chainFileSeed.toPath());
    Files.write(chainFile.toPath(), allBytes);

    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.MONTH, -1);
    Date time = calendar.getTime();

    ECKey ecKey = DumpedPrivateKey.fromBase58(netParams, 
privateKeyAsWiF).getKey();
    ecKey.setCreationTimeSeconds(time.getTime() / 1000);
    Wallet wallet = Wallet.createBasic(netParams);
    wallet.importKey(ecKey);

    BlockStore blockStore = new SPVBlockStore(netParams, chainFile);
    BlockChain chain = new BlockChain(netParams, blockStore);
    final PeerGroup peerGroup = new PeerGroup(netParams, chain);

    //peerGroup.setBloomFilteringEnabled(false);

    peerGroup.addPeerDiscovery(new DnsDiscovery(netParams));
    peerGroup.setFastCatchupTimeSecs(time.getTime());

    peerGroup.addWallet(wallet);
    chain.addWallet(wallet);

    peerGroup.start();
    peerGroup.downloadBlockChain();
    peerGroup.stop();

    chainFile.delete();

    System.out.println(wallet);
    wallet.cleanup();
}


The output


using New Wallet

@Test
public void SyncBasicWallet0151() throws Exception {

    Context.propagate(new Context(netParams));

    File chainFileSeed = new File("seed.spvchain");
    File chainFile = new File(System.currentTimeMillis() + ".spvchain");
    byte[] allBytes = Files.readAllBytes(chainFileSeed.toPath());
    Files.write(chainFile.toPath(), allBytes);

    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.MONTH, -1);
    Date time = calendar.getTime();

    ECKey ecKey = DumpedPrivateKey.fromBase58(netParams, 
privateKeyAsWiF).getKey();
    ecKey.setCreationTimeSeconds(time.getTime() / 1000);
    Wallet wallet = new Wallet(netParams);
    wallet.importKey(ecKey);

    BlockStore blockStore = new SPVBlockStore(netParams, chainFile);
    BlockChain chain = new BlockChain(netParams, blockStore);
    final PeerGroup peerGroup = new PeerGroup(netParams, chain);

    //peerGroup.setBloomFilteringEnabled(false);

    peerGroup.addPeerDiscovery(new DnsDiscovery(netParams));
    peerGroup.setFastCatchupTimeSecs(time.getTime());

    peerGroup.addWallet(wallet);
    chain.addWallet(wallet);

    peerGroup.start();
    peerGroup.downloadBlockChain();
    peerGroup.stop();

    chainFile.delete();

    System.out.println(wallet);
    wallet.cleanup();
}


The output

-- 
You received this message because you are subscribed to the Google Groups 
"bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bitcoinj+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to