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 serializeTransactionsBtc() throws Exception, Bip44KeyLookAheadExceededException { WalletPocketHD account = new WalletPocketHD(rootKey, BTC, null, null); Transaction tx = new Transaction(BTC); tx.addOutput(BTC.oneCoin().toCoin(), account.getReceiveAddress()); account.addNewTransactionIfNeeded(tx); testWalletSerializationForCoin(account); }
@Test public void serializeTransactionsNbt() throws Exception, Bip44KeyLookAheadExceededException { WalletPocketHD account = new WalletPocketHD(rootKey, NBT, null, null); Transaction tx = new Transaction(NBT); tx.addOutput(NBT.oneCoin().toCoin(), account.getReceiveAddress()); account.addNewTransactionIfNeeded(tx); testWalletSerializationForCoin(account); }
@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()); }
tx.setTime(0x99999999); tx.addOutput(VPN.oneCoin().toCoin(), account.getFreshReceiveAddress()); account.addNewTransactionIfNeeded(tx); WalletPocketHD newAccount = testWalletSerializationForCoin(account); Transaction newTx = newAccount.getRawTransaction(tx.getHash()); tx.setExtraBytes(new byte[0]); tx.addOutput(VPN.oneCoin().toCoin(), account.getFreshReceiveAddress()); account.addNewTransactionIfNeeded(tx); newAccount = testWalletSerializationForCoin(account); newTx = newAccount.getRawTransaction(tx.getHash()); tx.setExtraBytes(bytes); tx.addOutput(VPN.oneCoin().toCoin(), account.getFreshReceiveAddress()); account.addNewTransactionIfNeeded(tx); newAccount = testWalletSerializationForCoin(account); newTx = newAccount.getRawTransaction(tx.getHash());
tx.addOutput(BTC.oneCoin().toCoin(), account1.getReceiveAddress()); tx.getConfidence().setSource(Source.SELF); account1.addNewTransactionIfNeeded(tx);