diff --git a/src/i18n_messages/en.json b/src/i18n_messages/en.json
index 336ae46..70b9a15 100644
--- a/src/i18n_messages/en.json
+++ b/src/i18n_messages/en.json
@@ -487,11 +487,12 @@
},
"tranDetailScreen": {
"amount": "Amount",
+ "paymentId": "Payment ID",
"balanceAfter": "Balance after this transaction",
"claim": "Claim",
"createdAt": "Created at",
"expiresAt": "Expires at",
- "id": "ID",
+ "id": "Transaction ID",
"invoice": "Lightning invoice to pay",
"isOffline": "Redeem online",
"lightningFee": "Lightning network fee",
diff --git a/src/screens/CashuPaymentRequestScreen.tsx b/src/screens/CashuPaymentRequestScreen.tsx
index 8df0f13..4792c17 100644
--- a/src/screens/CashuPaymentRequestScreen.tsx
+++ b/src/screens/CashuPaymentRequestScreen.tsx
@@ -8,7 +8,7 @@ import { useStores } from "../models"
import { MintBalanceSelector } from "./Mints/MintBalanceSelector"
import { CurrencyAmount } from "./Wallet/CurrencyAmount"
import EventEmitter from '../utils/eventEmitter'
-import { getCurrency, MintUnit, CurrencyCode } from "../services/wallet/currency"
+import { getCurrency, MintUnit, CurrencyCode, convertToFromSats } from "../services/wallet/currency"
import { round, toNumber } from "../utils/number"
import { translate } from "../i18n"
import AppError, { Err } from "../utils/AppError"
@@ -25,7 +25,6 @@ import {
Text,
} from "../components"
import useIsInternetReachable from "../utils/useIsInternetReachable"
-import { PaymentRequest} from "@cashu/cashu-ts"
import {HANDLE_RECEIVED_EVENT_TASK, log, TransactionTaskResult, WalletTask } from "../services"
import { QRCodeBlock } from "./Wallet/QRCode"
import { TranItem } from "./TranDetailScreen"
@@ -33,6 +32,7 @@ import { Transaction, TransactionStatus } from "../models/Transaction"
import { CASHU_PAYMENT_REQUEST_TASK } from "../services/wallet/cashuPaymentRequestTask"
import { ResultModalInfo } from "./Wallet/ResultModalInfo"
import { MintHeader } from "./Mints/MintHeader"
+import { verticalScale } from "@gocodingnow/rn-size-matters"
type Props = StaticScreenProps<{
unit: MintUnit,
@@ -327,32 +327,30 @@ const headerBg = useThemeColor("header")
const placeholderTextColor = useThemeColor("textDim")
const amountInputColor = useThemeColor("amountInput")
const inputText = useThemeColor("text")
-const convertedAmountColor = useThemeColor("headerSubTitle")
+ const convertedAmountColor = useThemeColor('headerSubTitle')
-const getConvertedAmount = () => {
- if (!walletStore.exchangeRate) return undefined
- const precision = getCurrency(unit).precision
- return (
- round(toNumber(amountToRequest) * precision, 0) &&
- walletStore.exchangeRate &&
- walletStore.exchangeRate[getCurrency(unit).code]
- ? round(
- (toNumber(amountToRequest) * precision * walletStore.exchangeRate[userSettingsStore.exchangeCurrency]) /
- walletStore.exchangeRate[getCurrency(unit).code],
- 2,
+ const getConvertedAmount = function () {
+ if (!walletStore.exchangeRate) {
+ return undefined
+ }
+
+ const precision = getCurrency(unit).precision
+ return convertToFromSats(
+ round(toNumber(amountToRequest) * precision, 0) || 0,
+ getCurrency(unit).code,
+ walletStore.exchangeRate
)
- : undefined
- )
-}
+ }
+
+ const isConvertedAmountVisible = function () {
+ return (
+ walletStore.exchangeRate &&
+ (userSettingsStore.exchangeCurrency === getCurrency(unit).code ||
+ unit === 'sat') &&
+ getConvertedAmount() !== undefined
+ )
+ }
-const isConvertedAmountVisible = () => {
- return (
- walletStore.exchangeRate &&
- (userSettingsStore.exchangeCurrency === getCurrency(unit).code ||
- unit === "sat") &&
- getConvertedAmount() !== undefined
- )
-}
return (
@@ -380,26 +378,15 @@ return (
selectTextOnFocus={true}
returnKeyType={"done"}
/>
- {isConvertedAmountVisible() && (
-
+ {isConvertedAmountVisible() && (
+
)}
(null) // Initialize pubkeyInputRef
// Offline send
useEffect(() => {
- if(isInternetReachable) return
+ //if(isInternetReachable) return
log.trace('[Offline send]')
// if offline we set all non-zero mint balances as available to allow ecash selection
@@ -436,7 +436,7 @@ const pubkeyInputRef = useRef(null) // Initialize pubkeyInputRef
setAvailableMintBalances(availableBalances)
setMintBalanceToSendFrom(availableBalances[0])
setIsMintSelectorVisible(true)
- }, [isInternetReachable])
+ }, [])
useEffect(() => {
@@ -1427,6 +1427,7 @@ const SelectProofsBlock = observer(function (props: {
const {proofsStore} = useStores()
const hintColor = useThemeColor('textDim')
+ const statusColor = useThemeColor('header')
const onCancel = function () {
@@ -1436,13 +1437,48 @@ const SelectProofsBlock = observer(function (props: {
return (
+
+
+
+
-
+
data={proofsStore.getByMint(props.mintBalanceToSendFrom.mintUrl, {isPending: false, unit: props.unit})}
renderItem={({ item }) => {
@@ -1464,21 +1500,6 @@ const SelectProofsBlock = observer(function (props: {
/>
-
-
-
- }
- onPress={gotoContacts}
- text='Contacts'
- textStyle={{fontSize: 12, color: contactIcon}}
- />
- }*/
- />
- }
+
- setShowTokenInput((v) => !v)}
/>
-
- setEncodedToken(data)}
- value={encodedToken}
- autoCapitalize='none'
- keyboardType='default'
- maxLength={5000}
- numberOfLines={3}
- multiline={true}
- selectTextOnFocus={true}
- style={[$addressInput, {backgroundColor: inputBg, color: inputText}]}
- />
-
- {!!encodedToken && encodedToken?.length > 1 ? (
-
-
+
+
+ (
+
+ )}
+ onPress={gotoScan}
+ style={{backgroundColor: mainButtonColor}}
+ text='Scan'
+ />
+
+
{error && }
)
@@ -303,10 +285,9 @@ const $screen: ViewStyle = {
}
const $contentContainer: ViewStyle = {
- // flex: 1,
marginTop: -spacing.extraLarge * 2,
padding: spacing.extraSmall,
- // alignItems: 'center',
+ flex: 1
}
const $headerContainer: TextStyle = {
@@ -316,12 +297,11 @@ const $headerContainer: TextStyle = {
}
const $buttonContainer: ViewStyle = {
- marginTop: spacing.large,
+ //marginTop: spacing.large,
flexDirection: 'row',
alignSelf: 'center',
}
-
const $addressInput: TextStyle = {
textAlignVertical: 'top' ,
borderRadius: spacing.extraSmall,
@@ -330,15 +310,21 @@ const $addressInput: TextStyle = {
height: verticalScale(70),
}
+
+const $card: ViewStyle = {
+ marginBottom: 0,
+}
+
const $bottomContainer: ViewStyle = {
- position: 'absolute',
+ /*position: 'absolute',
bottom: 0,
left: 0,
right: 0,
flex: 1,
justifyContent: 'flex-end',
- marginBottom: spacing.medium,
- alignSelf: 'stretch',
+ marginBottom: spacing.medium,*/
+ alignSelf: 'center',
// opacity: 0,
-}
+ }
+
diff --git a/src/screens/TranDetailScreen.tsx b/src/screens/TranDetailScreen.tsx
index 2e99856..8a37999 100644
--- a/src/screens/TranDetailScreen.tsx
+++ b/src/screens/TranDetailScreen.tsx
@@ -232,6 +232,7 @@ export const TranDetailScreen = observer(function TranDetailScreen({ route }: Pr
const colorScheme = useColorScheme()
const headerTitle = useThemeColor('headerTitle')
const inputText = useThemeColor('text')
+ const statusColor = useThemeColor('header')
return (
@@ -253,7 +254,32 @@ export const TranDetailScreen = observer(function TranDetailScreen({ route }: Pr
preset="heading"
text={getFormattedAmount()}
style={[$tranAmount, {color: headerTitle}]}
- />
+ />
+ {transaction.status !== TransactionStatus.COMPLETED && (
+
+
+
+ )}
+ {transaction.memo && (
+ )}
{transaction.sentFrom && (
<>
{profilePicture ? (
@@ -823,6 +852,12 @@ const ReceiveInfoBlock = function (props: {
label="tranDetailScreen.createdAt"
value={(transaction.createdAt as Date).toLocaleString()}
/>
+ {transaction.paymentId && (
+
+ )}
>
}
@@ -1037,6 +1072,12 @@ const ReceiveOfflineInfoBlock = function (props: {
label="tranDetailScreen.createdAt"
value={(transaction.createdAt as Date).toLocaleString()}
/>
+ {transaction.paymentId && (
+
+ )}
>
}
@@ -1503,7 +1544,13 @@ const TopupInfoBlock = function (props: {
label="tranDetailScreen.expiresAt"
value={(new Date(paymentRequest.expiresAt!)).toLocaleString()}
/>
- )}
+ )}
+ {transaction.paymentId && (
+
+ )}
>
}
@@ -1748,6 +1795,12 @@ const TransferInfoBlock = function (props: {
label="tranDetailScreen.createdAt"
value={(transaction.createdAt as Date).toLocaleString()}
/>
+ {transaction.paymentId && (
+
+ )}
>
}
@@ -2003,7 +2056,7 @@ const $contentContainer: TextStyle = {
const $tranAmount: TextStyle = {
fontSize: verticalScale(48),
lineHeight: verticalScale(48),
- marginLeft: -20,
+ //marginLeft: -20,
}
const $actionCard: ViewStyle = {
diff --git a/src/screens/Transactions/TransactionListItem.tsx b/src/screens/Transactions/TransactionListItem.tsx
index 4e182dc..4ab3bcc 100644
--- a/src/screens/Transactions/TransactionListItem.tsx
+++ b/src/screens/Transactions/TransactionListItem.tsx
@@ -62,6 +62,14 @@ export const TransactionListItem = observer(function (props: TransactionListProp
} else {
return tx.memo ? tx.memo : translate('transactionCommon.youReceived')
}
+ case TransactionType.RECEIVE_BY_PAYMENT_REQUEST:
+ if (tx.sentFrom) {
+ if (!tx.memo || tx.memo.includes('Sent from Minibits')) {
+ return translate('transactionCommon.from', {sender: getProfileName(tx.sentFrom)})
+ }
+ } else {
+ return tx.memo ? tx.memo : translate('transactionCommon.youReceived')
+ }
case TransactionType.RECEIVE_OFFLINE:
if (tx.sentFrom) {
if (!tx.memo || tx.memo.includes('Sent from Minibits')) {
diff --git a/src/services/lightning/lightningUtils.ts b/src/services/lightning/lightningUtils.ts
index 7bd2b52..af82982 100644
--- a/src/services/lightning/lightningUtils.ts
+++ b/src/services/lightning/lightningUtils.ts
@@ -57,7 +57,13 @@ const extractEncodedLightningInvoice = function (maybeInvoice: string) {
return encodedInvoice
}
- if (maybeInvoice && maybeInvoice.toLowerCase().startsWith('bitcoin:' || 'http')) {
+ if (
+ maybeInvoice &&
+ (
+ maybeInvoice.toLowerCase().startsWith('bitcoin:') ||
+ maybeInvoice.toLowerCase().startsWith('http')
+ )
+ ) {
const url = new URL(maybeInvoice.toLowerCase())
// Use URLSearchParams to get the value of the "lightning" parameter
encodedInvoice = url.searchParams.get("lightning") as string
diff --git a/src/services/wallet/cashuPaymentRequestTask.ts b/src/services/wallet/cashuPaymentRequestTask.ts
index f956401..3582d34 100644
--- a/src/services/wallet/cashuPaymentRequestTask.ts
+++ b/src/services/wallet/cashuPaymentRequestTask.ts
@@ -78,7 +78,7 @@ export const cashuPaymentRequestTask = async function (
},
] as PaymentRequestTransport[]
- const cashuPrId = QuickCrypto.randomBytes(16).toString("hex")
+ const cashuPrId = QuickCrypto.randomBytes(4).toString("hex")
const cashuPaymentRequest = new CashuPaymentRequest(
transport,
cashuPrId,
diff --git a/src/services/wallet/transferTask.ts b/src/services/wallet/transferTask.ts
index 1385bd6..a304d49 100644
--- a/src/services/wallet/transferTask.ts
+++ b/src/services/wallet/transferTask.ts
@@ -11,6 +11,7 @@ import { WalletUtils } from './utils'
import {isBefore} from 'date-fns'
import { MintUnit, formatCurrency, getCurrency } from './currency'
import { NostrEvent } from '../nostrService'
+import { LightningUtils } from '../lightning/lightningUtils'
const {
transactionsStore,
@@ -77,6 +78,8 @@ export const transferTask = async function (
// store tx in db and in the model
transaction = await transactionsStore.addTransaction(newTransaction)
const transactionId = transaction.id
+ const paymentHash = LightningUtils.getInvoiceData(LightningUtils.decodeInvoice(encodedInvoice)).payment_hash
+ transaction.setPaymentId(paymentHash)
if (amountToTransfer + meltQuote.fee_reserve > mintBalanceToTransferFrom.balances[unit]!) {
throw new AppError(
@@ -263,7 +266,7 @@ export const transferTask = async function (
)
const balanceAfter = proofsStore.getUnitBalance(unit)?.unitBalance!
- transaction.setBalanceAfter(balanceAfter)
+ transaction.setBalanceAfter(balanceAfter)
return {
taskFunction: TRANSFER_TASK,