Compare commits
5 Commits
c0ee0a5df1
...
66c93dcc00
| Author | SHA1 | Date | |
|---|---|---|---|
| 66c93dcc00 | |||
| 7f050a9a09 | |||
| d3c20789e9 | |||
| 035e4cd1b4 | |||
| 6998ea5982 |
@ -78,7 +78,7 @@ ipcMain.handle('wallet:checkKeystore', async () => {
|
|||||||
fs.statSync(path.join(walletDir, a)).mtime.getTime()
|
fs.statSync(path.join(walletDir, a)).mtime.getTime()
|
||||||
)[0]
|
)[0]
|
||||||
|
|
||||||
if (!newestFile) return { exists: false, filePath: null }
|
if (!newestFile?.length) return { exists: false, filePath: null }
|
||||||
|
|
||||||
const resolvedPath = path.join(walletDir, newestFile)
|
const resolvedPath = path.join(walletDir, newestFile)
|
||||||
let minBlockHeight: number | null = null
|
let minBlockHeight: number | null = null
|
||||||
@ -88,11 +88,10 @@ ipcMain.handle('wallet:checkKeystore', async () => {
|
|||||||
const data = JSON.parse(json)
|
const data = JSON.parse(json)
|
||||||
const height = data?.minBlockHeight
|
const height = data?.minBlockHeight
|
||||||
|
|
||||||
if (typeof height === 'number' && Number.isFinite(height)) {
|
if (Number.isFinite(height)) minBlockHeight = height
|
||||||
minBlockHeight = height
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('Unable to read minBlockHeight from keystore:', error)
|
console.warn('Unable to read minBlockHeight from keystore:', error)
|
||||||
|
return { exists: true, filePath: resolvedPath }
|
||||||
}
|
}
|
||||||
|
|
||||||
return { exists: true, filePath: resolvedPath, minBlockHeight }
|
return { exists: true, filePath: resolvedPath, minBlockHeight }
|
||||||
@ -137,37 +136,34 @@ ipcMain.handle(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
ipcMain.handle(
|
ipcMain.handle('wallet:getMinBlockHeight', async (_event, filePath: string | null) => {
|
||||||
'wallet:getMinBlockHeight',
|
if (!filePath) {
|
||||||
async (_event, filePath: string | null) => {
|
return { success: false, error: 'No keystore file path provided.', minBlockHeight: null }
|
||||||
if (!filePath) {
|
|
||||||
return { success: false, error: 'No keystore file path provided.', minBlockHeight: null }
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const normalizedPath = path.isAbsolute(filePath)
|
|
||||||
? filePath
|
|
||||||
: path.join(process.cwd(), filePath)
|
|
||||||
|
|
||||||
if (!fs.existsSync(normalizedPath)) {
|
|
||||||
return { success: false, error: 'Keystore file not found.', minBlockHeight: null }
|
|
||||||
}
|
|
||||||
|
|
||||||
const fileContents = fs.readFileSync(normalizedPath, 'utf-8')
|
|
||||||
const walletJson = JSON.parse(fileContents)
|
|
||||||
const height = walletJson?.minBlockHeight
|
|
||||||
|
|
||||||
if (typeof height === 'number' && Number.isFinite(height)) {
|
|
||||||
return { success: true, minBlockHeight: height }
|
|
||||||
}
|
|
||||||
|
|
||||||
return { success: true, minBlockHeight: null }
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error reading min block height:', error)
|
|
||||||
return { success: false, error: String(error), minBlockHeight: null }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
try {
|
||||||
|
const normalizedPath = path.isAbsolute(filePath)
|
||||||
|
? filePath
|
||||||
|
: path.join(process.cwd(), filePath)
|
||||||
|
|
||||||
|
if (!fs.existsSync(normalizedPath)) {
|
||||||
|
return { success: false, error: 'Keystore file not found.', minBlockHeight: null }
|
||||||
|
}
|
||||||
|
|
||||||
|
const fileContents = fs.readFileSync(normalizedPath, 'utf-8')
|
||||||
|
const walletJson = JSON.parse(fileContents)
|
||||||
|
const height = walletJson?.minBlockHeight
|
||||||
|
|
||||||
|
if (Number.isFinite(height)) {
|
||||||
|
return { success: true, minBlockHeight: height }
|
||||||
|
}
|
||||||
|
|
||||||
|
return { success: true, minBlockHeight: null }
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error reading min block height:', error)
|
||||||
|
return { success: false, error: String(error), minBlockHeight: null }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
ipcMain.handle('wallet:generateKeysFromSeed', async (_event, seedPhrase: string[]) => {
|
ipcMain.handle('wallet:generateKeysFromSeed', async (_event, seedPhrase: string[]) => {
|
||||||
try {
|
try {
|
||||||
@ -188,7 +184,6 @@ ipcMain.handle('wallet:buildTransaction', async (_event, args) => {
|
|||||||
import.meta.env.VITE_APP_API,
|
import.meta.env.VITE_APP_API,
|
||||||
spendingKeyHex,
|
spendingKeyHex,
|
||||||
inputAdditionRecords,
|
inputAdditionRecords,
|
||||||
// pass minBlockHeight from args if provided, default 0
|
|
||||||
typeof args?.minBlockHeight === 'number' && Number.isFinite(args.minBlockHeight)
|
typeof args?.minBlockHeight === 'number' && Number.isFinite(args.minBlockHeight)
|
||||||
? args.minBlockHeight
|
? args.minBlockHeight
|
||||||
: 0,
|
: 0,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user