protected void setupAutoSave(Wallet wallet) { wallet.autosaveToFile(vWalletFile, 5, TimeUnit.SECONDS, null); }
protected void setupAutoSave(Wallet wallet) { wallet.autosaveToFile(vWalletFile, 5, TimeUnit.SECONDS, null); }
protected void setupAutoSave(Wallet wallet) { wallet.autosaveToFile(vWalletFile, 5, TimeUnit.SECONDS, null); }
protected void setupAutoSave(Wallet wallet) { wallet.autosaveToFile(vWalletFile, 5, TimeUnit.SECONDS, null); }
private Wallet createWallet(File walletFile) throws IOException { Wallet wallet = new Wallet(Constants.NETWORK_PARAMETERS); WalletFiles walletFiles = wallet.autosaveToFile(walletFile, 3 * 1000, TimeUnit.MILLISECONDS, null); walletFiles.saveNow(); return wallet; }
private Wallet readWallet(File walletFile) throws FileNotFoundException, UnreadableWalletException { InputStream inputStream = new FileInputStream(walletFile); Wallet wallet = new WalletProtobufSerializer().readWallet(inputStream); wallet.autosaveToFile(walletFile, 3 * 1000, TimeUnit.MILLISECONDS, null); wallet.cleanup(); return wallet; }
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); }
wallet.autosaveToFile(walletFile, 5, TimeUnit.SECONDS, null); if (options.has("tor")) { try {
@Test public void autosaveImmediate() throws Exception { // Test that the wallet will save itself automatically when it changes. File f = File.createTempFile("bitcoinj-unit-test", null); Sha256Hash hash1 = Sha256Hash.of(f); // Start with zero delay and ensure the wallet file changes after adding a key. wallet.autosaveToFile(f, 0, TimeUnit.SECONDS, null); ECKey key = wallet.freshReceiveKey(); Sha256Hash hash2 = Sha256Hash.of(f); assertFalse("Wallet not saved after generating fresh key", hash1.equals(hash2)); // File has changed. Transaction t1 = createFakeTx(PARAMS, valueOf(5, 0), key); if (wallet.isPendingTransactionRelevant(t1)) wallet.receivePending(t1, null); Sha256Hash hash3 = Sha256Hash.of(f); assertFalse("Wallet not saved after receivePending", hash2.equals(hash3)); // File has changed again. }
File tempFile = File.createTempFile("channel_connection_test", ".wallet"); tempFile.deleteOnExit(); serverWallet.autosaveToFile(tempFile, 0, TimeUnit.SECONDS, new WalletFiles.Listener() { @Override public void onBeforeAutoSave(File tempFile) {
File f = File.createTempFile("bitcoinj-unit-test", null); Sha256Hash hash1 = Sha256Hash.of(f); wallet.autosaveToFile(f, 1, TimeUnit.SECONDS, new WalletFiles.Listener() { @Override