Hi there,

I'm trying to use BitcoinJ for a test application I'm writing. This app 
should be able to do two main things:

1) Generate new bitcoin addresses on demand, and
2) Get the unspent outputs for a given address (which will have been 
created in step 1).

I can easily do 1) by using `wallet.freshReceiveAddress()`. 

I'm struggling with with 2) at the moment. Data should be stored in 
Postgres so I can restart the app. My code right now looks like this: 

NetworkParameters params = TestNet3Params.get();
PostgresFullPrunedBlockStore blockstore =
        new PostgresFullPrunedBlockStore(params, 1000,
                "localhost", "blockchain", "postgres", "secret");
Wallet w = new Wallet(params);
// A random address I've found that I know has unspent outputs.
Address a = Address.fromBase58(params, "2N66DDrmjDCMM3yMSYtAQyAqRtasSkFhbmX");
w.addWatchedAddress(a);


BlockChain bc = new BlockChain(params, blockstore);
PeerGroup pg = new PeerGroup(params, bc);
pg.addWallet(w);

w.addChangeEventListener(new WalletChangeEventListener() {
    @Override
    public void onWalletChanged(Wallet wallet) {
        System.out.println("Changed!" + wallet.getBalance());
    }
});


System.out.println("New balance: " + w.getBalance());


However, I never see "New balance: <balance>" and the postgres database 
rarely gets updated (only a single header is ever stored). I'm not sure if 
I'm misunderstanding how to use the FullPrunedBlockStore, so any help would 
be massively appreciated!

Thanks

-- 
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