-
Notifications
You must be signed in to change notification settings - Fork 101
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ | |
package transactions | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/BitBoxSwiss/bitbox-wallet-app/backend/accounts" | ||
"github.com/BitBoxSwiss/bitbox-wallet-app/backend/coins/btc/blockchain" | ||
"github.com/BitBoxSwiss/bitbox-wallet-app/backend/coins/btc/headers" | ||
|
@@ -221,6 +223,18 @@ func (transactions *Transactions) SpendableOutputs() (map[wire.OutPoint]*Spendab | |
}) | ||
} | ||
|
||
// 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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, err := dbTx.TxInfo(txHash) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return txInfo.HeaderTimestamp, nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HeaderTimestamp is It would probably be good to add a method |
||
}) | ||
} | ||
|
||
func (transactions *Transactions) isInputSpent(dbTx DBTxInterface, outPoint wire.OutPoint) bool { | ||
input, err := dbTx.Input(outPoint) | ||
if err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -408,6 +408,7 @@ export type TUTXO = { | |
scriptType: ScriptType; | ||
addressReused: boolean; | ||
isChange: boolean; | ||
headerTimestamp: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think in theory both the HeaderTimestamp and the CreatedTimestamp could be |
||
}; | ||
|
||
export const getUTXOs = (code: AccountCode): Promise<TUTXO[]> => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,7 @@ | |
} | ||
|
||
.address, | ||
.date, | ||
.transaction { | ||
display: flex; | ||
font-size: var(--size-default); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ import { FiatConversion } from '@/components/rates/rates'; | |
import { getScriptName } from '@/routes/account/utils'; | ||
import { Message } from '@/components/message/message'; | ||
import { Badge } from '@/components/badge/badge'; | ||
import { Date } from '@/components/transactions/transaction'; | ||
import style from './utxos.module.css'; | ||
|
||
export type TSelectedUTXOs = { | ||
|
@@ -127,6 +128,14 @@ export const UTXOs = ({ | |
</span> | ||
<FiatConversion alwaysShowAmounts amount={utxo.amount} unstyled noAction/> | ||
</div> | ||
<div className={style.date}> | ||
<span className={style.label}> | ||
{t('send.coincontrol.receivedDate')}: | ||
</span> | ||
<span className={style.shrink}> | ||
<Date time={utxo.headerTimestamp} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please dont' hardcode 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" |
||
</span> | ||
</div> | ||
<div className={style.address}> | ||
<span className={style.label}> | ||
{t('send.coincontrol.address')}: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't the timestamp need to be formatted like here?
https://github.com/BitBoxSwiss/bitbox-wallet-app/blob/master/backend/coins/btc/handlers/handlers.go#L215