use of run.wallet.iota.model.Address 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;
}
use of run.wallet.iota.model.Address in project run-wallet-android by runplay.
the class WalletAddressesFragment method onResume.
@Override
public void onResume() {
super.onResume();
if (Store.getNodeInfo() == null)
AppService.getNodeInfo(getActivity());
setAdapter(true);
attachingHandler.postDelayed(runAttaching, 500);
if (Store.getCurrentWallet() == null) {
// firstLoadPod.setVisibility(View.VISIBLE);
firstLoad.postDelayed(runFirstLoad, 500);
} else {
firstLoadPod.setVisibility(View.GONE);
confirmPod.setVisibility(View.GONE);
emptyAddresses.setVisibility(View.GONE);
}
if (Store.getCurrentWallet() != null) {
int countemptyattached = 0;
for (Address address : Store.getAddresses()) {
if (address.isAttached() && address.getValue() == 0 && !address.isUsed() && !address.isPig()) {
countemptyattached++;
}
}
int countmin = Store.getAutoAttach();
if (countemptyattached < countmin) {
AppService.auditAddresses(getActivity(), Store.getCurrentSeed());
}
}
}
use of run.wallet.iota.model.Address in project run-wallet-android by runplay.
the class WalletTransfersFragment method setAdapterOld.
private void setAdapterOld(boolean force) {
if (recyclerView != null) {
if (adapter == null) {
firstVis = 0;
adapter = new WalletTransfersCardAdapter(getActivity(), force);
} else {
firstVis = recyclerView.getVerticalScrollbarPosition();
if (force) {
WalletTransfersCardAdapter.load(getActivity(), true);
}
}
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
if (adapter.getItemCount() != 0) {
emptyTransfers.setVisibility(View.GONE);
firstLoadPod.setVisibility(View.GONE);
} else {
if (Store.getCurrentWallet() != null) {
emptyTransfers.setVisibility(View.VISIBLE);
}
}
filterBar.setVisibility(View.GONE);
if (WalletTransfersCardAdapter.getFilterAddress() != null) {
Address address = Store.isAlreadyAddress(WalletTransfersCardAdapter.getFilterAddress(), Store.getAddresses());
if (address != null) {
filterBar.setVisibility(View.VISIBLE);
filterBar.setBackgroundColor(AppTheme.getColorPrimaryDark(getActivity()));
IotaToText.IotaDisplayData data = IotaToText.getIotaDisplayData(address.getValue());
filterAddress.setText(address.getAddress());
filterId.setText(WalletTransfersCardAdapter.getFilterAddressId());
filterBalance.setText(data.value);
filterBalanceThird.setText(data.thirdDecimal);
filterBalanceUnit.setText(data.unit);
}
}
recyclerView.scrollToPosition(firstVis);
}
}
Aggregations