mirror of
https://github.com/minibits-cash/minibits_wallet.git
synced 2026-10-06 19:53:09 +00:00
Save relays from nip05 server when adding own name
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "minibits_wallet",
|
||||
"version": "0.1.3-beta.11",
|
||||
"version": "0.1.3-beta.12",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"android:clean": "cd android && ./gradlew clean",
|
||||
|
||||
@@ -49,10 +49,8 @@ export const InvoicesStoreModel = types
|
||||
}
|
||||
|
||||
if (invoiceInstance) {
|
||||
log.info('Invoice to be removed from InvoicesStore', invoiceToRemove)
|
||||
log.trace('Invoice to be removed from InvoicesStore', invoiceToRemove)
|
||||
destroy(invoiceInstance)
|
||||
log.info('Invoice removed')
|
||||
|
||||
}
|
||||
},
|
||||
}))
|
||||
|
||||
@@ -44,7 +44,7 @@ export const MintsStoreModel = types
|
||||
|
||||
self.mints.push(mintInstance)
|
||||
|
||||
log.info('New mint added to the MintsStore')
|
||||
log.info('New mint added to the MintsStore', newMint.mintUrl)
|
||||
},
|
||||
removeMint(mintToBeRemoved: Mint) {
|
||||
if (self.blockedMintUrls.some(m => m === mintToBeRemoved.mintUrl)) {
|
||||
@@ -62,16 +62,16 @@ export const MintsStoreModel = types
|
||||
|
||||
if (mintInstance) {
|
||||
destroy(mintInstance)
|
||||
log.info('Mint removed from MintsStore')
|
||||
log.trace('Mint removed from MintsStore')
|
||||
}
|
||||
},
|
||||
blockMint(mintToBeBlocked: Mint) {
|
||||
self.blockedMintUrls.push(mintToBeBlocked.mintUrl)
|
||||
log.info('Mint blocked in MintsStore')
|
||||
log.trace('Mint blocked in MintsStore')
|
||||
},
|
||||
unblockMint(blockedMint: Mint) {
|
||||
self.blockedMintUrls.remove(blockedMint.mintUrl)
|
||||
log.info('Mint unblocked in MintsStore')
|
||||
log.trace('Mint unblocked in MintsStore')
|
||||
},
|
||||
}))
|
||||
.views(self => ({
|
||||
|
||||
@@ -24,7 +24,7 @@ interface OwnKeysScreenProps extends ContactsStackScreenProps<'OwnKeys'> {}
|
||||
|
||||
export const OwnKeysScreen: FC<OwnKeysScreenProps> = observer(function OwnKeysScreen({navigation}) {
|
||||
|
||||
const {walletProfileStore, contactsStore} = useStores()
|
||||
const {walletProfileStore, contactsStore, relaysStore} = useStores()
|
||||
|
||||
useHeader({
|
||||
leftIcon: 'faArrowLeft',
|
||||
@@ -77,7 +77,7 @@ export const OwnKeysScreen: FC<OwnKeysScreenProps> = observer(function OwnKeysSc
|
||||
setInfo(`Invalid NOSTR address, please check that it follows name@domain.com format`)
|
||||
}
|
||||
|
||||
if(nip05Domain && MINIBITS_NIP05_DOMAIN.includes(nip05Domain)) {
|
||||
if(MINIBITS_NIP05_DOMAIN.includes(nip05Domain as string)) {
|
||||
setInfo(`${MINIBITS_NIP05_DOMAIN} names and keys can't be used with multiple wallets.`)
|
||||
return
|
||||
}
|
||||
@@ -86,7 +86,17 @@ export const OwnKeysScreen: FC<OwnKeysScreenProps> = observer(function OwnKeysSc
|
||||
// get nip05 record from the .well-known server
|
||||
const {nip05Pubkey, nip05Relays} = await NostrClient.getNip05PubkeyAndRelays(ownNip05)
|
||||
|
||||
const relaysToConnect = nip05Relays.length > 0 ? nip05Relays : NostrClient.getDefaultRelays()
|
||||
if(nip05Relays.length > 0) {
|
||||
for (const relay of nip05Relays) {
|
||||
relaysStore.addOrUpdateRelay({
|
||||
url: relay,
|
||||
status: WebSocket.CLOSED
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const relaysToConnect = relaysStore.allPublicUrls
|
||||
setOwnProfileRelays(relaysToConnect)
|
||||
|
||||
const profile: NostrProfile = await NostrClient.getProfileFromRelays(nip05Pubkey, relaysToConnect)
|
||||
|
||||
@@ -111,11 +121,6 @@ export const OwnKeysScreen: FC<OwnKeysScreenProps> = observer(function OwnKeysSc
|
||||
|
||||
log.trace('Got valid profile', profile)
|
||||
setOwnProfile(profile)
|
||||
|
||||
if(relaysToConnect.length > 0) {
|
||||
setOwnProfileRelays(relaysToConnect)
|
||||
contactsStore.setPublicRelay(relaysToConnect[0]) // TODO extend model to n relays
|
||||
}
|
||||
|
||||
setIsLoading(false)
|
||||
} catch(e: any) {
|
||||
@@ -212,7 +217,7 @@ export const OwnKeysScreen: FC<OwnKeysScreenProps> = observer(function OwnKeysSc
|
||||
<ListItem
|
||||
LeftComponent={<View style={[$numIcon, {backgroundColor: iconNip05}]}><Text text='1'/></View>}
|
||||
text='Enter your NOSTR address'
|
||||
subText={'Minibits uses NOSTR adress (nip05) as a sharable contact to send and receive ecash.'}
|
||||
subText={'Minibits uses NOSTR address (nip05) as a sharable contact to send and receive ecash.'}
|
||||
bottomSeparator={true}
|
||||
style={{}}
|
||||
/>
|
||||
|
||||
@@ -370,7 +370,7 @@ const transfer = async function () {
|
||||
encodedInvoice,
|
||||
)
|
||||
|
||||
log.info('Transfer result', {transaction, message, error, finalFee}, 'transfer')
|
||||
log.trace('Transfer result', {transaction, message, error, finalFee}, 'transfer')
|
||||
|
||||
const {status} = transaction as Transaction
|
||||
setTransactionStatus(status)
|
||||
|
||||
@@ -72,11 +72,11 @@ export const UpdateScreen: FC<SettingsStackScreenProps<'Update'>> = observer(fun
|
||||
(status) => {
|
||||
switch (status) {
|
||||
case codePush.SyncStatus.DOWNLOADING_PACKAGE:
|
||||
log.info('Downloading update...')
|
||||
log.trace('Downloading update...')
|
||||
setInfo('Downloading update...')
|
||||
break
|
||||
case codePush.SyncStatus.INSTALLING_UPDATE:
|
||||
log.info('Installing update...')
|
||||
log.trace('Installing update...')
|
||||
setInfo('Installing update...')
|
||||
break
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ const payLightningInvoice = async function (
|
||||
)
|
||||
|
||||
// if (newKeys) { _setKeys(mintUrl, newKeys) }
|
||||
log.info('payLnInvoice result', {
|
||||
log.trace('payLnInvoice result', {
|
||||
isPaid,
|
||||
change,
|
||||
preimage,
|
||||
@@ -290,7 +290,10 @@ const requestProofs = async function (
|
||||
newKeys
|
||||
}
|
||||
} catch (e: any) {
|
||||
log.info(`[MINT_ERROR] ${e.message}`,[],'cashuMintClient.requestProofs')
|
||||
if(e.message.includes('Invoice not paid') === false) {
|
||||
log.info(`[MINT_ERROR] ${e.message}`,[],'cashuMintClient.requestProofs')
|
||||
}
|
||||
|
||||
return {proofs: []}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ const getInstance = function () {
|
||||
encryptionKey: _encryptionKey,
|
||||
})
|
||||
|
||||
log.info('MMKV encrypted storage initialized')
|
||||
log.trace('MMKV encrypted storage initialized')
|
||||
} else {
|
||||
_storage = new MMKV({
|
||||
id: 'storage-v1',
|
||||
|
||||
@@ -81,7 +81,7 @@ const getOrCreateKeyPair = async function (): Promise<KeyPair> {
|
||||
keyPair = KeyChain.generateNostrKeyPair() as KeyPair
|
||||
await KeyChain.saveNostrKeyPair(keyPair)
|
||||
|
||||
log.info('Created and saved new NOSTR keypair','','getOrCreateKeyPair',)
|
||||
log.trace('Created and saved new NOSTR keypair','','getOrCreateKeyPair',)
|
||||
}
|
||||
|
||||
return keyPair
|
||||
@@ -304,7 +304,7 @@ const getNip05PubkeyAndRelays = async function (nip05: string) {
|
||||
} else {
|
||||
throw new AppError(
|
||||
Err.VALIDATION_ERROR,
|
||||
`Could not get public key from NOSTR address verification server`, {nip05Record})
|
||||
`Could not get public key from NOSTR address verification server`, {nip05, nip05Record})
|
||||
}
|
||||
|
||||
// retrieve recommended relays
|
||||
|
||||
@@ -336,7 +336,7 @@ const updateUserSettings = function (settings: UserSettings): UserSettings {
|
||||
const db = getInstance()
|
||||
db.execute(query, params)
|
||||
|
||||
log.info('User settings created or updated in the database', params)
|
||||
log.trace('User settings created or updated in the database', params)
|
||||
|
||||
const updated = getUserSettings()
|
||||
return updated
|
||||
@@ -799,7 +799,7 @@ const addOrUpdateProofs = function (
|
||||
|
||||
const totalAmount = CashuUtils.getProofsAmount(proofs)
|
||||
// DO NOT log proof secrets to Sentry
|
||||
log.info(
|
||||
log.trace(
|
||||
`${rowsAffected}${isPending ? ' pending' : ''
|
||||
} proofs were added or updated in the database backup`,
|
||||
{isPending, isSpent}
|
||||
|
||||
@@ -1257,9 +1257,9 @@ const transfer = async function (
|
||||
) {
|
||||
const mintUrl = mintBalanceToTransferFrom.mint
|
||||
|
||||
log.info('mintBalanceToTransferFrom', mintBalanceToTransferFrom, 'transfer')
|
||||
log.info('amountToTransfer', amountToTransfer, 'transfer')
|
||||
log.info('estimatedFee', estimatedFee, 'transfer')
|
||||
log.trace('mintBalanceToTransferFrom', mintBalanceToTransferFrom, 'transfer')
|
||||
log.trace('amountToTransfer', amountToTransfer, 'transfer')
|
||||
log.trace('estimatedFee', estimatedFee, 'transfer')
|
||||
|
||||
if (amountToTransfer + estimatedFee > mintBalanceToTransferFrom.balance) {
|
||||
throw new AppError(Err.VALIDATION_ERROR, 'Mint balance is insufficient to cover the amount to transfer with expected Lightning fees.')
|
||||
@@ -1446,7 +1446,7 @@ const _addCashuProofs = function (
|
||||
proofsStore.addProofs(proofsToAdd as Proof[])
|
||||
const amount = CashuUtils.getProofsAmount(proofsToAdd as Proof[])
|
||||
|
||||
log.info('Added proofs with amount', { amount, isRecoveredFromPending })
|
||||
log.trace('Added proofs with amount', { amount, isRecoveredFromPending })
|
||||
|
||||
if(isRecoveredFromPending) {
|
||||
// Remove them from pending if they are returned to the wallet due to failed lightning payment
|
||||
@@ -1592,7 +1592,7 @@ const checkPendingTopups = async function () {
|
||||
// remove already expired invoices only after check that they have not been paid
|
||||
// Fixes #3
|
||||
if (isBefore(invoice.expiresAt as Date, new Date())) {
|
||||
log.info('Invoice expired, removing', invoice.paymentHash, 'checkPendingTopups')
|
||||
log.trace('Invoice expired, removing', invoice.paymentHash, 'checkPendingTopups')
|
||||
|
||||
const transactionId = invoice.transactionId
|
||||
invoicesStore.removeInvoice(invoice)
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import * as Sentry from '@sentry/react-native'
|
||||
import {Err} from './AppError'
|
||||
import {APP_ENV, LOG_LEVEL, SENTRY_ACTIVE} from '@env'
|
||||
|
||||
// refresh // refresh
|
||||
// refresh // refresh // refresh
|
||||
|
||||
export enum LogLevel {
|
||||
TRACE = 'TRACE',
|
||||
|
||||
Reference in New Issue
Block a user