upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/btfrv.h
diff options
context:
space:
mode:
authorBitflash-sh <btf01@proton.me>2026-07-24 11:18:11 -0300
committerBitflash-sh <btf01@proton.me>2026-07-24 11:18:11 -0300
commit51d617e70f90a972185917ea0096c1ecef2bfa8b (patch)
tree9fbbcd867de9de9d0776afdd02f594ba312c46eb /src/btfrv.h
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.
Diffstat (limited to 'src/btfrv.h')
-rw-r--r--src/btfrv.h59
1 files changed, 59 insertions, 0 deletions
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 @@
1// Copyright (c) 2026 Bitflash developers
2// Distributed under the MIT/X11 software license.
3//
4// Bitflash rendezvous transport -- the "meeting node" that lets two nodes behind
5// CGNAT connect without a public IP or port forwarding. Both sides connect OUT
6// to the relay (which HAS a public IP, e.g. the VPS); the relay pairs them by
7// `.btf` pubkey and forwards raw bytes between them. The endpoints then run the
8// echan end-to-end channel on top, so the relay sees only ciphertext and cannot
9// MITM (the client boxes to the service's STATIC key from its self-certified
10// descriptor -- a substituting relay just breaks the channel, never reads it).
11//
12// This is the server that runs on the VPS (headless, Layer 6 ports it to Linux)
13// plus the client/service helpers the desktop node uses.
14
15#ifndef BITFLASH_BTFRV_H
16#define BITFLASH_BTFRV_H
17
18#include <stdint.h>
19
20namespace btf
21{
22
23// A connected, paired rendezvous socket (opaque). Read/write raw bytes; the
24// caller layers echan on top. Close with RvClose.
25typedef intptr_t RvSocket;
26static const RvSocket RV_INVALID = (RvSocket)-1;
27
28// Initialize sockets (Winsock on Windows). Idempotent.
29bool RvInit();
30
31// ---- relay side (runs on the VPS) ----
32// Run the rendezvous relay forever on `port`, forwarding between paired peers.
33// Blocks; run it in a thread. Returns false if it can't bind/listen.
34bool RvRelayRun(unsigned short port);
35
36// Stop a running relay (signals RvRelayRun to return).
37void RvRelayStop();
38
39// ---- service side (the node being reached by its .btf address) ----
40// Register at the relay under `my_pubkey` (32 bytes) and block until a client is
41// paired to us. Returns the paired socket, or RV_INVALID on error.
42RvSocket RvServiceRegister(const char* relay_host, unsigned short port,
43 const unsigned char my_pubkey[32]);
44
45// ---- client side (the node dialing a .btf address) ----
46// Connect through the relay to the service registered under `target_pubkey`.
47// Returns the paired socket, or RV_INVALID on error.
48RvSocket RvClientConnect(const char* relay_host, unsigned short port,
49 const unsigned char target_pubkey[32]);
50
51// Blocking read/write of exactly n bytes over a rendezvous socket. Return false
52// on error/EOF.
53bool RvReadN(RvSocket s, void* buf, int n);
54bool RvWriteN(RvSocket s, const void* buf, int n);
55void RvClose(RvSocket s);
56
57} // namespace btf
58
59#endif