Browse Source

SimpleTransaction.timestamp is now in milliseconds instead of seconds.

Should fix 1970 timestamp issue in UI for foreign transactions, and also maintains consistency with QORT wallet transactions.
increase-online-timestamp-modulus
CalDescent 2 years ago
parent
commit
ca7d58c272
  1. 7
      src/main/java/org/qortal/crosschain/Bitcoiny.java
  2. 6
      src/main/java/org/qortal/crosschain/SimpleTransaction.java

7
src/main/java/org/qortal/crosschain/Bitcoiny.java

@ -375,7 +375,7 @@ public abstract class Bitcoiny implements ForeignBlockchain {
public Long getWalletBalanceFromTransactions(String key58) throws ForeignBlockchainException { public Long getWalletBalanceFromTransactions(String key58) throws ForeignBlockchainException {
long balance = 0; long balance = 0;
Comparator<SimpleTransaction> oldestTimestampFirstComparator = Comparator.comparingInt(SimpleTransaction::getTimestamp); Comparator<SimpleTransaction> oldestTimestampFirstComparator = Comparator.comparingLong(SimpleTransaction::getTimestamp);
List<SimpleTransaction> transactions = getWalletTransactions(key58).stream().sorted(oldestTimestampFirstComparator).collect(Collectors.toList()); List<SimpleTransaction> transactions = getWalletTransactions(key58).stream().sorted(oldestTimestampFirstComparator).collect(Collectors.toList());
for (SimpleTransaction transaction : transactions) { for (SimpleTransaction transaction : transactions) {
balance += transaction.getTotalAmount(); balance += transaction.getTotalAmount();
@ -455,7 +455,7 @@ public abstract class Bitcoiny implements ForeignBlockchain {
// Process new keys // Process new keys
} while (true); } while (true);
Comparator<SimpleTransaction> newestTimestampFirstComparator = Comparator.comparingInt(SimpleTransaction::getTimestamp).reversed(); Comparator<SimpleTransaction> newestTimestampFirstComparator = Comparator.comparingLong(SimpleTransaction::getTimestamp).reversed();
// Update cache and return // Update cache and return
transactionsCacheTimestamp = NTP.getTime(); transactionsCacheTimestamp = NTP.getTime();
@ -537,7 +537,8 @@ public abstract class Bitcoiny implements ForeignBlockchain {
// All inputs and outputs relate to this wallet, so the balance should be unaffected // All inputs and outputs relate to this wallet, so the balance should be unaffected
amount = 0; amount = 0;
} }
return new SimpleTransaction(t.txHash, t.timestamp, amount, fee, inputs, outputs); long timestampMillis = t.timestamp * 1000L;
return new SimpleTransaction(t.txHash, timestampMillis, amount, fee, inputs, outputs);
} }
/** /**

6
src/main/java/org/qortal/crosschain/SimpleTransaction.java

@ -7,7 +7,7 @@ import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class SimpleTransaction { public class SimpleTransaction {
private String txHash; private String txHash;
private Integer timestamp; private Long timestamp;
private long totalAmount; private long totalAmount;
private long feeAmount; private long feeAmount;
private List<Input> inputs; private List<Input> inputs;
@ -74,7 +74,7 @@ public class SimpleTransaction {
public SimpleTransaction() { public SimpleTransaction() {
} }
public SimpleTransaction(String txHash, Integer timestamp, long totalAmount, long feeAmount, List<Input> inputs, List<Output> outputs) { public SimpleTransaction(String txHash, Long timestamp, long totalAmount, long feeAmount, List<Input> inputs, List<Output> outputs) {
this.txHash = txHash; this.txHash = txHash;
this.timestamp = timestamp; this.timestamp = timestamp;
this.totalAmount = totalAmount; this.totalAmount = totalAmount;
@ -87,7 +87,7 @@ public class SimpleTransaction {
return txHash; return txHash;
} }
public Integer getTimestamp() { public Long getTimestamp() {
return timestamp; return timestamp;
} }

Loading…
Cancel
Save