Java Code Examples for org.bitcoinj.core.Transaction#getValueSentToMe()
The following examples show how to use
org.bitcoinj.core.Transaction#getValueSentToMe() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WalletTest.java From bcm-android with GNU General Public License v3.0 | 5 votes |
public void fragmentedReKeying() throws Exception { // Send lots of small coins and check the fee is correct. ECKey key = wallet.freshReceiveKey(); Address address = LegacyAddress.fromKey(UNITTEST, key); Utils.setMockClock(); Utils.rollMockClock(86400); for (int i = 0; i < 800; i++) { sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, CENT, address); } MockTransactionBroadcaster broadcaster = new MockTransactionBroadcaster(wallet); Date compromise = Utils.now(); Utils.rollMockClock(86400); wallet.freshReceiveKey(); wallet.setKeyRotationTime(compromise); wallet.doMaintenance(null, true); Transaction tx = broadcaster.waitForTransactionAndSucceed(); final Coin valueSentToMe = tx.getValueSentToMe(wallet); Coin fee = tx.getValueSentFromMe(wallet).subtract(valueSentToMe); assertEquals(Coin.valueOf(900000), fee); assertEquals(KeyTimeCoinSelector.MAX_SIMULTANEOUS_INPUTS, tx.getInputs().size()); assertEquals(Coin.valueOf(599100000), valueSentToMe); tx = broadcaster.waitForTransaction(); assertNotNull(tx); assertEquals(200, tx.getInputs().size()); }
Example 2
Source File: WalletTest.java From green_android with GNU General Public License v3.0 | 5 votes |
public void fragmentedReKeying() throws Exception { // Send lots of small coins and check the fee is correct. ECKey key = wallet.freshReceiveKey(); Address address = key.toAddress(PARAMS); Utils.setMockClock(); Utils.rollMockClock(86400); for (int i = 0; i < 800; i++) { sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, CENT, address); } MockTransactionBroadcaster broadcaster = new MockTransactionBroadcaster(wallet); Date compromise = Utils.now(); Utils.rollMockClock(86400); wallet.freshReceiveKey(); wallet.setKeyRotationTime(compromise); wallet.doMaintenance(null, true); Transaction tx = broadcaster.waitForTransactionAndSucceed(); final Coin valueSentToMe = tx.getValueSentToMe(wallet); Coin fee = tx.getValueSentFromMe(wallet).subtract(valueSentToMe); assertEquals(Coin.valueOf(900000), fee); assertEquals(KeyTimeCoinSelector.MAX_SIMULTANEOUS_INPUTS, tx.getInputs().size()); assertEquals(Coin.valueOf(599100000), valueSentToMe); tx = broadcaster.waitForTransaction(); assertNotNull(tx); assertEquals(200, tx.getInputs().size()); }
Example 3
Source File: WalletTest.java From GreenBits with GNU General Public License v3.0 | 5 votes |
public void fragmentedReKeying() throws Exception { // Send lots of small coins and check the fee is correct. ECKey key = wallet.freshReceiveKey(); Address address = key.toAddress(PARAMS); Utils.setMockClock(); Utils.rollMockClock(86400); for (int i = 0; i < 800; i++) { sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, CENT, address); } MockTransactionBroadcaster broadcaster = new MockTransactionBroadcaster(wallet); Date compromise = Utils.now(); Utils.rollMockClock(86400); wallet.freshReceiveKey(); wallet.setKeyRotationTime(compromise); wallet.doMaintenance(null, true); Transaction tx = broadcaster.waitForTransactionAndSucceed(); final Coin valueSentToMe = tx.getValueSentToMe(wallet); Coin fee = tx.getValueSentFromMe(wallet).subtract(valueSentToMe); assertEquals(Coin.valueOf(900000), fee); assertEquals(KeyTimeCoinSelector.MAX_SIMULTANEOUS_INPUTS, tx.getInputs().size()); assertEquals(Coin.valueOf(599100000), valueSentToMe); tx = broadcaster.waitForTransaction(); assertNotNull(tx); assertEquals(200, tx.getInputs().size()); }
Example 4
Source File: WalletService.java From bisq-core with GNU Affero General Public License v3.0 | 4 votes |
public Coin getValueSentToMeForTransaction(Transaction transaction) throws ScriptException { return transaction.getValueSentToMe(wallet); }
Example 5
Source File: WalletService.java From bisq with GNU Affero General Public License v3.0 | 4 votes |
public Coin getValueSentToMeForTransaction(Transaction transaction) throws ScriptException { return transaction.getValueSentToMe(wallet); }