From 51d617e70f90a972185917ea0096c1ecef2bfa8b Mon Sep 17 00:00:00 2001 From: Bitflash-sh Date: Fri, 24 Jul 2026 11:18:11 -0300 Subject: Bitflash: fair-launch release Satoshi's bitcoin-0.1.0 reborn with RandomX CPU proof of work, anonymous .btf addressing over Nostr with CGNAT rendezvous, automatic peer discovery, a headless Linux node, and Windows GUI wallet. Fair launch, no premine, 21M cap. --- src/btfrv.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/btfrv.h (limited to 'src/btfrv.h') diff --git a/src/btfrv.h b/src/btfrv.h new file mode 100644 index 0000000..c776201 --- /dev/null +++ b/src/btfrv.h @@ -0,0 +1,59 @@ +// Copyright (c) 2026 Bitflash developers +// Distributed under the MIT/X11 software license. +// +// Bitflash rendezvous transport -- the "meeting node" that lets two nodes behind +// CGNAT connect without a public IP or port forwarding. Both sides connect OUT +// to the relay (which HAS a public IP, e.g. the VPS); the relay pairs them by +// `.btf` pubkey and forwards raw bytes between them. The endpoints then run the +// echan end-to-end channel on top, so the relay sees only ciphertext and cannot +// MITM (the client boxes to the service's STATIC key from its self-certified +// descriptor -- a substituting relay just breaks the channel, never reads it). +// +// This is the server that runs on the VPS (headless, Layer 6 ports it to Linux) +// plus the client/service helpers the desktop node uses. + +#ifndef BITFLASH_BTFRV_H +#define BITFLASH_BTFRV_H + +#include + +namespace btf +{ + +// A connected, paired rendezvous socket (opaque). Read/write raw bytes; the +// caller layers echan on top. Close with RvClose. +typedef intptr_t RvSocket; +static const RvSocket RV_INVALID = (RvSocket)-1; + +// Initialize sockets (Winsock on Windows). Idempotent. +bool RvInit(); + +// ---- relay side (runs on the VPS) ---- +// Run the rendezvous relay forever on `port`, forwarding between paired peers. +// Blocks; run it in a thread. Returns false if it can't bind/listen. +bool RvRelayRun(unsigned short port); + +// Stop a running relay (signals RvRelayRun to return). +void RvRelayStop(); + +// ---- service side (the node being reached by its .btf address) ---- +// Register at the relay under `my_pubkey` (32 bytes) and block until a client is +// paired to us. Returns the paired socket, or RV_INVALID on error. +RvSocket RvServiceRegister(const char* relay_host, unsigned short port, + const unsigned char my_pubkey[32]); + +// ---- client side (the node dialing a .btf address) ---- +// Connect through the relay to the service registered under `target_pubkey`. +// Returns the paired socket, or RV_INVALID on error. +RvSocket RvClientConnect(const char* relay_host, unsigned short port, + const unsigned char target_pubkey[32]); + +// Blocking read/write of exactly n bytes over a rendezvous socket. Return false +// on error/EOF. +bool RvReadN(RvSocket s, void* buf, int n); +bool RvWriteN(RvSocket s, const void* buf, int n); +void RvClose(RvSocket s); + +} // namespace btf + +#endif -- cgit v1.2.3