mirror of
https://github.com/minibits-cash/minibits_wallet.git
synced 2026-10-05 19:28:26 +00:00
more work
This commit is contained in:
@@ -0,0 +1 @@
|
||||
cache
|
||||
@@ -8,7 +8,7 @@
|
||||
"modules": [
|
||||
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-empty-pattern@latest/dist/index.js",
|
||||
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-without-source@latest/dist/index.js",
|
||||
"https://cdn.jsdelivr.net/gh/KraXen72/inlang-t-function-jsx-hybrid-matcher/dist/index.js",
|
||||
"https://cdn.jsdelivr.net/gh/KraXen72/inlang-t-function-jsx-hybrid-matcher@021003e/dist/index.js",
|
||||
"https://cdn.jsdelivr.net/npm/@inlang/plugin-json@latest/dist/index.js"
|
||||
],
|
||||
"plugin.inlang.json": {
|
||||
@@ -22,6 +22,10 @@
|
||||
"preferredTfuncName": "translate",
|
||||
"recognizedTfuncNames": [
|
||||
"translate"
|
||||
],
|
||||
"recognizedJSXAttributes": [
|
||||
"tx",
|
||||
"subTx"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,19 @@ interface MemoInputProps {
|
||||
setMemo: (memo: string) => void
|
||||
disabled?: boolean
|
||||
onMemoDone: () => void
|
||||
onMemoEndEditing: () => void
|
||||
onMemoEndEditing?: () => void
|
||||
maxLength?: number
|
||||
}
|
||||
|
||||
export const MemoInputCard = forwardRef<TextInput, MemoInputProps>((props, memoInputRef) => {
|
||||
const {memo, setMemo, disabled = true, onMemoDone, onMemoEndEditing} = props
|
||||
const {
|
||||
memo,
|
||||
setMemo,
|
||||
disabled = true,
|
||||
onMemoDone,
|
||||
onMemoEndEditing = () => {},
|
||||
maxLength = 200,
|
||||
} = props
|
||||
return (
|
||||
<Card
|
||||
style={$memoCard}
|
||||
@@ -26,7 +34,7 @@ export const MemoInputCard = forwardRef<TextInput, MemoInputProps>((props, memoI
|
||||
onEndEditing={onMemoEndEditing}
|
||||
value={`${memo}`}
|
||||
style={$memoInput}
|
||||
maxLength={200}
|
||||
maxLength={maxLength}
|
||||
keyboardType="default"
|
||||
selectTextOnFocus={true}
|
||||
placeholder={translate('sendScreen.memo')}
|
||||
|
||||
@@ -4,7 +4,6 @@ import {Switch, TextStyle, View, ViewStyle} from 'react-native'
|
||||
import {colors, spacing, useThemeColor} from '../theme'
|
||||
import {SettingsStackScreenProps} from '../navigation'
|
||||
import {
|
||||
Icon,
|
||||
ListItem,
|
||||
Screen,
|
||||
Text,
|
||||
|
||||
@@ -51,6 +51,7 @@ import numbro from 'numbro'
|
||||
import { TranItem } from './TranDetailScreen'
|
||||
import useIsInternetReachable from '../utils/useIsInternetReachable'
|
||||
import { translate } from '../i18n'
|
||||
import { MemoInputCard } from '../components/MemoInputCard'
|
||||
|
||||
|
||||
if (
|
||||
@@ -451,7 +452,7 @@ const onAmountEndEditing = async function () {
|
||||
return;
|
||||
}
|
||||
|
||||
if (lnurlPayParams.maxSendable && amount > lnurlPayParams.maxSendable / 1000 ) {
|
||||
if (lnurlPayParams.maxSendable && amount > lnurlPayParams.maxSendable / 1000) {
|
||||
infoMessage(translate("payCommon.maximumPay", {
|
||||
amount: roundDown(lnurlPayParams.maxSendable / 1000, 0),
|
||||
currency: CurrencyCode.SATS
|
||||
@@ -460,13 +461,13 @@ const onAmountEndEditing = async function () {
|
||||
}
|
||||
|
||||
if (lnurlPayParams.payerData) {
|
||||
infoMessage(translate("transferScreen.LUD18unsupported"))
|
||||
infoMessage(translate("transferScreen.LUD18unsupported"))
|
||||
}
|
||||
|
||||
setAmountToTransfer(`${numbro(amountToTransfer).format({thousandSeparated: true, mantissa: getCurrency(unit).mantissa})}`)
|
||||
|
||||
setIsLoading(true)
|
||||
const encoded = await LnurlClient.getInvoice(lnurlPayParams, amount * 1000)
|
||||
const encoded = await LnurlClient.getInvoice(lnurlPayParams, amount * 1000, lnurlPayCommentAllowed > 0 ? lnurlPaymentComment : void 0)
|
||||
setIsLoading(false)
|
||||
|
||||
if (encoded) return onEncodedInvoice(encoded);
|
||||
@@ -579,6 +580,17 @@ const iconColor = useThemeColor('textDim')
|
||||
const inputBg = useThemeColor('background')
|
||||
const satsColor = colors.palette.primary200
|
||||
|
||||
const memoInputRef = useRef<TextInput>(null)
|
||||
const onMemoDone = function () {
|
||||
console.log(lnurlPayParams)
|
||||
if (parseInt(amountToTransfer) > 0) {
|
||||
if (memoInputRef && memoInputRef.current) memoInputRef.current.blur();
|
||||
if (amountInputRef && amountInputRef.current) amountInputRef.current.blur();
|
||||
} else {
|
||||
if (amountInputRef && amountInputRef.current) amountInputRef.current.focus();
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Screen preset="fixed" contentContainerStyle={$screen}>
|
||||
<MintHeader
|
||||
@@ -645,25 +657,15 @@ const satsColor = colors.palette.primary200
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{transactionStatus !== TransactionStatus.COMPLETED && encodedInvoice &&
|
||||
lnurlPayCommentAllowed > 0 && (
|
||||
<Card
|
||||
style={{ marginBottom: spacing.small }}
|
||||
heading='LNURL Pay comment'
|
||||
ContentComponent={
|
||||
<TextInput
|
||||
// ref={lightningInputRef}
|
||||
onChangeText={data => setLnurlPaymentComment(data)}
|
||||
value={lnurlPaymentComment}
|
||||
autoCapitalize="none"
|
||||
keyboardType="default"
|
||||
maxLength={lnurlPayCommentAllowed}
|
||||
numberOfLines={3}
|
||||
multiline={true}
|
||||
selectTextOnFocus={true}
|
||||
style={[$commentInput, {backgroundColor: inputBg}]}
|
||||
/>
|
||||
}
|
||||
{lnurlPayCommentAllowed > 0 && (
|
||||
<MemoInputCard
|
||||
memo={lnurlPaymentComment}
|
||||
setMemo={setLnurlPaymentComment}
|
||||
ref={memoInputRef}
|
||||
onMemoDone={onMemoDone}
|
||||
onMemoEndEditing={onAmountEndEditing} // re-calculate encoded url
|
||||
disabled={encodedInvoice ? false : true}
|
||||
maxLength={lnurlPayCommentAllowed}
|
||||
/>
|
||||
)}
|
||||
{availableMintBalances.length > 0 &&
|
||||
|
||||
@@ -123,27 +123,27 @@ const getLnurlAddressParams = async (lnurlAddress: string) => {
|
||||
|
||||
|
||||
|
||||
const getInvoice = async(lnurlParams: LNURLPayParams, amountMsat?: number) => {
|
||||
const getInvoice = async (lnurlParams: LNURLPayParams, amountMsat?: number, comment?: string) => {
|
||||
if (!amountMsat || amountMsat === 0) { amountMsat = lnurlParams.minSendable }
|
||||
|
||||
if(!amountMsat || amountMsat === 0) {
|
||||
amountMsat = lnurlParams.minSendable
|
||||
}
|
||||
|
||||
const url = lnurlParams.callback.includes('?') ? `${lnurlParams.callback}&amount=${amountMsat}` : `${lnurlParams.callback}?amount=${amountMsat}`
|
||||
const url = new URL(lnurlParams.callback)
|
||||
url.searchParams.set('amount', amountMsat.toString())
|
||||
if (comment) url.searchParams.set('comment', comment)
|
||||
const strUrl = url.toString()
|
||||
const method = 'GET'
|
||||
const headers = MinibitsClient.getPublicHeaders()
|
||||
|
||||
const invoiceResult: any = await MinibitsClient.fetchApi(url, {
|
||||
method,
|
||||
headers,
|
||||
const invoiceResult: any = await MinibitsClient.fetchApi(strUrl, {
|
||||
method,
|
||||
headers,
|
||||
})
|
||||
|
||||
if(invoiceResult.status && invoiceResult.status === 'ERROR') {
|
||||
throw new AppError(Err.CONNECTION_ERROR, invoiceResult.reason, {domain: lnurlParams.domain, caller: 'getLnurlParams'})
|
||||
throw new AppError(Err.CONNECTION_ERROR, invoiceResult.reason, {domain: lnurlParams.domain, caller: 'getLnurlParams'})
|
||||
}
|
||||
|
||||
if(invoiceResult.pr) {
|
||||
return invoiceResult.pr as string
|
||||
return invoiceResult.pr as string
|
||||
}
|
||||
|
||||
throw new AppError(Err.CONNECTION_ERROR, 'Could not get lightning invoice from the LNURL provider', {domain: lnurlParams.domain, caller: 'getLnurlParams'})
|
||||
|
||||
Reference in New Issue
Block a user