@Override public void getInfoDialog() { view.displayInfoDialog(walletAppKit.wallet().currentReceiveAddress().toBase58()); }
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); }
System.out.println("Send money to: " + kit.wallet().currentReceiveAddress().toString());
rekeyTx.addOutput(toMove.valueGathered, sign ? freshReceiveAddress() : currentReceiveAddress()); if (!adjustOutputDownwardsForFee(rekeyTx, toMove, Transaction.DEFAULT_TX_FEE, true)) { log.error("Failed to adjust rekey tx for fees.");
rekeyTx.addOutput(toMove.valueGathered, sign ? freshReceiveAddress() : currentReceiveAddress()); if (!adjustOutputDownwardsForFee(rekeyTx, toMove, Transaction.DEFAULT_TX_FEE, true)) { log.error("Failed to adjust rekey tx for fees.");
rekeyTx.addOutput(toMove.valueGathered, sign ? freshReceiveAddress() : currentReceiveAddress()); if (!adjustOutputDownwardsForFee(rekeyTx, toMove, Transaction.DEFAULT_TX_FEE, true)) { log.error("Failed to adjust rekey tx for fees.");
rekeyTx.addOutput(toMove.valueGathered, sign ? freshReceiveAddress() : currentReceiveAddress()); if (!adjustOutputDownwardsForFee(rekeyTx, toMove, Transaction.DEFAULT_TX_FEE, true, false)) { log.error("Failed to adjust rekey tx for fees.");
System.out.println("Send some money to " + kit.wallet().currentReceiveAddress()); System.out.println("... and wait for it to confirm"); kit.wallet().getBalanceFuture(feeToTest, Wallet.BalanceType.AVAILABLE).get();
@Test public void testSequenceNumber() throws Exception { Wallet wallet = new Wallet(PARAMS); Transaction tx1 = createFakeTx(PARAMS, Coin.COIN, wallet.currentReceiveAddress()); tx1.getInput(0).setSequenceNumber(TransactionInput.NO_SEQUENCE); wallet.receivePending(tx1, null); Transaction tx2 = createFakeTx(PARAMS, Coin.COIN, wallet.currentReceiveAddress()); tx2.getInput(0).setSequenceNumber(TransactionInput.NO_SEQUENCE - 1); wallet.receivePending(tx2, null); Wallet walletCopy = roundTrip(wallet); Transaction tx1copy = checkNotNull(walletCopy.getTransaction(tx1.getHash())); assertEquals(TransactionInput.NO_SEQUENCE, tx1copy.getInput(0).getSequenceNumber()); Transaction tx2copy = checkNotNull(walletCopy.getTransaction(tx2.getHash())); assertEquals(TransactionInput.NO_SEQUENCE - 1, tx2copy.getInput(0).getSequenceNumber()); }
@Test public void marriedKeychainBloomFilter() throws Exception { createMarriedWallet(2, 2); Address address = wallet.currentReceiveAddress(); assertTrue(wallet.getBloomFilter(0.001).contains(address.getHash160())); Transaction t1 = createFakeTx(PARAMS, CENT, address); TransactionOutPoint outPoint = new TransactionOutPoint(PARAMS, 0, t1); assertFalse(wallet.getBloomFilter(0.001).contains(outPoint.unsafeBitcoinSerialize())); sendMoneyToWallet(BlockChain.NewBlockType.BEST_CHAIN, t1); assertTrue(wallet.getBloomFilter(0.001).contains(outPoint.unsafeBitcoinSerialize())); }
@Test public void testStandardWalletDisconnect() throws Exception { NetworkParameters params = UnitTestParams.get(); Wallet w = new Wallet(new Context(params)); w.setCoinSelector(new AllowUnconfirmedCoinSelector()); Address a = w.currentReceiveAddress(); Transaction tx1 = FakeTxBuilder.createFakeTxWithoutChangeAddress(params, Coin.COIN, a); w.receivePending(tx1, null); Transaction tx2 = new Transaction(params); tx2.addOutput(Coin.valueOf(99000000), new ECKey()); w.completeTx(SendRequest.forTx(tx2)); TransactionInput txInToDisconnect = tx2.getInput(0); assertEquals(tx1, txInToDisconnect.getOutpoint().fromTx); assertNull(txInToDisconnect.getOutpoint().connectedOutput); txInToDisconnect.disconnect(); assertNull(txInToDisconnect.getOutpoint().fromTx); assertNull(txInToDisconnect.getOutpoint().connectedOutput); }
final NetworkParameters params = UnitTestParams.get(); Wallet w = new Wallet(new Context(params)); Address a = w.currentReceiveAddress(); final UTXO utxo = new UTXO(Sha256Hash.of(new byte[] { 1, 2, 3 }), 1, Coin.COIN, 0, false, ScriptBuilder.createOutputScript(a));