forked from octra-labs/wallet-gen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwallet-generator.ps1
More file actions
132 lines (100 loc) · 3.6 KB
/
Copy pathwallet-generator.ps1
File metadata and controls
132 lines (100 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env pwsh
param()
$ErrorActionPreference = "Stop"
$RepoOwner = "octra-labs"
$RepoName = "wallet-gen"
$InstallDir = "${Home}\.octra"
$TempDir = "${env:TEMP}\octra-wallet-gen-install"
Write-Host "=== ⚠️ SECURITY WARNING ⚠️ ==="
Write-Host ""
Write-Host "this tool generates real cryptographic keys. always:"
Write-Host " - keep your private keys secure"
Write-Host " - never share your mnemonic phrase"
Write-Host " - don't store wallet files on cloud services"
Write-Host " - use on a secure, offline computer for production wallets"
Write-Host ""
Read-Host "press enter to continue..." < /dev/tty
Write-Host ""
Write-Host "=== octra wallet generator installer ==="
Write-Host ""
function Install-Bun {
if (-not (Get-Command bun -ErrorAction SilentlyContinue)) {
$installScript = Invoke-RestMethod -Uri 'https://bun.sh/install.ps1'
Invoke-Expression $installScript
# Add bun to PATH for the current session
$env:PATH = "${Home}\.bun\bin;$($env:PATH)"
}
}
function Get-LatestReleaseTag {
Write-Host "fetching latest release information..."
try {
$apiUrl = "https://api.github.com/repos/$RepoOwner/$RepoName/tags"
$tags = Invoke-RestMethod -Uri $apiUrl
return $tags[0].name
} catch {
Write-Host "❌ error: could not fetch release information from GitHub."
Write-Host $_.Exception.Message
exit 1
}
}
function Download-And-Extract {
param(
[string]$Tag
)
Write-Host "downloading octra wallet generator..."
if (Test-Path $TempDir) {
Remove-Item -Recurse -Force -Path $TempDir
}
New-Item -ItemType Directory -Path $TempDir | Out-Null
$zipballUrl = "https://api.github.com/repos/$RepoOwner/$RepoName/zipball/refs/tags/$Tag"
$outputFile = Join-Path $TempDir "release.zip"
Invoke-WebRequest -Uri $zipballUrl -OutFile $outputFile
Set-Location $TempDir
Expand-Archive -Path $outputFile -DestinationPath . -Force
$extractedDir = Get-ChildItem -Directory | Select-Object -First 1
if ($extractedDir) {
Get-ChildItem -Path $extractedDir.FullName -Force | Move-Item -Destination . -Force
Remove-Item -Recurse -Force -Path $extractedDir.FullName
}
}
$latestTag = Get-LatestReleaseTag
Download-And-Extract -Tag $latestTag
Set-Location $TempDir
Install-Bun
bun install
Write-Host ""
Write-Host "building standalone executable..."
bun run build
$executableName = "wallet-generator"
$executablePath = Join-Path $TempDir $executableName
if (-not (Test-Path -Path $executablePath)) {
Write-Host "❌ error: wallet-generator executable not found after build!"
Write-Host "build may have failed. please check the build output above."
exit 1
}
Write-Host "installing to $InstallDir..."
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
Copy-Item -Path $executablePath -Destination $InstallDir -Force
$installedExecutablePath = Join-Path $InstallDir $executableName
Write-Host ""
Write-Host "starting wallet generator server..."
Set-Location $InstallDir
if (Test-Path $TempDir) {
Remove-Item -Recurse -Force -Path $TempDir
}
$process = Start-Process -FilePath $installedExecutablePath -PassThru
Start-Sleep -Seconds 2
try {
Start-Process "http://localhost:8888"
} catch {
}
Write-Host ""
Write-Host "=== installation complete! ==="
Write-Host "wallet generator is running at http://localhost:8888"
Write-Host "to run again later, use: $installedExecutablePath"
Write-Host "to stop the wallet generator, press Ctrl+C in this window or close it."
Write-Host ""
try {
Wait-Process -Id $process.Id
} catch {
}