diff --git a/CHANGELOG.md b/CHANGELOG.md index ed9a11e6cb..06c45d8c03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Reduced support for BitBox01 - Fix a bug that would prevent the app to perform firmware upgrade when offline. - Replace sidebar with bottom navigation bar for mobile devices +- Add received date to coin control transaction details # v4.47.2 - Linux: fix compatiblity with some versions of Mesa that are incompatible with the bundled wayland libraries diff --git a/backend/coins/btc/account.go b/backend/coins/btc/account.go index 9268fe9711..0e6f9af9cf 100644 --- a/backend/coins/btc/account.go +++ b/backend/coins/btc/account.go @@ -23,6 +23,7 @@ import ( "path" "sort" "sync/atomic" + "time" "github.com/BitBoxSwiss/bitbox-wallet-app/backend/accounts" accountsTypes "github.com/BitBoxSwiss/bitbox-wallet-app/backend/accounts/types" @@ -840,9 +841,10 @@ func sortByAddresses(result []*SpendableOutput) []*SpendableOutput { // SpendableOutput is an unspent coin. type SpendableOutput struct { *transactions.SpendableOutput - OutPoint wire.OutPoint - Address *addresses.AccountAddress - IsChange bool + OutPoint wire.OutPoint + Address *addresses.AccountAddress + IsChange bool + HeaderTimestamp *time.Time } // SpendableOutputs returns the utxo set, sorted by the value descending. @@ -856,6 +858,10 @@ func (account *Account) SpendableOutputs() []*SpendableOutput { } for outPoint, txOut := range utxos { scriptHashHex := blockchain.NewScriptHashHex(txOut.TxOut.PkScript) + headerTimestamp, err := account.transactions.GetHeaderTimestamp(outPoint.Hash) + if err != nil { + headerTimestamp = nil + } result = append( result, &SpendableOutput{ @@ -863,6 +869,7 @@ func (account *Account) SpendableOutputs() []*SpendableOutput { SpendableOutput: txOut, Address: account.getAddress(scriptHashHex), IsChange: account.IsChange(scriptHashHex), + HeaderTimestamp: headerTimestamp, }) } return sortByAddresses(result) diff --git a/backend/coins/btc/handlers/handlers.go b/backend/coins/btc/handlers/handlers.go index 73f691bd69..bd622c2db1 100644 --- a/backend/coins/btc/handlers/handlers.go +++ b/backend/coins/btc/handlers/handlers.go @@ -365,15 +365,16 @@ func (handlers *Handlers) getUTXOs(*http.Request) (interface{}, error) { result = append(result, map[string]interface{}{ - "outPoint": output.OutPoint.String(), - "txId": output.OutPoint.Hash.String(), - "txOutput": output.OutPoint.Index, - "amount": handlers.formatBTCAmountAsJSON(btcutil.Amount(output.TxOut.Value), false), - "address": address, - "scriptType": output.Address.Configuration.ScriptType(), - "note": handlers.account.TxNote(output.OutPoint.Hash.String()), - "addressReused": addressReused, - "isChange": output.IsChange, + "outPoint": output.OutPoint.String(), + "txId": output.OutPoint.Hash.String(), + "txOutput": output.OutPoint.Index, + "amount": handlers.formatBTCAmountAsJSON(btcutil.Amount(output.TxOut.Value), false), + "address": address, + "scriptType": output.Address.Configuration.ScriptType(), + "note": handlers.account.TxNote(output.OutPoint.Hash.String()), + "addressReused": addressReused, + "isChange": output.IsChange, + "headerTimestamp": output.HeaderTimestamp, }) } diff --git a/backend/coins/btc/transactions/transactions.go b/backend/coins/btc/transactions/transactions.go index aa288c4f8d..2eb4cfe73d 100644 --- a/backend/coins/btc/transactions/transactions.go +++ b/backend/coins/btc/transactions/transactions.go @@ -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) { + txInfo, err := dbTx.TxInfo(txHash) + if err != nil { + return nil, err + } + return txInfo.HeaderTimestamp, nil + }) +} + func (transactions *Transactions) isInputSpent(dbTx DBTxInterface, outPoint wire.OutPoint) bool { input, err := dbTx.Input(outPoint) if err != nil { diff --git a/frontends/web/src/api/account.ts b/frontends/web/src/api/account.ts index 450aab7000..f0b54713f5 100644 --- a/frontends/web/src/api/account.ts +++ b/frontends/web/src/api/account.ts @@ -408,6 +408,7 @@ export type TUTXO = { scriptType: ScriptType; addressReused: boolean; isChange: boolean; + headerTimestamp: string; }; export const getUTXOs = (code: AccountCode): Promise => { diff --git a/frontends/web/src/components/transactions/transaction.tsx b/frontends/web/src/components/transactions/transaction.tsx index 800a9d6a8a..d109df23cd 100644 --- a/frontends/web/src/components/transactions/transaction.tsx +++ b/frontends/web/src/components/transactions/transaction.tsx @@ -190,7 +190,7 @@ type TDateProps = { time: string | null; } -const Date = ({ +export const Date = ({ time, }: TDateProps) => { const { i18n } = useTranslation(); diff --git a/frontends/web/src/locales/en/app.json b/frontends/web/src/locales/en/app.json index a9fad75145..ed836804b5 100644 --- a/frontends/web/src/locales/en/app.json +++ b/frontends/web/src/locales/en/app.json @@ -1660,6 +1660,7 @@ "addressReused": "Address re-used", "change": "Change", "outpoint": "Outpoint", + "receivedDate": "Received date", "title": "Send from output" }, "confirm": { diff --git a/frontends/web/src/routes/account/send/utxos.module.css b/frontends/web/src/routes/account/send/utxos.module.css index f4f9c8b2d1..2022ce08dc 100644 --- a/frontends/web/src/routes/account/send/utxos.module.css +++ b/frontends/web/src/routes/account/send/utxos.module.css @@ -69,6 +69,7 @@ } .address, +.date, .transaction { display: flex; font-size: var(--size-default); diff --git a/frontends/web/src/routes/account/send/utxos.tsx b/frontends/web/src/routes/account/send/utxos.tsx index 72ea7585ac..4f58c87cef 100644 --- a/frontends/web/src/routes/account/send/utxos.tsx +++ b/frontends/web/src/routes/account/send/utxos.tsx @@ -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 = ({ +
+ + {t('send.coincontrol.receivedDate')}: + + + + +
{t('send.coincontrol.address')}: