private SendRequest generateSendRequest(AbstractAddress sendTo, boolean emptyWallet, @Nullable Value amount, @Nullable TxMessage txMessage) throws WalletAccount.WalletAccountException { SendRequest sendRequest; if (emptyWallet) { sendRequest = sourceAccount.getEmptyWalletRequest(sendTo); } else { sendRequest = sourceAccount.getSendToRequest(sendTo, checkNotNull(amount)); } sendRequest.txMessage = txMessage; sendRequest.signTransaction = false; sourceAccount.completeTransaction(sendRequest); return sendRequest; }
@Override public Value getValue(AbstractWallet wallet) { if (tx.getSenderId() == wallet.getReceiveAddress().getId()) { return Value.valueOf(wallet.getCoinType(), -1 * tx.getAmountNQT()); } else { return Value.valueOf(wallet.getCoinType(), tx.getAmountNQT()); } }
@Override public boolean equals(WalletAccount other) { return other != null && getId().equals(other.getId()) && getCoinType().equals(other.getCoinType()); } }
@Override public void completeAndSignTx(SendRequest request) throws WalletAccountException { if (request.isCompleted()) { signTransaction(request); } else { completeTransaction(request); } }
public TransactionAmountVisualizerAdapter(final Context context, final AbstractWallet walletPocket) { this.context = context; inflater = LayoutInflater.from(context); pocket = walletPocket; type = pocket.getCoinType(); symbol = type.getSymbol(); outputs = new ArrayList<>(); }
public void setTransaction(AbstractTransaction tx) { outputs.clear(); final Value value = tx.getValue(pocket); isSending = value.signum() < 0; // if sending and all the outputs point inside the current pocket it is an internal transfer boolean isInternalTransfer = isSending; for (AbstractOutput output : tx.getSentTo()) { if (isSending) { // When sending hide change outputs if (pocket.isAddressMine(output.getAddress())) continue; isInternalTransfer = false; } else { if (pocket.getCoinType() instanceof NxtFamily) { // TODO review the following outputs.add(new AbstractOutput(tx.getReceivedFrom().get(0), tx.getValue(pocket))); break; } // When receiving hide outputs that are not ours if (!pocket.isAddressMine(output.getAddress())) continue; } outputs.add(output); } feeAmount = tx.getFee(); hasFee = feeAmount != null && !feeAmount.isZero(); itemCount = isInternalTransfer ? 1 : outputs.size(); itemCount += hasFee ? 1 : 0; notifyDataSetChanged(); }
sourceAccount.completeAndSignTx(request); if (!sourceAccount.broadcastTxSync(request.tx)) { throw new Exception("Error broadcasting transaction: " + request.tx.getHashAsString());
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_transaction_details, container, false); outputRows = (ListView) view.findViewById(R.id.output_rows); outputRows.setOnItemClickListener(getListener()); // Header View header = inflater.inflate(R.layout.fragment_transaction_details_header, null); outputRows.addHeaderView(header, null, false); txStatusView = (TextView) header.findViewById(R.id.tx_status); txDateLabel = (TextView) header.findViewById(R.id.tx_date_label); txDate = (TextView) header.findViewById(R.id.tx_date); // Footer View footer = inflater.inflate(R.layout.fragment_transaction_details_footer, null); outputRows.addFooterView(footer, null, false); txIdView = (TextView) footer.findViewById(R.id.tx_id); txMessageLabel = (TextView) footer.findViewById(R.id.tx_message_label); txMessage = (TextView) footer.findViewById(R.id.tx_message); blockExplorerLink = (TextView) footer.findViewById(R.id.block_explorer_link); pocket.addEventListener(walletListener); adapter = new TransactionAmountVisualizerAdapter(inflater.getContext(), pocket); outputRows.setAdapter(adapter); txId = getArguments().getString(Constants.ARG_TRANSACTION_ID); updateView(); return view; }
sourceAccount.getRefundAddress(config.isManualAddressManagement());
@CheckForNull public static List<AbstractAddress> getReceivedWithOrFrom(@Nonnull final AbstractTransaction tx, @Nonnull final AbstractWallet pocket) { // TODO a better approach is to use a "features" enum list and check agaist that if (pocket.getCoinType() instanceof NxtFamily) { return tx.getReceivedFrom(); } else { return getToAddresses(tx, pocket, true); } }
sourceAccount = (AbstractWallet) checkNotNull(application.getAccount(fromAccountId)); application.maybeConnectAccount(sourceAccount); sourceType = sourceAccount.getCoinType(); emptyWallet = args.getBoolean(ARG_EMPTY_WALLET, false); sendAmount = (Value) args.getSerializable(ARG_SEND_VALUE); String toAccountId = args.getString(ARG_SEND_TO_ACCOUNT_ID); AbstractWallet toAccount = (AbstractWallet) checkNotNull(application.getAccount(toAccountId)); sendToAddress = toAccount.getReceiveAddress(config.isManualAddressManagement()); sendingToAccount = true; } else {
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { accountId = getArguments().getString(Constants.ARG_ACCOUNT_ID); } pocket = (AbstractWallet) getWalletApplication().getAccount(accountId); if (pocket == null) { Toast.makeText(getActivity(), R.string.no_such_pocket_error, Toast.LENGTH_LONG).show(); // TODO report anomaly return; } type = pocket.getCoinType(); }
final boolean sent = value.signum() < 0; final CoinType type = walletPocket.getCoinType(); rowDirectionText.setText(sentToTitle); rowDirectionFontIcon.setText(fontIconSentTo); } else if (walletPocket.getCoinType().getFamily() != Families.NXT) { rowDirectionText.setText(receivedWithTitle); rowDirectionFontIcon.setText(fontIconReceivedWith);
setupBlockExplorerLink(pocket.getCoinType(), tx.getHashAsString());