deviant/scripts/chipnet-setup-c.mjs
walerikus 518a3ce174 chore: initial project baseline — full Deviant codebase under version control
Brings the whole project into git (previously only the on-ramp feature and
a few parallel files were tracked). Includes: wallet core (src/), CashScript
contracts/, the Capacitor shell (shells/), scripts/, tests, and the docs
corpus (wiki/, snapshots/, Parameters/, Archive/, KnowledgeBase text).

Excluded via .gitignore: node_modules/, dist/, .env (secrets), testnet WIF
key files (.chipnet-*.json, devWallets.ts), KnowledgeBase/RAW media (~9.6 GB),
transcripts/ (session logs), and machine-local config (.claude/*.local,
*.lock). Secret-scanned before commit — no credentials in the tree.

Note: src/swapMath.ts, src/swapBuilder.ts, contracts/OpenMintToken.cash are
legacy (OP_RETURN era) but still imported; committed as-is, flagged for a
separate removal once de-referenced.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-13 20:38:07 +02:00

81 lines
2.4 KiB
JavaScript

#!/usr/bin/env node
/**
* chipnet-setup-c.mjs — generate or load a THIRD chipnet wallet (Wallet C).
*
* Wallet C is an independent identity for the next round of tests. Unlike
* Wallet B (funded from Wallet A), Wallet C is funded directly from the
* chipnet faucet so its BCH has no provenance link to Wallet A. This
* exercises the case where a fully-independent third party participates
* in an open-mint Deviant token's economy.
*/
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { TestNetWallet } from 'mainnet-js';
const ROOT = join(import.meta.dirname, '..');
const KEYS_FILE = join(ROOT, '.chipnet-keys-c.json');
const FAUCETS = [
'https://tbch.googol.cash/',
'https://bitcoincash-faucet.com/',
];
function divider() {
console.log('='.repeat(72));
}
async function main() {
let wallet;
let fresh;
if (existsSync(KEYS_FILE)) {
const { wif } = JSON.parse(readFileSync(KEYS_FILE, 'utf8'));
wallet = await TestNetWallet.fromWIF(wif);
fresh = false;
} else {
wallet = await TestNetWallet.newRandom();
writeFileSync(
KEYS_FILE,
JSON.stringify(
{
wif: wallet.privateKeyWif,
cashaddr: wallet.cashaddr,
tokenaddr: wallet.tokenaddr,
generated: new Date().toISOString(),
network: 'chipnet',
role: 'wallet C (independent, faucet-funded)',
},
null,
2,
),
);
fresh = true;
}
const balance = await wallet.getBalance();
const sats = typeof balance === 'object' ? balance.sat : balance;
divider();
console.log(fresh ? 'Generated Wallet C (fresh).' : 'Loaded Wallet C.');
console.log(`Stored at: ${KEYS_FILE}`);
divider();
console.log(`Receive (BCH): ${wallet.cashaddr}`);
console.log(`Receive (token): ${wallet.tokenaddr}`);
console.log(`Balance: ${sats} sats`);
divider();
if (sats === 0 || sats === 0n) {
console.log('Wallet C is empty. Fund it from a chipnet faucet:');
for (const url of FAUCETS) console.log(` - ${url}`);
console.log('');
console.log('Paste this address into the faucet:');
console.log(` ${wallet.cashaddr}`);
console.log('Then re-run this script to confirm the balance.');
process.exitCode = 2;
} else {
console.log('Wallet C is funded. Ready for instructions.');
}
}
main().catch((err) => {
console.error('FAILED:', err?.message ?? err);
process.exit(1);
});