Skip to content

Commit

Permalink
Use Transaction.getIncludedInBestChainAt()
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarguindzberg committed Jan 24, 2019
1 parent 8b28f73 commit 2f324c4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/src/main/java/bisq/core/btc/wallet/WalletService.java
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ public boolean isEncrypted() {
}

public List<Transaction> getRecentTransactions(int numTransactions, boolean includeDead) {
// Returns a list ordered by tx.getUpdateTime() desc
return wallet.getRecentTransactions(numTransactions, includeDead);
}

Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/bisq/core/trade/Trade.java
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,8 @@ private long getTradeStartTime() {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ private void updateList() {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ else if (!txFeeForBsqPayment)
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);
}

Expand Down

0 comments on commit 2f324c4

Please sign in to comment.