Skip to content

Commit

Permalink
switch to ms for duration
Browse files Browse the repository at this point in the history
  • Loading branch information
niteshbalusu11 committed Dec 8, 2022
1 parent 2e6e4c5 commit 5929b36
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/migration/app-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export const appMigration: IAppMigration[] = [
// Version 32
{
async beforeLnd(db, i) {
await db.executeSql("ALTER TABLE tx ADD duration TEXT NULL");
await db.executeSql("ALTER TABLE tx ADD duration REAL NULL");
},
},
];
2 changes: 1 addition & 1 deletion src/state/Send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const send: ISendModel = {
throw new Error(`${translatePaymentFailureReason(sendPaymentResult.failureReason)}`);
}

const settlementDuration = (new Date().getTime() - start) / 1000 + "s";
const settlementDuration = (new Date().getTime() - start);

const transaction: ITransaction = {
date: paymentRequest.timestamp,
Expand Down
2 changes: 1 addition & 1 deletion src/storage/database/sqlite-migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const schema = [
`CREATE TABLE tx (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
date TEXT NOT NULL,
duration TEXT NULL,
duration REAL NULL,
expire TEXT NOT NULL,
value TEXT NOT NULL,
valueMsat TEXT NOT NULL,
Expand Down
4 changes: 3 additions & 1 deletion src/storage/database/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { hexToUint8Array, bytesToHexString } from "../../utils";
export interface IDBTransaction {
id: number;
date: string;
duration: number | null;
expire: string;
value: string;
valueMsat: string;
Expand Down Expand Up @@ -41,7 +42,7 @@ export interface IDBTransaction {
export interface ITransaction {
id?: number;
date: Long;
duration?: string;
duration: number | null;
expire: Long;
value: Long;
valueMsat: Long;
Expand Down Expand Up @@ -326,6 +327,7 @@ const convertDBTransaction = (transaction: IDBTransaction): ITransaction => {
return {
id: transaction.id!,
date: Long.fromString(transaction.date),
duration: transaction.duration,
expire: Long.fromString(transaction.expire),
value: Long.fromString(transaction.value),
valueMsat: Long.fromString(transaction.valueMsat),
Expand Down
2 changes: 1 addition & 1 deletion src/windows/Keysend/Experiment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default function KeysendTest({ navigation }: ILightningInfoProps) {
console.log("Payment request is " + result.paymentRequest);
console.log(typeof result.paymentRequest);

const settlementDuration = (new Date().getTime() - start) / 1000 + "s";
const settlementDuration = (new Date().getTime() - start);

const transaction: ITransaction = {
date: result.creationDate,
Expand Down
4 changes: 3 additions & 1 deletion src/windows/TransactionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { Alert } from "../utils/alert";
import { useTranslation } from "react-i18next";
import { namespaces } from "../i18n/i18n.constants";

const durationAsSeconds = (n: number) => `${n /1000}s`

interface IMetaDataProps {
title: string;
data: string;
Expand Down Expand Up @@ -237,7 +239,7 @@ export default function TransactionDetails({ route, navigation }: ITransactionDe
<MetaData title={t("generic.amount", { ns: namespaces.common })} data={formatBitcoin(transactionValue, bitcoinUnit)} />
{transaction.valueFiat != null && transaction.valueFiatCurrency && <MetaData title={t("amountInFiatTimeOfPayment")} data={`${transaction.valueFiat.toFixed(2)} ${transaction.valueFiatCurrency}`} />}
{transaction.fee !== null && transaction.fee !== undefined && <MetaData title={t("generic.fee", { ns: namespaces.common })} data={transaction.fee.toString() + " Satoshi"} />}
{transaction.duration && <MetaData title={t("duration")} data={transaction.duration} />}
{transaction.duration && <MetaData title={t("duration")} data={durationAsSeconds(transaction.duration)} />}
{transaction.hops && transaction.hops.length > 0 && <MetaData title={t("numberOfHops")} data={transaction.hops.length.toString()} />}
{direction === "send" && <MetaData title={t("remotePubkey")} data={transaction.remotePubkey} />}
<MetaData title={t("paymentHash")} data={transaction.rHash}/>
Expand Down

0 comments on commit 5929b36

Please sign in to comment.