Use Transaction.getIncludedInBestChainAt()

This commit is contained in:
Oscar Guindzberg 2019-01-22 19:19:10 -03:00
parent 6c09a671a5
commit 3476765a90
4 changed files with 7 additions and 4 deletions

View file

@ -592,6 +592,7 @@ public abstract class WalletService {
}
public List<Transaction> getRecentTransactions(int numTransactions, boolean includeDead) {
// Returns a list ordered by tx.getUpdateTime() desc
return wallet.getRecentTransactions(numTransactions, includeDead);
}

View file

@ -752,7 +752,8 @@ public abstract class Trade implements Tradable, Model {
if (depositTx != null && getTakeOfferDate() != null) {
if (depositTx.getConfidence().getDepthInBlocks() > 0) {
final long tradeTime = getTakeOfferDate().getTime();
long blockTime = depositTx.getUpdateTime().getTime();
// Use tx.getIncludedInBestChainAt() when available, otherwise use tx.getUpdateTime()
long blockTime = depositTx.getIncludedInBestChainAt() != null ? depositTx.getIncludedInBestChainAt().getTime() : depositTx.getUpdateTime().getTime();
// If block date is in future (Date in Bitcoin blocks can be off by +/- 2 hours) we use our current date.
// If block date is earlier than our trade date we use our trade date.
if (blockTime > now)

View file

@ -265,7 +265,8 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
bsqWalletService,
btcWalletService,
daoFacade,
transaction.getUpdateTime(),
// Use tx.getIncludedInBestChainAt() when available, otherwise use tx.getUpdateTime()
transaction.getIncludedInBestChainAt() != null ? transaction.getIncludedInBestChainAt() : transaction.getUpdateTime(),
bsqFormatter);
})
.collect(Collectors.toList());

View file

@ -221,8 +221,8 @@ class TransactionsListItem {
else if (details.isEmpty())
details = Res.get("funds.tx.txFeePaymentForBsqTx");
}
date = transaction.getUpdateTime();
// Use tx.getIncludedInBestChainAt() when available, otherwise use tx.getUpdateTime()
date = transaction.getIncludedInBestChainAt() != null ? transaction.getIncludedInBestChainAt() : transaction.getUpdateTime();
dateString = formatter.formatDateTime(date);
}