private void walletSetUp() { this.wallet = new Wallet(this.bitcoinContext); this.bitcoinBlockchain.addWallet(wallet); bitcoinPeerGroup.addWallet(wallet); }
public void addWalletToPeerGroup(Wallet wallet, boolean useFastCatchup) { if (peerGroup != null && wallet != null) { log.trace("Adding wallet {} to peerGroup {}", wallet, peerGroup); peerGroup.addWallet(wallet); if (useFastCatchup) { peerGroup.setFastCatchupTimeSecs(wallet.getEarliestKeyCreationTime()); } else { peerGroup.setFastCatchupTimeSecs(0); // Download full blocks always } recalculateFastCatchupAndFilter(false); } else { log.debug("Could not add wallet to peerGroup - one or more is missing"); } }
public BitcoinTestPaymentService(BlockChain bitcoinBlockchain, Context bitcoinContext, NetworkParameters bitcoinNetworkParameters, PeerGroup peerGroup, String walletPassword, String walletPath) throws IOException, CipherException, UnreadableWalletException { this.bitcoinBlockchain = bitcoinBlockchain; this.bitcoinContext = bitcoinContext; this.bitcoinNetworkParameters = bitcoinNetworkParameters; this.peerGroup = peerGroup; File walletFile = new File(walletPath); if (walletFile.exists()) { LOG.info("Wallet exists... trying to load from: {}", walletPath); this.bitcoinWallet = Wallet.loadFromFile(new File(walletPath)); } else { LOG.info("Wallet does NOT exist... creating one.", walletPath); this.bitcoinWallet = new Wallet(this.bitcoinContext); this.bitcoinWallet.saveToFile(walletFile); } LOG.info("Wallet loaded: address={}", this.bitcoinWallet.currentReceiveAddress()); this.bitcoinWallet.autosaveToFile(walletFile, 500, TimeUnit.MILLISECONDS, null); this.bitcoinBlockchain.addWallet(this.bitcoinWallet); peerGroup.addWallet(this.bitcoinWallet); }
vPeerGroup.addWallet(vWallet); onSetupCompleted();
vPeerGroup.addWallet(vWallet); onSetupCompleted();
vPeerGroup.addWallet(vWallet); onSetupCompleted();
vPeerGroup.addWallet(vWallet); onSetupCompleted();
peers.addWallet(wallet);
if (params == RegTestParams.get()) peers.setMinBroadcastConnections(1); peers.addWallet(wallet); if (options.has("peers")) { String peersFlag = (String) options.valueOf("peers");
peerGroup = new PeerGroup(Constants.NETWORK_PARAMETERS, blockChain); peerGroup.setDownloadTxDependencies(0); // recursive implementation causes StackOverflowError peerGroup.addWallet(wallet); try { PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_ACTIVITIES);
protected void initPeerGroup() { if (clientType == ClientType.NIO_CLIENT_MANAGER) peerGroup = createPeerGroup(new NioClientManager()); else peerGroup = createPeerGroup(new BlockingClientManager()); peerGroup.setPingIntervalMsec(0); // Disable the pings as they just get in the way of most tests. peerGroup.addWallet(wallet); peerGroup.setUseLocalhostPeerWhenPossible(false); // Prevents from connecting to bitcoin nodes on localhost. }
@Test public void receiveTxBroadcastOnAddedWallet() throws Exception { // Check that when we receive transactions on all our peers, we do the right thing. peerGroup.start(); // Create a peer. InboundMessageQueuer p1 = connectPeer(1); Wallet wallet2 = new Wallet(PARAMS); ECKey key2 = wallet2.freshReceiveKey(); Address address2 = key2.toAddress(PARAMS); peerGroup.addWallet(wallet2); blockChain.addWallet(wallet2); assertEquals(BloomFilter.class, waitForOutbound(p1).getClass()); assertEquals(MemoryPoolMessage.class, waitForOutbound(p1).getClass()); Coin value = COIN; Transaction t1 = FakeTxBuilder.createFakeTx(PARAMS, value, address2); InventoryMessage inv = new InventoryMessage(PARAMS); inv.addTransaction(t1); inbound(p1, inv); assertTrue(outbound(p1) instanceof GetDataMessage); inbound(p1, t1); // Asks for dependency. GetDataMessage getdata = (GetDataMessage) outbound(p1); assertNotNull(getdata); inbound(p1, new NotFoundMessage(PARAMS, getdata.getItems())); pingAndWait(p1); assertEquals(value, wallet2.getBalance(Wallet.BalanceType.ESTIMATED)); }
@Test public void testWalletCatchupTime() throws Exception { // Check the fast catchup time was initialized to something around the current runtime minus a week. // The wallet was already added to the peer in setup. final int WEEK = 86400 * 7; final long now = Utils.currentTimeSeconds(); peerGroup.start(); assertTrue(peerGroup.getFastCatchupTimeSecs() > now - WEEK - 10000); Wallet w2 = new Wallet(PARAMS); ECKey key1 = new ECKey(); key1.setCreationTimeSeconds(now - 86400); // One day ago. w2.importKey(key1); peerGroup.addWallet(w2); peerGroup.waitForJobQueue(); assertEquals(peerGroup.getFastCatchupTimeSecs(), now - 86400 - WEEK); // Adding a key to the wallet should update the fast catchup time, but asynchronously and in the background // due to the need to avoid complicated lock inversions. ECKey key2 = new ECKey(); key2.setCreationTimeSeconds(now - 100000); w2.importKey(key2); peerGroup.waitForJobQueue(); assertEquals(peerGroup.getFastCatchupTimeSecs(), now - WEEK - 100000); }
peerGroup.addWallet(wallet);
peerGroup.addWallet(wallet);