use of run.wallet.iota.model.TransferTransaction in project run-wallet-android by runplay.
the class TransferViewManager method populateTransferTransactions.
private static void populateTransferTransactions(Context context, LinearLayout uselayout, List<TransferTransaction> transactions, boolean isOtherTransactions) {
uselayout.removeAllViews();
int bgcolor = B.getColor(context, AppTheme.getPrimary());
int bglight = B.getColor(context, R.color.colorLight);
int white = B.getColor(context, R.color.white);
int red = B.getColor(context, R.color.flatRed);
int green = B.getColor(context, R.color.green);
main.weight = 1;
param.setMargins(8, 4, 8, 4);
param2.setMargins(8, 4, 8, 4);
param3.setMargins(0, 4, 8, 4);
for (TransferTransaction trans : transactions) {
LinearLayout layout = new LinearLayout(context);
layout.setBackgroundColor(bglight);
layout.setOrientation(LinearLayout.HORIZONTAL);
layout.setLayoutParams(main);
layout.setPadding(2, 2, 2, 2);
layout.canScrollHorizontally(View.LAYOUT_DIRECTION_LTR);
TextView addValue = new TextView(context);
addValue.setLayoutParams(param2);
addValue.setText(IotaToText.convertRawIotaAmountToDisplayText(trans.getValue(), true));
addValue.setTextSize(16F);
addValue.setTypeface(null, Typeface.BOLD);
if (trans.getValue() < 0) {
addValue.setTextColor(red);
} else {
addValue.setTextColor(green);
}
addValue.setPadding(5, 2, 2, 2);
addValue.setSingleLine();
TextView addAddress = new TextView(context);
addAddress.setLayoutParams(param3);
addAddress.setText(trans.getAddress());
addAddress.setTextColor(bgcolor);
addAddress.setTextSize(12F);
addAddress.setPadding(5, 2, 2, 2);
addAddress.setSingleLine();
if (!isOtherTransactions) {
List<Address> allAddresses = Store.getAddresses();
Address address = Store.isAlreadyAddress(trans.getAddress(), allAddresses);
if (address != null) {
TextView addId = new TextView(context);
addId.setLayoutParams(param);
addId.setText("a" + address.getIndexName());
addId.setBackgroundColor(bgcolor);
addId.setPadding(2, 2, 2, 2);
addId.setTextColor(white);
layout.addView(addId);
}
}
layout.addView(addValue);
layout.addView(addAddress);
uselayout.addView(layout);
}
}
use of run.wallet.iota.model.TransferTransaction in project run-wallet-android by runplay.
the class WalletTransfersCardAdapter method load.
public static synchronized void load(Context context, boolean force) {
if (force || seed == null || (Store.getCurrentSeed() != null && !seed.id.equals(Store.getCurrentSeed().id)) || transfers.isEmpty()) {
if (context != null) {
transfers.clear();
transfers.addAll(Store.getTransfers());
if (filterAddress != null) {
List<Transfer> filtered = new ArrayList<>();
for (Transfer t : transfers) {
if (t.getAddress().equals(filterAddress))
filtered.add(t);
else {
boolean add = false;
for (TransferTransaction tt : t.getTransactions()) {
if (tt.getAddress().equals(filterAddress))
add = true;
}
if (add)
filtered.add(t);
}
}
transfers = filtered;
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
if (!prefs.getBoolean(Constants.PREFERENCES_SHOW_CANCELLED, true)) {
List<Transfer> lesscancelled = new ArrayList<>();
for (Transfer transfer : transfers) {
if (!transfer.isMarkDoubleSpend())
lesscancelled.add(transfer);
}
transfers = lesscancelled;
}
if (!prefs.getBoolean(Constants.PREFERENCES_SHOW_ATTACH, true)) {
List<Transfer> lessattach = new ArrayList<>();
for (Transfer transfer : transfers) {
if (transfer.getValue() != 0 || (transfer.getValue() == 0 && !transfer.getTransactions().isEmpty()))
lessattach.add(transfer);
}
transfers = lessattach;
}
int nudges = Sf.toInt(prefs.getString(Constants.PREF_TRANSFER_NUDGE_ATTEMPTS, "" + Constants.PREF_TRANSFER_NUDGE_ATTEMPTS_VALUE));
isAutoNudge = nudges == 0 ? false : true;
}
}
}
use of run.wallet.iota.model.TransferTransaction in project run-wallet-android by runplay.
the class Audit method processTransfersToAddresses.
private static ProcessResult processTransfersToAddresses(Seeds.Seed seed, List<Transfer> transfers, List<Address> allAddresses) {
Collections.sort(transfers);
Collections.reverse(transfers);
HashMap<String, Transfer> completed = new HashMap<String, Transfer>();
HashMap<String, Transfer> completedAddresses = new HashMap<String, Transfer>();
for (Transfer transfer : transfers) {
if (!transfer.getTransactions().isEmpty()) {
String key = transfer.getValue() + transfer.getAddress();
Transfer comp = completed.get(key);
if (comp == null) {
completed.put(key, transfer);
} else {
if (comp.isCompleted()) {
transfer.setMarkDoubleSpend(true);
} else {
comp.setMarkDoubleSpend(true);
completed.put(key, transfer);
}
}
if (transfer.isCompleted()) {
transfer.setMarkDoubleAddress(false);
transfer.setMarkDoubleSpend(false);
if (transfer.getTimestampConfirmed() == 0)
transfer.setTimestampConfirmed(System.currentTimeMillis());
for (TransferTransaction trans : transfer.getTransactions()) {
if (trans.getValue() < 0) {
// Log.e("AUDIT","comp address: "+trans.getValue()+" - "+trans.getAddress());
completedAddresses.put(trans.getAddress(), transfer);
}
}
}
}
}
for (Transfer transfer : transfers) {
if (!transfer.isCompleted() && !transfer.isMarkDoubleSpend()) {
// Log.e("AUDIT","check: "+transfer.getValue()+" - "+transfer.getHash());
List<String> testAddress = new ArrayList<>();
for (TransferTransaction trans : transfer.getTransactions()) {
if (trans.getValue() < 0) {
// Log.e("AUDIT","-address: "+trans.getValue()+" - "+trans.getAddress());
testAddress.add(trans.getAddress());
}
}
if (!testAddress.isEmpty()) {
for (String testadd : testAddress) {
Transfer completedOnTransfer = completedAddresses.get(testadd);
if (completedOnTransfer != null && !completedOnTransfer.getHash().equals(transfer.getHash())) {
Address tmpadd = Store.isAlreadyAddress(testadd, allAddresses);
if (tmpadd != null && tmpadd.getValue() == 0) {
// Log.e("AUDIT", "completedOnTransfer: " + completedOnTransfer.getValue() + " - " + completedOnTransfer.getAddress());
transfer.setMarkDoubleAddress(true);
}
}
}
}
}
}
long seedTotalPendingIn = 0;
long seedTotalPendingOut = 0;
List<TransferTransaction> already = new ArrayList<>();
for (Transfer transfer : transfers) {
if (transfer.isCompleted()) {
for (TransferTransaction trans : transfer.getTransactions()) {
Address address = Store.isAlreadyAddress(trans.getAddress(), allAddresses);
if (address != null) {
// address.setValue(address.getValue() + trans.getValue());
if (trans.getValue() < 0) {
address.setUsed(true);
}
}
}
} else if (!transfer.isCompleted()) {
if (transfer.isInternal() || (!transfer.isMarkDoubleSpend() && !transfer.isMarkDoubleAddress())) {
for (TransferTransaction trans : transfer.getTransactions()) {
Address address = Store.isAlreadyAddress(trans.getAddress(), allAddresses);
if (address != null) {
address.setPendingValue(address.getPendingValue() + trans.getValue());
if (trans.getValue() < 0) {
seedTotalPendingOut += trans.getValue();
} else {
seedTotalPendingIn += trans.getValue();
}
already.add(trans);
}
}
}
}
}
long seedTotal = 0;
for (Address address : allAddresses) {
seedTotal += address.getValue();
if (address.getPendingValue() != 0 && !address.isPigUser()) {
address.setPigInt(1);
}
}
// Log.e("SEED-TOTAL",seedTotal+" - pending out: "+seedTotalPendingOut);
ProcessResult result = new ProcessResult();
result.seedTotal = seedTotal;
result.seedTotalPendingIn = seedTotalPendingIn;
result.seedTotalPendingOut = seedTotalPendingOut;
return result;
}
Aggregations