@Override public List<Transaction> loadInBackground() { org.bitcoinj.core.Context.propagate(Constants.CONTEXT); final Set<Transaction> transactions = wallet.getTransactions(true); final List<Transaction> filteredTransactions = new ArrayList<Transaction>(transactions.size()); for (final Transaction tx : transactions) { final boolean sent = tx.getValue(wallet).signum() < 0; final boolean isInternal = tx.getPurpose() == Purpose.KEY_ROTATION; if ((direction == Direction.RECEIVED && !sent && !isInternal) || direction == null || (direction == Direction.SENT && sent && !isInternal)) filteredTransactions.add(tx); } Collections.sort(filteredTransactions, TRANSACTION_COMPARATOR); return filteredTransactions; }
@Override public List<Transaction> loadInBackground() { final Set<Transaction> transactions = wallet.getTransactions(true); final List<Transaction> filteredTransactions = new ArrayList<Transaction>(transactions.size()); for (final Transaction tx : transactions) { final boolean sent = tx.getValue(wallet).signum() < 0; final boolean isInternal = tx.getPurpose() == Purpose.KEY_ROTATION; if ((direction == Direction.RECEIVED && !sent && !isInternal) || direction == null || (direction == Direction.SENT && sent && !isInternal)) filteredTransactions.add(tx); } Collections.sort(filteredTransactions, TRANSACTION_COMPARATOR); return filteredTransactions; }
@Test public void raiseFeeTx() throws Exception { // Check basic tx serialization. Coin v1 = COIN; Transaction t1 = createFakeTx(PARAMS, v1, myAddress); t1.setPurpose(Purpose.RAISE_FEE); myWallet.receivePending(t1, null); Wallet wallet1 = roundTrip(myWallet); Transaction t1copy = wallet1.getTransaction(t1.getHash()); assertEquals(Purpose.RAISE_FEE, t1copy.getPurpose()); }
public void bindView(final View row, final Transaction tx) { final boolean isCoinBase = tx.isCoinBase(); final boolean isInternal = tx.getPurpose() == Purpose.KEY_ROTATION; final Coin value = tx.getValue(wallet); final boolean sent = value.signum() < 0; final boolean self = WalletUtils.isEntirelySelf(tx, wallet); final Address address; if (sent) address = WalletUtils.getToAddressOfSent(tx, wallet); else address = WalletUtils.getWalletAddressOfReceived(tx, wallet); // receiving or sending final TextView rowFromTo = (TextView) row.findViewById(R.id.block_row_transaction_fromto); if (isInternal || self) rowFromTo.setText(R.string.symbol_internal); else if (sent) rowFromTo.setText(R.string.symbol_to); else rowFromTo.setText(R.string.symbol_from); // address final TextView rowAddress = (TextView) row.findViewById(R.id.block_row_transaction_address); final String label; if (isCoinBase) label = textCoinBase; else if (isInternal || self) label = textInternal; else if (address != null) label = AddressBookProvider.resolveLabel(context, address.toBase58()); else label = "?"; rowAddress.setText(label != null ? label : address.toBase58()); rowAddress.setTypeface(label != null ? Typeface.DEFAULT : Typeface.MONOSPACE); // value final CurrencyTextView rowValue = (CurrencyTextView) row.findViewById(R.id.block_row_transaction_value); rowValue.setAlwaysSigned(true); rowValue.setFormat(format); rowValue.setAmount(value); }
public void bindView(final View row, final Transaction tx) { final boolean isCoinBase = tx.isCoinBase(); final boolean isInternal = tx.getPurpose() == Purpose.KEY_ROTATION; final Coin value = tx.getValue(wallet); final boolean sent = value.signum() < 0; final Address address; if (sent) address = WalletUtils.getToAddressOfSent(tx, wallet); else address = WalletUtils.getWalletAddressOfReceived(tx, wallet); // receiving or sending final TextView rowFromTo = (TextView) row.findViewById(R.id.block_row_transaction_fromto); if (isInternal) rowFromTo.setText(R.string.symbol_internal); else if (sent) rowFromTo.setText(R.string.symbol_to); else rowFromTo.setText(R.string.symbol_from); // address final TextView rowAddress = (TextView) row.findViewById(R.id.block_row_transaction_address); final String label; if (isCoinBase) label = textCoinBase; else if (isInternal) label = textInternal; else if (address != null) label = AddressBookProvider.resolveLabel(context, address.toString()); else label = "?"; rowAddress.setText(label != null ? label : address.toString()); rowAddress.setTypeface(label != null ? Typeface.DEFAULT : Typeface.MONOSPACE); // value final CurrencyTextView rowValue = (CurrencyTextView) row.findViewById(R.id.block_row_transaction_value); rowValue.setAlwaysSigned(true); rowValue.setFormat(format); rowValue.setAmount(value); }