diff --git a/scripts/make_video.mjs b/scripts/make_video.mjs deleted file mode 100644 index c815c70..0000000 --- a/scripts/make_video.mjs +++ /dev/null @@ -1,357 +0,0 @@ -#!/usr/bin/env node -/* Clawback Cinema-Grade 1080p @ 30fps Narrated Walkthrough Video & Thumbnail Producer - * - Natural British female neural voice (en-GB-SoniaNeural, broadcast leveled -16 LUFS) - * - 7 chapters covering the July 2026 Coldcard incident, Live Simulator, - * Tiered Multi-Slot Vault Builder, Animated BBQr, 24/7 Watchtower, Offline Auditor & Support - * - Flagship discreet dark-slate (#11151c) & crimson red-crab (#cf4a4a) styling — zero orange - * - Outputs: docs/clawback-tour.mp4, docs/youtube-thumbnail.png, and $COPY_MP4_TO if set - * - Prerequisites (not installed by this repo): node, ffmpeg + ffprobe, google-chrome at /usr/bin/google-chrome, - * msedge-tts (MSEDGE_TTS_PATH), playwright-core (PLAYWRIGHT_PATH), DejaVu fonts, and the app served at - * CLAWBACK_URL (default http://127.0.0.1:8091). - */ -import fs from "node:fs"; -import path from "node:path"; -import { execFileSync } from "node:child_process"; -import { createRequire } from "node:module"; - -const require = createRequire(import.meta.url); -const { MsEdgeTTS, OUTPUT_FORMAT } = require(process.env.MSEDGE_TTS_PATH || "msedge-tts"); -const { chromium } = require(process.env.PLAYWRIGHT_PATH || "playwright-core"); - -const ROOT = path.resolve(import.meta.dirname, ".."); -const DOCS = path.join(ROOT, "docs"); -const TMP = path.join(DOCS, "video-tmp"); -const OUT_MP4 = path.join(DOCS, "clawback-tour.mp4"); -const PC_MP4 = process.env.COPY_MP4_TO || ""; -const THUMB_PNG = path.join(DOCS, "youtube-thumbnail.png"); -const APP_URL = process.env.CLAWBACK_URL || "http://127.0.0.1:8091/"; - -fs.mkdirSync(TMP, { recursive: true }); -if (PC_MP4) fs.mkdirSync(path.dirname(PC_MP4), { recursive: true }); - -const FONT_BOLD = fs.existsSync("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf") - ? "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf" - : "/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf"; - -const FONT_MONO = fs.existsSync("/usr/share/fonts/truetype/jetbrains-mono/JetBrainsMono-Bold.ttf") - ? "/usr/share/fonts/truetype/jetbrains-mono/JetBrainsMono-Bold.ttf" - : "/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf"; - -const VOICE = "en-GB-SoniaNeural"; - -const CHAPTERS = [ - { - id: "00-intro", - shot: "intro-bg.png", - titleCard: { - headline: "CLAWBACK", - sub1: "TIME-DELAYED BITCOIN VAULTS · PRE-SIGNED EMERGENCY CLAWBACK", - sub2: "2-OF-2 P2WSH | BIP-68 CSV (1H–180D) | 4-TIER RBF (UP TO 500 SAT/VB) | BBQR", - sub3: "ZERO SOFT FORKS · ZERO CUSTODIANS · ZERO STORED PRIVATE KEYS", - url: "github.com/Random21m/clawback", - }, - padTail: 0.7, - narration: - "In July twenty twenty-six, a silent Coldcard firmware entropy bug let attackers drain over one thousand eight hundred Bitcoin across five thousand addresses without ever touching a single physical device. Traditional self-custody gave victims zero reaction time. Welcome to Clawback... an open-source, offline-first armor layer that gives your existing hardware wallet a trustless time-delayed undo button on Bitcoin today.", - }, - { - id: "01-simulator-attack", - shot: "sim-attack.png", - badge: "CHAPTER 01 // LIVE ATTACK & CLAWBACK SANDBOX", - title: "2-of-2 P2WSH Vault + Mandatory Consensus Quarantine (1 Hour to 180 Days)", - padTail: 0.5, - narration: - "When you open Clawback, you can test the real secp256k1 vault engine immediately in the Live Simulator. Your coins lock inside a two-of-two P2WSH vault combining your primary Coldcard key with an ephemeral key that is permanently wiped from memory before funding. Even if an attacker steals your Coldcard, your PIN, and your vault file, Bitcoin consensus freezes the coins inside your chosen quarantine window... from one hour up to one hundred eighty days.", - }, - { - id: "02-clawback-sweep", - shot: "sim-clawed.png", - badge: "CHAPTER 02 // ONE-TAP EMERGENCY CLAWBACK", - title: "4-Tier Pre-Signed RBF Clawback (15 / 50 / 200 / 500 sat/vB) to Your Bunker", - padTail: 0.5, - narration: - "The moment an unauthorized unvault hits the mempool, your Watchtower alerts you. With one tap... and without needing any hardware wallet in the crisis... you choose fifteen, fifty, two hundred, or extreme five hundred satoshis per virtual byte to crush fee spikes and sweep one hundred percent of your Bitcoin straight into your independent offsite SeedSigner bunker. Every transaction uses canonical Miniscript and verifies right down to the raw hex.", - }, - { - id: "03-create-vault", - shot: "create-setup.png", - badge: "CHAPTER 03 // WHOLE-WALLET & TIERED MULTI-SLOT VAULTS", - title: "Native SegWit Guard · Tiered Per-Slot Armor (3d · 14d · 90d) · PSBT / xpub", - padTail: 0.5, - narration: - "In Create Vault, you never enter a seed phrase. Load a single UTXO or sweep your whole wallet by importing a Sparrow or Coldcard PSBT, scanning a watch-only zpub, or using your camera. Clawback hard-blocks legacy one and three addresses so your funding transaction ID can never mutate, preserves full BIP-32 hardware derivation paths, and lets you split your stack into independent tiered slots... like three days for spending, fourteen days for medium savings, and ninety days for deep cold storage.", - }, - { - id: "04-sealed-bbqr", - shot: "bbqr-modal.png", - badge: "CHAPTER 04 // EPHEMERAL KEY WIPE & ANIMATED BBQR", - title: "RAM Destruction Receipt · Mandatory Backup Gate · BIP-380 Descriptors", - padTail: 0.5, - narration: - "Once built, Clawback zeroes every ephemeral private key in memory, passes a full cryptographic self-audit, and locks the funding PSBT behind a mandatory backup confirmation so you always save your Vault Package first. Export checksummed BIP-380 Miniscript descriptors for Sparrow and Bitcoin Core, download the PSBT to microSD, or scan the spec-compliant animated BBQr code directly on Coldcard Q or SeedSigner.", - }, - { - id: "05-watchtower", - shot: "watchtower.png", - badge: "CHAPTER 05 // ZERO-KEY WATCHTOWER & 24/7 PUSH ALERTS", - title: "Dust-Immune Monitor · Own Umbrel / Start9 Node · One-Tap Panic Controls", - padTail: 0.5, - narration: - "Install Clawback as a discreet dark-slate PWA on your phone and load your watch-only Panic Package. Because it stores zero private keys and every pre-signed clawback pays exclusively to your own bunker, even losing your phone puts zero sats at risk. Point Watchtower at mempool dot space or your own Umbrel or Start9 node, set up twenty-four seven push alerts or a self-hosted cron watcher, and keep instant one-tap clawback controls in your pocket.", - }, - { - id: "06-auditor-support", - shot: "auditor.png", - badge: "CHAPTER 06 // OFFLINE AUDITOR, ZERO LOCK-IN & SUPPORT", - title: "Independent Script & Signature Verification · Single-File clawback.html", - padTail: 0.7, - narration: - "Finally, Verify and Spend audits any vault or panic package completely offline... checking every BIP-66 Low-S signature, locktime, and 2-of-2 script byte for byte... and builds post-quarantine CSV spend PSBTs once your delay completes. Because everything uses standard Bitcoin scripts and raw hex, you have zero software lock-in even decades from now. Download the single self-contained clawback dot html file, verify its SHA-256 checksum, rehearse on Signet first, and if Clawback helps protect your stack, scan the Lightning QR to support open-source Bitcoin security.", - }, -]; - -function escText(s) { - return s.replace(/\\/g, "\\\\").replace(/:/g, "\\:").replace(/'/g, "\\'"); -} - -async function synthesizeVoice(text, outMp3) { - const tts = new MsEdgeTTS(); - await tts.setMetadata(VOICE, OUTPUT_FORMAT.AUDIO_24KHZ_96KBITRATE_MONO_MP3); - const { audioStream } = tts.toStream(text); - const chunks = []; - await new Promise((resolve, reject) => { - audioStream.on("data", (d) => chunks.push(d)); - audioStream.on("end", resolve); - audioStream.on("error", reject); - }); - fs.writeFileSync(outMp3, Buffer.concat(chunks)); -} - -function getDuration(mediaPath) { - const out = execFileSync("ffprobe", [ - "-v", "error", "-show_entries", "format=duration", "-of", "default=noprint_wrappers=1:nokey=1", mediaPath, - ], { encoding: "utf8" }); - return parseFloat(out.trim()); -} - -async function capture1080pFrames() { - console.log(" Capturing native 1920x1080 frames from flagship Clawback UI..."); - const browser = await chromium.launch({ - executablePath: "/usr/bin/google-chrome", - headless: true, - args: ["--no-sandbox", "--disable-gpu"], - }); - const ctx = await browser.newContext({ viewport: { width: 1920, height: 1080 }, deviceScaleFactor: 1 }); - const page = await ctx.newPage(); - const clearToast = () => page.evaluate(() => document.getElementById("toast")?.classList.remove("show")); - - await page.goto(APP_URL, { waitUntil: "networkidle" }); - await page.addStyleTag({ content: "html { zoom: 1.18; } body { padding-bottom: 130px; }" }); - - // 1. Simulator Attack (also used dimmed under intro title card & YouTube thumbnail) - await page.click("#sim-btn-seal"); - await page.click("#sim-btn-unvault-hack"); - await page.click("#sim-btn-mine-100"); - await page.click("#sim-btn-mine-100"); - await clearToast(); - await page.waitForTimeout(150); - await page.screenshot({ path: path.join(TMP, "intro-bg.png") }); - await page.screenshot({ path: path.join(TMP, "sim-attack.png") }); - - // 2. Clawback Sweep + Miniscript ASM - await page.click("#sim-tier-chips .chip[data-tier=\"fast\"]"); - await page.click("#sim-btn-clawback"); - await page.click("#sim-toggle-raw"); - await clearToast(); - await page.waitForTimeout(150); - await page.screenshot({ path: path.join(TMP, "sim-clawed.png") }); - - // 3. Create Vault Multi-Slot Tiered Setup - await page.click(".nav-tab[data-tab=\"create\"]"); - await page.click("#btn-fill-demo-utxo"); - await page.fill("#cfg-label", "Reserve-Coldcard-01"); - await page.click("#slot-mode-chips .chip[data-mode=\"split3\"]"); - await page.click("#tiered-delay-chips .chip[data-tier-mode=\"preset\"]"); - await page.evaluate(() => window.scrollTo(0, 310)); - await clearToast(); - await page.waitForTimeout(150); - await page.screenshot({ path: path.join(TMP, "create-setup.png") }); - - // 4. Build Vault + Confirm Gate + Animated BBQr Modal - await page.click("#btn-build-vault"); - await page.waitForSelector("#out-backup-confirm", { state: "visible" }); - await page.check("#out-backup-confirm"); - await page.locator("#vault-output-area").scrollIntoViewIfNeeded(); - await page.click("#out-qr-funding-psbt"); - await page.waitForSelector("#qr-modal.open"); - await clearToast(); - await page.waitForTimeout(200); - await page.screenshot({ path: path.join(TMP, "bbqr-modal.png") }); - await page.keyboard.press("Escape"); - - // 5. Watchtower & Panic Dashboard - await page.click("#out-add-watchtower"); - await page.evaluate(() => window.scrollTo(0, 0)); - await clearToast(); - await page.waitForTimeout(150); - await page.screenshot({ path: path.join(TMP, "watchtower.png") }); - - // 6. Offline Auditor + Post-Quarantine Spend - await page.click(".nav-tab[data-tab=\"verify\"]"); - await page.evaluate(() => { - const C = window.ClawCrypto; - const V = window.ClawVault; - const p1 = C.generatePrivateKey(); - const pub1 = C.privToPub(p1); - const addr1 = C.p2wpkhAddressFromPubKey(pub1, "signet"); - C.wipeBytes(p1); - const p2 = C.generatePrivateKey(); - const bunker = C.p2wpkhAddressFromPubKey(C.privToPub(p2), "signet"); - C.wipeBytes(p2); - const pkg = V.createVaultPackage({ - network: "signet", - label: "Reserve-Coldcard-01", - utxos: [{ txid: "aa".repeat(32), vout: 0, amount: 4000000, address: addr1 }], - userSpendPubHex: C.bytesToHex(pub1), - userSpendOrigin: { masterFingerprint: "a1b2c3d4", path: C.parseDerivationPath("m/84h/1h/0h/0/0") }, - clawbackAddress: bunker, - csvBlocks: 1008, - slotAmounts: [600000, 1400000, 1990000], - slotDelays: [432, 2016, 12960], - changeAddress: addr1, - }); - document.getElementById("verify-json-input").value = JSON.stringify(pkg); - document.getElementById("spend-dest-addr").value = addr1; - }); - await page.click("#verify-btn-run"); - await page.click("#spend-btn-build"); - await page.evaluate(() => window.scrollTo(0, 110)); - await clearToast(); - await page.waitForTimeout(150); - await page.screenshot({ path: path.join(TMP, "auditor.png") }); - - await browser.close(); -} - -function buildThumbnail() { - console.log(" Generating flagship 1280x720 YouTube / README video thumbnail..."); - const vf = [ - "scale=1280:720", - "drawbox=x=0:y=0:w=1280:h=720:color=0x11151c@0.68:t=fill", - "drawbox=x=70:y=96:w=1140:h=528:color=0x181e28@0.92:t=fill", - "drawbox=x=70:y=96:w=1140:h=528:color=0xcf4a4a@0.75:t=2", - "drawbox=x=70:y=96:w=1140:h=5:color=0xcf4a4a@0.95:t=fill", - `drawtext=fontfile=${FONT_MONO}:text='WATCH WALKTHROUGH · 1080P NARRATED DEMO':fontcolor=0xcf4a4a:fontsize=20:x=(w-text_w)/2:y=158`, - `drawtext=fontfile=${FONT_BOLD}:text='CLAWBACK':fontcolor=0xe7edf6:fontsize=88:x=(w-text_w)/2:y=215`, - `drawtext=fontfile=${FONT_BOLD}:text='Time-Delayed Bitcoin Vaults + Emergency Clawback':fontcolor=0xbcc7d9:fontsize=29:x=(w-text_w)/2:y=342`, - `drawtext=fontfile=${FONT_MONO}:text='1H–180D CSV QUARANTINE · 4-TIER RBF (500 SAT/VB) · ZERO CUSTODY':fontcolor=0x4d9e82:fontsize=19:x=(w-text_w)/2:y=424`, - "drawbox=x=548:y=486:w=184:h=68:color=0xcf4a4a@0.95:t=fill", - `drawtext=fontfile=${FONT_BOLD}:text='PLAY DEMO':fontcolor=0xfdfeff:fontsize=24:x=(w-text_w)/2:y=509`, - ].join(","); - - execFileSync("ffmpeg", [ - "-hide_banner", "-loglevel", "error", - "-i", path.join(TMP, "sim-attack.png"), - "-vf", vf, - "-frames:v", "1", "-y", THUMB_PNG, - ]); -} - -async function main() { - console.log(`=== Clawback Flagship 1080p Cinema Tutorial Producer (${VOICE}) ===`); - await capture1080pFrames(); - buildThumbnail(); - - const segFiles = []; - for (const ch of CHAPTERS) { - console.log(` Synthesizing voice [${ch.id}]...`); - const mp3 = path.join(TMP, `${ch.id}.mp3`); - await synthesizeVoice(ch.narration, mp3); - const vDur = getDuration(mp3); - const lead = ch.titleCard ? 0.6 : 0.4; - const totalDur = vDur + lead + (ch.padTail || 0.5); - - const wav = path.join(TMP, `${ch.id}-audio.wav`); - execFileSync("ffmpeg", [ - "-hide_banner", "-loglevel", "error", - "-i", mp3, - "-af", `adelay=${Math.round(lead * 1000)}|${Math.round(lead * 1000)},apad=whole_dur=${totalDur.toFixed(2)}`, - "-ar", "48000", "-ac", "2", "-y", wav, - ]); - - let vf = ""; - if (ch.titleCard) { - const tc = ch.titleCard; - vf = [ - "drawbox=x=0:y=0:w=1920:h=1080:color=0x11151c@0.88:t=fill", - "drawbox=x=140:y=164:w=1640:h=752:color=0x181e28@0.96:t=fill", - "drawbox=x=140:y=164:w=1640:h=752:color=0x94a8c6@0.25:t=2", - "drawbox=x=140:y=164:w=1640:h=6:color=0xcf4a4a@0.95:t=fill", - `drawtext=fontfile=${FONT_BOLD}:text='${escText(tc.headline)}':fontcolor=0xe7edf6:fontsize=118:x=(w-text_w)/2:y=264`, - `drawtext=fontfile=${FONT_BOLD}:text='${escText(tc.sub1)}':fontcolor=0xcf4a4a:fontsize=28:x=(w-text_w)/2:y=432`, - `drawtext=fontfile=${FONT_MONO}:text='${escText(tc.sub2)}':fontcolor=0x8a97ae:fontsize=21:x=(w-text_w)/2:y=528`, - `drawtext=fontfile=${FONT_MONO}:text='${escText(tc.sub3)}':fontcolor=0x4d9e82:fontsize=23:x=(w-text_w)/2:y=624`, - `drawtext=fontfile=${FONT_MONO}:text='${escText(tc.url)}':fontcolor=0x82a4d6:fontsize=26:x=(w-text_w)/2:y=760`, - `fade=t=in:st=0:d=0.45,fade=t=out:st=${(totalDur - 0.45).toFixed(2)}:d=0.45,format=yuv420p`, - ].join(","); - } else { - vf = [ - "drawbox=x=0:y=952:w=1920:h=128:color=0x11151c@0.95:t=fill", - "drawbox=x=0:y=952:w=1920:h=2:color=0x94a8c6@0.22:t=fill", - "drawbox=x=48:y=952:w=160:h=3:color=0xcf4a4a@0.98:t=fill", - `drawtext=fontfile=${FONT_MONO}:text='${escText(ch.badge)}':fontcolor=0xcf4a4a:fontsize=20:x=48:y=972`, - `drawtext=fontfile=${FONT_BOLD}:text='${escText(ch.title)}':fontcolor=0xe7edf6:fontsize=30:x=48:y=1010`, - `fade=t=in:st=0:d=0.35,fade=t=out:st=${(totalDur - 0.35).toFixed(2)}:d=0.35,format=yuv420p`, - ].join(","); - } - - const segMp4 = path.join(TMP, `${ch.id}.mp4`); - execFileSync("ffmpeg", [ - "-hide_banner", "-loglevel", "error", - "-loop", "1", "-framerate", "30", "-i", path.join(TMP, ch.shot), - "-i", wav, - "-t", totalDur.toFixed(2), - "-vf", vf, - "-c:v", "libx264", "-preset", "medium", "-crf", "20", "-r", "30", "-pix_fmt", "yuv420p", - "-c:a", "aac", "-b:a", "192k", "-ar", "48000", "-ac", "2", - "-shortest", "-y", segMp4, - ]); - segFiles.push(segMp4); - } - - // Concat + whisper-soft ambient bed + broadcast loudness (-16 LUFS) - const listTxt = path.join(TMP, "concat.txt"); - fs.writeFileSync(listTxt, segFiles.map((f) => `file '${f}'`).join("\n") + "\n"); - const rawJoin = path.join(TMP, "joined.mp4"); - execFileSync("ffmpeg", [ - "-hide_banner", "-loglevel", "error", - "-f", "concat", "-safe", "0", "-i", listTxt, - "-c", "copy", "-y", rawJoin, - ]); - - const finalDur = getDuration(rawJoin); - execFileSync("ffmpeg", [ - "-hide_banner", "-loglevel", "error", - "-i", rawJoin, - "-f", "lavfi", "-t", finalDur.toFixed(2), - "-i", "aevalsrc=0.03*sin(2*PI*55.0*t)+0.02*sin(2*PI*82.41*t)+0.012*sin(2*PI*110.0*t)*(0.6+0.4*sin(2*PI*0.09*t)):s=48000:c=stereo", - "-filter_complex", - `[1:a]lowpass=f=220,volume=0.22,afade=t=in:st=0:d=2.0,afade=t=out:st=${Math.max(0, finalDur - 2.5).toFixed(2)}:d=2.5[bed];` + - `[0:a][bed]amix=inputs=2:duration=first:normalize=0,loudnorm=I=-16:TP=-1.5:LRA=11[aout]`, - "-map", "0:v", "-map", "[aout]", - "-c:v", "copy", "-c:a", "aac", "-b:a", "192k", "-movflags", "+faststart", - "-y", OUT_MP4, - ]); - - if (PC_MP4) fs.copyFileSync(OUT_MP4, PC_MP4); - fs.rmSync(TMP, { recursive: true, force: true }); - const sizeMB = (fs.statSync(OUT_MP4).size / (1024 * 1024)).toFixed(2); - console.log(`\n✓ Built Flagship Clawback 1080p Walkthrough Video: ${OUT_MP4} (${finalDur.toFixed(1)}s, ${sizeMB} MB)`); - if (PC_MP4) console.log(`✓ Copied video to: ${PC_MP4}`); - console.log(`✓ Generated Flagship Thumbnail: ${THUMB_PNG}`); -} - -main().catch((err) => { - console.error(err); - process.exit(1); -});