Skip to content

Commit 8dc4096

Browse files
committed
Initial subs implementation
1 parent fe2971b commit 8dc4096

File tree

28 files changed

+3238
-475
lines changed

28 files changed

+3238
-475
lines changed

Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[workspace]
22

33
resolver = "2"
4-
members = [ "client", "protocol", "veritas", "testutil", "wallet"]
4+
members = [ "client", "protocol", "veritas", "testutil", "wallet", "ptr"]

SUBSPACES.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Guide to Subspaces
2+
3+
## Operating a Space
4+
5+
### 1. Initialize the Space
6+
7+
Initialize your space for operation:
8+
9+
```bash
10+
$ space-cli operate @bitcoin
11+
```
12+
13+
### 2. Issue Subspaces
14+
15+
Use [subs](https://github.com/spacesprotocol/subs) to issue subspaces off-chain and create commitments.
16+
17+
### 3. Submit Commitments
18+
19+
Submit a commitment for your space with a Merkle root. Each commitment is cryptographically bound to all previous commitments.
20+
21+
**Example:** To submit a commitment for `@bitcoin` with root hash `85d3a410db41b317b7c0310df64cefb6504482c0b5c7e8a36c992ed0dfdb38af`:
22+
23+
```bash
24+
$ space-cli commit @bitcoin 85d3a410db41b317b7c0310df64cefb6504482c0b5c7e8a36c992ed0dfdb38af
25+
```
26+
27+
**Retrieve commitments** for a space:
28+
29+
```bash
30+
$ space-cli getcommitment @bitcoin
31+
```
32+
33+
### Delegating Operational Control
34+
35+
You can authorize another party to make commitments on your behalf:
36+
37+
```bash
38+
$ space-cli delegate @bitcoin --to <operator-address>
39+
```
40+
41+
## Binding Handles On-Chain
42+
43+
Handles like `alice@bitcoin` are bound to unique script pubkeys off-chain and are designed to remain off-chain by default. However, when on-chain interactivity is required, handles can be bound to UTXOs with minimal on-chain footprint.
44+
45+
### Creating a Space Pointer
46+
47+
Given a handle with its associated script pubkey:
48+
49+
```json
50+
{
51+
"handle": "alice@bitcoin",
52+
"script_pubkey": "5120d3c3196cb3ed7fa79c882ed62f8e5942e546130d5ae5983da67dbb6c9bdd2e79"
53+
}
54+
```
55+
56+
You can create an on-chain identifier that only the controller of the script pubkey can use, without requiring additional metadata on-chain:
57+
58+
```bash
59+
$ space-cli createptr 5120d3c3196cb3ed7fa79c882ed62f8e5942e546130d5ae5983da67dbb6c9bdd2e79
60+
```
61+
62+
This command creates a UTXO with the same script pubkey and "mints" a space pointer (sptr) derived from it:
63+
64+
```
65+
sptr13thcluavwywaktvv466wr6hykf7x5avg49hgdh7w8hh8chsqvwcskmtxpd
66+
```
67+
68+
The space pointer serves as a permanent, transferable on-chain reference for the handle that can be sold and transferred like any other space UTXO.

client/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ path = "src/lib.rs"
1818
[dependencies]
1919
spaces_wallet = { path = "../wallet" }
2020
spaces_protocol = { path = "../protocol", version = "*", features = ["std"]}
21+
spaces_ptr = { path = "../ptr" , features = ["std"]}
2122
spacedb = { git = "https://github.com/spacesprotocol/spacedb", version = "0.0.7" }
2223

2324
tokio = { version = "1.37.0", features = ["signal"] }

client/src/app.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::config::Args;
77
use crate::rpc::{AsyncChainState, RpcServerImpl, WalletLoadRequest, WalletManager};
88
use crate::source::{BitcoinBlockSource, BitcoinRpc};
99
use crate::spaces::Spaced;
10-
use crate::store::LiveSnapshot;
10+
use crate::store::chain::{Chain};
1111
use crate::wallets::RpcWallet;
1212

1313
pub struct App {
@@ -27,7 +27,7 @@ impl App {
2727
let wallet_service = RpcWallet::service(
2828
spaced.network,
2929
spaced.rpc.clone(),
30-
spaced.chain.state.clone(),
30+
spaced.chain.clone(),
3131
rx,
3232
self.shutdown.clone(),
3333
spaced.num_workers,
@@ -52,11 +52,11 @@ impl App {
5252
wallets: Arc::new(Default::default()),
5353
};
5454

55+
let chain_state = spaced.chain.clone();
5556
let (async_chain_state, async_chain_state_handle) = create_async_store(
5657
spaced.rpc.clone(),
5758
spaced.anchors_path.clone(),
58-
spaced.chain.state.clone(),
59-
spaced.block_index.as_ref().map(|index| index.state.clone()),
59+
chain_state,
6060
self.shutdown.subscribe(),
6161
)
6262
.await;
@@ -116,8 +116,7 @@ impl App {
116116
async fn create_async_store(
117117
rpc: BitcoinRpc,
118118
anchors: Option<PathBuf>,
119-
chain_state: LiveSnapshot,
120-
block_index: Option<LiveSnapshot>,
119+
state: Chain,
121120
shutdown: broadcast::Receiver<()>,
122121
) -> (AsyncChainState, JoinHandle<()>) {
123122
let (tx, rx) = mpsc::channel(32);
@@ -128,8 +127,7 @@ async fn create_async_store(
128127
&client,
129128
rpc,
130129
anchors,
131-
chain_state,
132-
block_index,
130+
state,
133131
rx,
134132
shutdown,
135133
)

0 commit comments

Comments
 (0)