upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/btftunnel.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/btftunnel.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/btftunnel.h')
-rw-r--r--src/btftunnel.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/btftunnel.h b/src/btftunnel.h
new file mode 100644
index 0000000..1fa4f01
--- /dev/null
+++ b/src/btftunnel.h
@@ -0,0 +1,49 @@
1// Copyright (c) 2026 Bitflash developers
2// Distributed under the MIT/X11 software license.
3//
4// Transparent anonymous tunnel. Gives the existing CNode a plain local socket
5// while, behind it, a pair of pump threads bridge plaintext <-> echan <->
6// rendezvous. CNode reads/writes normally and never knows its bytes travel
7// end-to-end encrypted through a meeting node (the Itzal `wrap()` pattern).
8//
9// Client side: resolve a `.btf` -> meeting node + service enc key (done by the
10// caller), then BtfClientTunnel connects through the relay, runs the echan
11// handshake, and returns a local SOCKET to hand a new outbound CNode.
12//
13// Service side: after RvServiceRegister pairs us with a client, BtfServiceWrap
14// completes the echan handshake and returns a local SOCKET for an inbound CNode.
15
16#ifndef BITFLASH_BTFTUNNEL_H
17#define BITFLASH_BTFTUNNEL_H
18
19#include "btfrv.h"
20
21#ifdef _WIN32
22#include <winsock2.h>
23typedef SOCKET btf_socket_t;
24#else
25typedef int btf_socket_t;
26#define INVALID_SOCKET (-1)
27#endif
28
29namespace btf
30{
31
32// Initialize (sockets + libsodium). Idempotent.
33bool TunnelInit();
34
35// Client: dial the service registered under `target_pubkey` at the meeting node
36// (host:port), box to its static x25519 `service_enc_pub`, and return a local
37// plaintext SOCKET tunneled end-to-end to the service. INVALID_SOCKET on error.
38btf_socket_t BtfClientTunnel(const char* meeting_host, unsigned short port,
39 const unsigned char target_pubkey[32],
40 const unsigned char service_enc_pub[32]);
41
42// Service: wrap an already-paired rendezvous socket (from RvServiceRegister)
43// with echan using my static x25519 secret, returning a local plaintext SOCKET
44// for an inbound CNode. Consumes `rv` (closed when the tunnel tears down).
45btf_socket_t BtfServiceWrap(RvSocket rv, const unsigned char my_enc_sk[32]);
46
47} // namespace btf
48
49#endif