Skip to content

Commit 2c7fece

Browse files
committed
Simplify generator installation even more
Signed-off-by: fpv.dev <kich@octra.org>
1 parent 11de6a6 commit 2c7fece

File tree

13 files changed

+286
-266
lines changed

13 files changed

+286
-266
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
Remove-Item -Recurse -Force C:\temp-bun-cache-init
6161
6262
- name: Build executable
63-
run: bun build --compile --target=${{ matrix.bun-target }}-baseline --outfile=wallet-generator${{ matrix.executable-ext }} ./wallet_generator.ts
63+
run: bun build --compile --target=${{ matrix.bun-target }}-baseline --outfile=wallet-generator${{ matrix.executable-ext }} ./src/server.ts
6464

6565
- name: Test executable (Linux/macOS)
6666
if: runner.os != 'Windows'

README.md

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,20 @@
1-
# Octra Wallet Generator
2-
3-
A secure wallet generator for Octra blockchain.
1+
# octra wallet generator
42

53
## Quick Start
64

7-
1. **Clone the repository:**
8-
```bash
9-
git clone https://github.com/octra-labs/wallet-gen.git
10-
cd wallet-gen
11-
```
12-
13-
2. **Run the wallet generator webserver:**
14-
15-
**Linux/macOS:**
16-
```bash
17-
chmod +x ./start.sh
18-
./start.sh
19-
```
20-
21-
**Windows:**
22-
```bash
23-
start.bat
24-
```
25-
26-
3. **Open your browser:**
27-
Navigate to `http://localhost:8888`
5+
**Download and start wallet generator web UI with a single command:**
286

29-
### Generating Wallets
7+
**Linux/macOS:**
8+
```bash
9+
curl -fsSL https://octra.org/wallet-generator.sh | bash
10+
```
3011

31-
1. **Generate a wallet:**
32-
Click "GENERATE NEW WALLET" and watch the real-time progress
12+
**Windows:**
13+
```powershell
14+
powershell -c "irm octra.org/wallet-generator.ps1 | iex"
15+
```
3316

34-
2. **Wallet features:**
35-
- View mnemonic phrase, private/public keys, and address
36-
- Test signature functionality
37-
- Derive addresses for different network types
38-
- Auto-save wallet file to disk
17+
This command will:
18+
- Download the latest source code and build the wallet generator
19+
- Start the server and open the generator web UI page in your browser
20+
- Install to `~/.octra/wallet-generator` for future use

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"name": "octra-wallet-generator",
2+
"name": "@octra/wallet-gen",
33
"version": "1.0.0",
4-
"description": "Octra Wallet Generator in TypeScript",
5-
"main": "wallet_generator.ts",
4+
"description": "octra wallet generator",
5+
"main": "./src/server.ts",
66
"type": "module",
77
"scripts": {
8-
"start": "bun wallet_generator.ts",
9-
"dev": "bun --watch wallet_generator.ts",
10-
"build": "bun build --compile --outfile=wallet-generator ./wallet_generator.ts"
8+
"start": "bun src/server.ts",
9+
"dev": "bun --watch src/server.ts",
10+
"build": "bun build --compile --outfile=wallet-generator ./src/server.ts"
1111
},
1212
"dependencies": {
1313
"tweetnacl": "^1.0.3",
@@ -19,6 +19,6 @@
1919
"typescript": "^5.3.3"
2020
},
2121
"keywords": ["wallet", "crypto", "ed25519", "bip39", "typescript"],
22-
"author": "",
22+
"author": "octra labs",
2323
"license": "MIT"
2424
}
Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,25 @@ import { fileURLToPath } from "url";
55
import nacl from "tweetnacl";
66
import bip39 from "bip39";
77

8-
import indexHtml from "./index.html" with { type: "text" };
9-
import logoSvg from "./assets/logo.svg" with { type: "text" };
10-
import foundersGroteskFontPath from "./assets/founders-grotesk-bold.woff2" with { type: "file" };
11-
import nationalFontPath from "./assets/national-regular.woff2" with { type: "file" };
8+
import indexHtml from "./static/index.html" with { type: "text" };
9+
import logoSvg from "./static/logo.svg" with { type: "text" };
10+
import foundersGroteskFontPath from "./static/founders-grotesk-bold.woff2" with { type: "file" };
11+
import nationalFontPath from "./static/national-regular.woff2" with { type: "file" };
1212

13-
// ESM equivalent of __dirname
1413
const __filename: string = fileURLToPath(import.meta.url);
1514
const __dirname: string = path.dirname(__filename);
1615

17-
// Embed static assets for executable builds
1816
let foundersGroteskFont: ArrayBuffer;
1917
let nationalFont: ArrayBuffer;
2018

21-
// Load assets asynchronously
2219
async function loadAssets() {
2320
try {
2421
foundersGroteskFont = await Bun.file(foundersGroteskFontPath).arrayBuffer();
2522
nationalFont = await Bun.file(nationalFontPath).arrayBuffer();
2623
} catch (error) {
27-
console.warn("Could not load embedded assets:", error.message);
28-
// Assets will be served from filesystem instead
2924
}
3025
}
3126

32-
// Type definitions
3327
interface MasterKey {
3428
masterPrivateKey: Buffer;
3529
masterChainCode: Buffer;
@@ -99,7 +93,7 @@ function base64Encode(buffer: Buffer | Uint8Array): string {
9993
return Buffer.from(buffer).toString("base64");
10094
}
10195

102-
// Base58 encoding for Octra addresses
96+
// Base58 encoding for octra addresses
10397
function base58Encode(buffer: Buffer): string {
10498
if (buffer.length === 0) return "";
10599

@@ -272,7 +266,7 @@ function deriveForNetwork(
272266
};
273267
}
274268

275-
// Create Octra address
269+
// Create octra address
276270
function createOctraAddress(publicKey: Buffer): string {
277271
const hash: Buffer = crypto.createHash("sha256").update(publicKey).digest();
278272
const base58Hash: string = base58Encode(hash);
@@ -392,7 +386,7 @@ async function handleGenerateWallet(): Promise<Response> {
392386
controller.enqueue(
393387
encoder.encode(
394388
`data: ${JSON.stringify({
395-
status: "Generating Octra address...",
389+
status: "Generating octra address...",
396390
})}\n\n`
397391
)
398392
);
@@ -513,7 +507,7 @@ async function handleSaveWallet(request: Request): Promise<Response> {
513507
-8
514508
)}_${timestamp}.txt`;
515509

516-
const content: string = `OCTRA WALLET
510+
const content: string = `octra wallet
517511
${"=".repeat(50)}
518512
519513
SECURITY WARNING: KEEP THIS FILE SECURE AND NEVER SHARE YOUR PRIVATE KEY
@@ -611,15 +605,15 @@ function serveEmbeddedAsset(pathname: string): Response | null {
611605
}
612606
break;
613607

614-
case '/assets/logo.svg':
608+
case '/static/logo.svg':
615609
if (logoSvg) {
616610
return new Response(logoSvg, {
617611
headers: { 'Content-Type': 'image/svg+xml' }
618612
});
619613
}
620614
break;
621615

622-
case '/assets/founders-grotesk-bold.woff2':
616+
case '/static/founders-grotesk-bold.woff2':
623617
if (foundersGroteskFont) {
624618
return new Response(foundersGroteskFont, {
625619
headers: {
@@ -630,7 +624,7 @@ function serveEmbeddedAsset(pathname: string): Response | null {
630624
}
631625
break;
632626

633-
case '/assets/national-regular.woff2':
627+
case '/static/national-regular.woff2':
634628
if (nationalFont) {
635629
return new Response(nationalFont, {
636630
headers: {
@@ -660,10 +654,8 @@ async function serveStaticFile(filePath: string): Promise<Response> {
660654
}
661655
}
662656

663-
// Load embedded assets
664657
await loadAssets();
665658

666-
// Start server
667659
const PORT: number = 8888;
668660

669661
const server = Bun.serve({
@@ -676,7 +668,6 @@ const server = Bun.serve({
676668
method: request.method,
677669
};
678670

679-
// Handle GET requests for static assets (embedded or file system)
680671
if (method === "GET") {
681672
// Try to serve embedded asset first
682673
const embeddedAsset = serveEmbeddedAsset(pathname);
@@ -686,16 +677,15 @@ const server = Bun.serve({
686677

687678
// Fallback to file system for development mode
688679
if (pathname === "/" || pathname === "/index.html") {
689-
return serveStaticFile(path.join(__dirname, "index.html"));
680+
return serveStaticFile(path.join(__dirname, "static/index.html"));
690681
}
691682

692-
if (pathname.startsWith("/assets/")) {
683+
if (pathname.startsWith("/static/")) {
693684
const assetPath = path.join(__dirname, pathname);
694685
return serveStaticFile(assetPath);
695686
}
696687
}
697688

698-
// Handle API routes
699689
if (method === "POST" && pathname === "/generate") {
700690
return handleGenerateWallet();
701691
}
@@ -708,9 +698,9 @@ const server = Bun.serve({
708698
return handleDeriveWallet(request);
709699
}
710700

711-
// 404 for all other routes
712701
return new Response("Not Found", { status: 404 });
713702
},
714703
});
715704

716-
console.log("OCTRA Wallet Generator Web Server");
705+
console.log("octra wallet generator server");
706+
console.log(`The server is running at: http://localhost:${PORT}`);

index.html renamed to src/static/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<link rel="icon" type="image/svg+xml" href="/assets/logo.svg" />
6+
<link rel="icon" type="image/svg+xml" href="/static/logo.svg" />
77
<title>Octra Wallet Generator</title>
88
<style>
99
@font-face {
1010
font-family: 'National';
11-
src: url('/assets/national-regular.woff2') format('woff2');
11+
src: url('/static/national-regular.woff2') format('woff2');
1212
font-weight: 400;
1313
font-style: normal;
1414
font-display: swap;
1515
}
1616

1717
@font-face {
1818
font-family: 'FoundersGrotesk';
19-
src: url('/assets/founders-grotesk-bold.woff2') format('woff2');
19+
src: url('/static/founders-grotesk-bold.woff2') format('woff2');
2020
font-weight: 700;
2121
font-style: normal;
2222
font-display: swap;
@@ -272,7 +272,7 @@
272272
.warning::before {
273273
content: '';
274274
position: absolute;
275-
background: url('assets/icon-warning.svg') 0 0 no-repeat;
275+
background: url('/static/icon-warning.svg') 0 0 no-repeat;
276276
width: 16px;
277277
height: 16px;
278278
left: 12px;
File renamed without changes.

start.bat

Lines changed: 0 additions & 106 deletions
This file was deleted.

0 commit comments

Comments
 (0)