Skip to content

frontend: add received date to coin control UTXO list #3249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

strmci
Copy link
Collaborator

@strmci strmci commented Mar 24, 2025

Add the received date (block header timestamp) to the UTXO detail in the coin control view. This makes it easier for users to view the date, which can be helpful for various reasons, without having to open each UTXO individually in the block explorer.

Add the received date (block header timestamp) to the UTXO detail in the
coin control view. This makes it easier for users to view the date, which can
be helpful for various reasons, without having to open each UTXO
individually in the block explorer.
@strmci strmci force-pushed the received_date_to_coin_control branch from a29ba3c to df304dd Compare March 24, 2025 16:29
@strmci strmci requested a review from Beerosagos March 24, 2025 16:30
@strmci strmci changed the title frontend: Add received date to coin control UTXO list frontend: add received date to coin control UTXO list Mar 24, 2025
// GetHeaderTimestamp retrieves the header timestamp for a given transaction hash.
func (transactions *Transactions) GetHeaderTimestamp(txHash chainhash.Hash) (*time.Time, error) {
transactions.synchronizer.WaitSynchronized()
return DBView(transactions.db, func(dbTx DBTxInterface) (*time.Time, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds one dbTx per UTXO. In transactions.SpendableOutputs() we aleady call TxInfo() on each UTXO, so it would be more natural to simply fetch the timestamp there.

if err != nil {
return nil, err
}
return txInfo.HeaderTimestamp, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HeaderTimestamp is nil when the utxo is unconfirmed. If nil you should take the CreatedTimestamp, like here:

https://github.com/BitBoxSwiss/bitbox-wallet-app/blob/master/backend/coins/btc/handlers/handlers.go#L205-L208

It would probably be good to add a method Timestamp() to the TransactionData struct and add this logic there.

"note": handlers.account.TxNote(output.OutPoint.Hash.String()),
"addressReused": addressReused,
"isChange": output.IsChange,
"headerTimestamp": output.HeaderTimestamp,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -408,6 +408,7 @@ export type TUTXO = {
scriptType: ScriptType;
addressReused: boolean;
isChange: boolean;
headerTimestamp: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in theory both the HeaderTimestamp and the CreatedTimestamp could be nil, so that means headerTimestamp should be string | null.

{t('send.coincontrol.receivedDate')}:
</span>
<span className={style.shrink}>
<Date time={utxo.headerTimestamp} />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this date format is used in the tx list of the account, but there the transactions are sorted by time. Here I find it a bit confusing to see dates like Saturday, March 22 or Wednesday, October 30, 2024. I think it would be easier to have a dd/mm/YYYY format or similar.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please dont' hardcode dd/mm/YYYY but use {parseTimeShort(utxo.headerTimestamp, i18n.language)}, so the date is localized and short.

new Date().toLocaleString('en-US', {
      month: 'short',
      day: 'numeric',
      year: 'numeric'
    })
"Apr 4, 2025" 

new Date().toLocaleString('de-CH', {
      month: 'short',
      day: 'numeric',
      year: 'numeric'
    })
"4. Apr. 2025" 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants