private Sha256Hash send(Value value, WalletPocketHD w1, WalletPocketHD w2) throws Exception { assertEquals(w1.getCoinType(), w2.getCoinType()); CoinType type = w1.getCoinType(); BitSendRequest req = w1.sendCoinsOffline(w2.getReceiveAddress(), value); req.feePerTxSize = type.value("0.01"); w1.completeAndSignTx(req); byte[] txBytes = req.tx.bitcoinSerialize(); w1.addNewTransactionIfNeeded(new BitTransaction(type, txBytes)); w2.addNewTransactionIfNeeded(new BitTransaction(type, txBytes)); return req.tx.getHash(); }
@Test public void createDustTransactionFee() throws Exception { pocket.onConnection(getBlockchainConnection(DOGE)); BitAddress toAddr = BitAddress.from(DOGE, "nZB8PHkfgJvuCJqchSexmfY3ABXa2aE1vp"); Value softDust = DOGE.getSoftDustLimit(); assertNotNull(softDust); // Send a soft dust BitSendRequest sendRequest = pocket.sendCoinsOffline(toAddr, softDust.subtract(DOGE.value(1))); pocket.completeTransaction(sendRequest); assertEquals(DOGE.getFeeValue().multiply(2), sendRequest.tx.getFee()); }
@Test public void createTransactionAndBroadcast() throws Exception { pocket.onConnection(getBlockchainConnection(DOGE)); BitAddress toAddr = BitAddress.from(DOGE, "nZB8PHkfgJvuCJqchSexmfY3ABXa2aE1vp"); Value orgBalance = pocket.getBalance(); BitSendRequest sendRequest = pocket.sendCoinsOffline(toAddr, DOGE.value(AMOUNT_TO_SEND)); sendRequest.shuffleOutputs = false; sendRequest.feePerTxSize = DOGE.value(0); pocket.completeTransaction(sendRequest); // FIXME, mock does not work here // pocket.broadcastTx(tx); pocket.addNewTransactionIfNeeded(sendRequest.tx); assertEquals(orgBalance.subtract(AMOUNT_TO_SEND), pocket.getBalance()); }