mirror of
https://github.com/minibits-cash/minibits_wallet.git
synced 2026-10-06 19:53:09 +00:00
Fix regression bug in reconnection to Nostr relays
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "minibits_wallet",
|
||||
"version": "0.1.6-beta.47",
|
||||
"version": "0.1.6-beta.48",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"android:clean": "cd android && ./gradlew clean",
|
||||
|
||||
@@ -22,7 +22,7 @@ import {log} from './logService'
|
||||
import AppError, { Err } from '../utils/AppError'
|
||||
import { MinibitsClient } from './minibitsService'
|
||||
import { rootStoreInstance } from '../models'
|
||||
import { Wallet } from './walletService'
|
||||
import { WalletTask } from './walletService'
|
||||
|
||||
export {
|
||||
NostrEvent,
|
||||
@@ -80,7 +80,7 @@ const reconnectToRelays = async function () {
|
||||
|
||||
// recreate subscriptions if all relays down
|
||||
if(relaysStore.connectedCount === 0) {
|
||||
Wallet.checkPendingReceived().catch(e => false)
|
||||
WalletTask.handleSpentFromPending().catch(e => false)
|
||||
}
|
||||
|
||||
const pool = getRelayPool()
|
||||
@@ -202,37 +202,37 @@ const decryptNip04 = async function(
|
||||
const publish = async function (
|
||||
event: NostrUnsignedEvent,
|
||||
relays: string[],
|
||||
): Promise<Event | undefined> {
|
||||
): Promise<NostrEvent | undefined> {
|
||||
|
||||
const keys: KeyPair = await getOrCreateKeyPair()
|
||||
|
||||
event.created_at = Math.floor(Date.now() / 1000)
|
||||
event.id = getEventHash(event)
|
||||
event.sig = getSignature(event, keys.privateKey)
|
||||
const signed = {...event} as NostrEvent
|
||||
|
||||
signed.created_at = Math.floor(Date.now() / 1000)
|
||||
signed.id = getEventHash(event)
|
||||
signed.sig = getSignature(event, keys.privateKey)
|
||||
|
||||
if(!validateEvent(event)) {
|
||||
throw new AppError(Err.VALIDATION_ERROR, 'Event is invalid and could not be published', event)
|
||||
}
|
||||
|
||||
log.trace('Event to be published', event, 'publish')
|
||||
log.trace('Event to be published', signed, 'publish')
|
||||
|
||||
const pool = getRelayPool()
|
||||
let pubs = pool.publish(relays, event)
|
||||
let pubs = pool.publish(relays, signed)
|
||||
await delay(1000)
|
||||
// await Promise.all(pubs)
|
||||
|
||||
const published: NostrEvent = await pool.get(relays, {
|
||||
ids: [event.id]
|
||||
ids: [signed.id]
|
||||
})
|
||||
|
||||
|
||||
if(published) {
|
||||
log.trace('Event successfully published', published, 'NostrClient.publish')
|
||||
// pool.close(relays)
|
||||
log.trace('Event successfully published', published, 'NostrClient.publish')
|
||||
return published
|
||||
}
|
||||
|
||||
// pool.close(relays)
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
@@ -258,10 +258,10 @@ const getEvent = async function (
|
||||
const getEvents = async function (
|
||||
relays: string[],
|
||||
filters: NostrFilter[]
|
||||
): Promise<Event[]> {
|
||||
): Promise<NostrEvent[]> {
|
||||
|
||||
const pool = getRelayPool()
|
||||
const events: Event[] = await pool.list(relays, filters)
|
||||
const events: NostrEvent[] = await pool.list(relays, filters)
|
||||
|
||||
if(events && events.length > 0) {
|
||||
return events
|
||||
@@ -357,7 +357,7 @@ const getProfileFromRelays = async function (pubkey: string, relays: string[]):
|
||||
kinds: [0],
|
||||
}]
|
||||
|
||||
const events: NostrEvent[] = await NostrClient.getEvents(relays, filters)
|
||||
const events = await NostrClient.getEvents(relays, filters)
|
||||
|
||||
|
||||
if(!events || events.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user