/** * Convenience wrapper for <tt>setCoinSelector(Wallet.AllowUnconfirmedCoinSelector.get())</tt>. If this method * is called on the wallet then transactions will be used for spending regardless of their confidence. This can * be dangerous - only use this if you absolutely know what you're doing! */ public void allowSpendingUnconfirmedTransactions() { setCoinSelector(AllowUnconfirmedCoinSelector.get()); }
/** * Convenience wrapper for <tt>setCoinSelector(Wallet.AllowUnconfirmedCoinSelector.get())</tt>. If this method * is called on the wallet then transactions will be used for spending regardless of their confidence. This can * be dangerous - only use this if you absolutely know what you're doing! */ public void allowSpendingUnconfirmedTransactions() { setCoinSelector(AllowUnconfirmedCoinSelector.get()); }
/** * Convenience wrapper for <tt>setCoinSelector(Wallet.AllowUnconfirmedCoinSelector.get())</tt>. If this method * is called on the wallet then transactions will be used for spending regardless of their confidence. This can * be dangerous - only use this if you absolutely know what you're doing! */ public void allowSpendingUnconfirmedTransactions() { setCoinSelector(AllowUnconfirmedCoinSelector.get()); }
/** * Convenience wrapper for <tt>setCoinSelector(Wallet.AllowUnconfirmedCoinSelector.get())</tt>. If this method * is called on the wallet then transactions will be used for spending regardless of their confidence. This can * be dangerous - only use this if you absolutely know what you're doing! */ public void allowSpendingUnconfirmedTransactions() { setCoinSelector(AllowUnconfirmedCoinSelector.get()); }
@Test public void testAddTransactionsDependingOn() throws Exception { CoinSelector originalCoinSelector = wallet.getCoinSelector(); try { wallet.allowSpendingUnconfirmedTransactions(); sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, valueOf(2, 0)); Transaction send1 = checkNotNull(wallet.createSend(OTHER_ADDRESS, valueOf(1, 0))); Transaction send2 = checkNotNull(wallet.createSend(OTHER_ADDRESS, valueOf(1, 20))); wallet.commitTx(send1); Transaction send1b = checkNotNull(wallet.createSend(OTHER_ADDRESS, valueOf(0, 50))); wallet.commitTx(send1b); Transaction send1c = checkNotNull(wallet.createSend(OTHER_ADDRESS, valueOf(0, 25))); wallet.commitTx(send1c); wallet.commitTx(send2); Set<Transaction> txns = new HashSet<>(); txns.add(send1); wallet.addTransactionsDependingOn(txns, wallet.getTransactions(true)); assertEquals(3, txns.size()); assertTrue(txns.contains(send1)); assertTrue(txns.contains(send1b)); assertTrue(txns.contains(send1c)); } finally { wallet.setCoinSelector(originalCoinSelector); } }
assertTrue(sortedTxns.indexOf(send2b) < sortedTxns.indexOf(send2c)); } finally { wallet.setCoinSelector(originalCoinSelector);
@Test public void doubleSpendForBuildingTx() throws Exception { CoinSelector originalCoinSelector = wallet.getCoinSelector(); try { wallet.allowSpendingUnconfirmedTransactions(); sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, valueOf(2, 0)); Transaction send1 = checkNotNull(wallet.createSend(OTHER_ADDRESS, valueOf(1, 0))); Transaction send2 = checkNotNull(wallet.createSend(OTHER_ADDRESS, valueOf(1, 20))); sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, send1); assertUnspent(send1); wallet.receivePending(send2, null); assertUnspent(send1); assertDead(send2); } finally { wallet.setCoinSelector(originalCoinSelector); } }
@Test public void txSpendingDeadTx() throws Exception { CoinSelector originalCoinSelector = wallet.getCoinSelector(); try { wallet.allowSpendingUnconfirmedTransactions(); sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, valueOf(2, 0)); Transaction send1 = checkNotNull(wallet.createSend(OTHER_ADDRESS, valueOf(1, 0))); Transaction send2 = checkNotNull(wallet.createSend(OTHER_ADDRESS, valueOf(1, 20))); wallet.commitTx(send1); assertPending(send1); Transaction send1b = checkNotNull(wallet.createSend(OTHER_ADDRESS, valueOf(0, 50))); sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, send2); assertDead(send1); assertUnspent(send2); wallet.receivePending(send1b, null); assertDead(send1); assertUnspent(send2); assertDead(send1b); } finally { wallet.setCoinSelector(originalCoinSelector); } }
@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); }
assertDead(txD2); } finally { wallet.setCoinSelector(originalCoinSelector);