bstore

module
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: Apache-2.0

README

bstore

CI Release Go Reference Go version License

[!WARNING] Experimental software. bstore is part of bstack, the applications and patterns built on BSV Layered Multicast. It is published to be built on and improved. Interfaces, formats and behavior may change rapidly between releases; pin an exact version.

Object storage as a market on Bitcoin. A writer publishes an object once; storage providers compete to hold it for a bounty; a reader proves every byte it gets. Readers and writers may speak S3.

How it works

  • Publish once, many providers. An object is a CHIRP (BRC-167) closure sent to every provider of its bucket, with a signed entry on the bucket's records topic. Providers advertise what they hold with ordinary UHRP (BRC-26) advertisements.
  • A bounty races the write. A writer may commit a hold bounty that its own client pays, by rank, to the first providers to advertise and pass a challenge, with BRC-178's square-root split.
  • Anyone can buy time or proof. A renewal extends a provider's holding; a challenge samples 4 KiB segments and proves each into the object's proof root.
  • The bucket proves its own listing. The owner's chain of mined tokens commits to the whole key map, so a reader proves what a key names, that a key is absent and that a listing page is complete.
  • Incumbent UHRP hosts join unchanged through a bridge (bstore-bridge) that speaks their HTTP routes.
  • Honest about limits. Availability is a market outcome, keys are not copies, and enforcement is reputation in this version.

docs/architecture.md shows the pieces and how they fit.

Install

$ go install github.com/lightwebinc/bstore/cmd/bstore@latest            # the command line and the S3 gateway
$ go install github.com/lightwebinc/bstore/cmd/bstore-provider@latest   # a storage provider

Release tarballs for Linux and macOS (amd64, arm64), each with its SHA256SUMS entry, are on the releases page. The container images are built from the Dockerfile (ghcr.io/lightwebinc/bstore, bstore-provider, bstore-devchain); see docs/configuration.md.

On mainnet

No node is needed. By default the chain is read from WhatsOnChain (every header held to its proof of work, every proof to those headers) and transactions are broadcast through GorillaPool's public arcade; your own node (-chain asset:URL) is the better chain view, and every backend is a setting (docs/configuration.md). You need only the overlay hosts that carry your bucket.

$ bstore init -network main \
    -hosts https://overlay-a.example.com,https://overlay-b.example.com
identity 02...
$ bstore fund
identity     02...
fund address 1...
pool         0 output(s), 0 satoshis

Send a small amount from your own wallet to the fund address (100,000 satoshis, 0.001 BSV, is ample to try every role but a bounty) and import the payment: as the BEEF your wallet hands over (no lookup, and it need not have mined), or by its txid once it has a block:

$ bstore fund -beef payment.beef
$ bstore fund -txid <txid of your payment>
<txid> mined at height <h>: 1 output(s) to the fund address, 1 imported (100000 satoshis), 0 already held, 0 spent
pool 1 output(s), 100000 satoshis
$ bstore bucket new photos          # prints the "served" line your hosts add
$ bstore put photos/cat.jpg ./cat.jpg

Reading needs no coin: name the bucket (its identifier, owner key and id, from its owner) and read, every byte proven:

$ bstore bucket add photos_hmqzvtkwrx -owner 02... -id 5f...
$ bstore -bucket photos_hmqzvtkwrx get photos/cat.jpg ./cat.jpg -proof-root

Testnet is the same with -network test. docs/examples.md walks each role on a real network, with what each step costs.

Documentation

If you want to Read
Do a task on mainnet or testnet: fund, make a bucket, put, read, challenge, renew docs/examples.md
Learn the ideas and the day-to-day use, by role docs/user-guide.md
See the components, the data flow and the code layout docs/architecture.md
Look up a flag, an environment variable, a config key or an image docs/configuration.md
Look up a command and what it does, step by step docs/usage.md
Know the bounds, what each operation costs, and the known limits docs/limits.md
Run a storage provider docs/provider.md
Run the S3 gateway, and what S3 clients can do through it docs/s3.md
Run an overlay host that carries buckets docs/host.md
Try everything on one machine: a local development sandbox (no coin needed, a private regtest chain) QUICKSTART.md
Implement a compatible writer, provider, host or reader docs/spec.md (the specification)
Know what cannot change once published docs/frozen.md
Use or check the codec and its golden vectors docs/codec.md

Building

$ cd host && npm ci && cd ..
$ make verify NODE=/path/to/node24
$ make bstore bstore-provider       # bin/: the command line (and bstore s3d), the provider
$ make module NODE=/path/to/node24  # host/bundle/bstore-module.js
$ make docker-build                 # the images

Go 1.27.1 and Node 24. bstore pins go-sdk v1.7.1 and bcommon v0.15.0.

License

Apache License 2.0. See LICENSE, and NOTICE for the third-party software and standards.

Directories

Path Synopsis
Package auth104 is the server side of BRC-103 mutual authentication over HTTP (BRC-104), as a provider's routes need it: the handshake at /.well-known/auth, and each authenticated request checked and its answer signed, the way the SDK's clients (authhttp in Go, AuthFetch in TypeScript) send and check them.
Package auth104 is the server side of BRC-103 mutual authentication over HTTP (BRC-104), as a provider's routes need it: the handshake at /.well-known/auth, and each authenticated request checked and its answer signed, the way the SDK's clients (authhttp in Go, AuthFetch in TypeScript) send and check them.
Package backend is the hold-backend interface of spec section 17 and the native content-addressed backend on local disk.
Package backend is the hold-backend interface of spec section 17 and the native content-addressed backend on local disk.
Package chaincfg builds what every bstore program reads the chain through from its configuration: the chain view (transactions, proofs, spends), the header source and the tip, the settlement leg, and the miner fee policy.
Package chaincfg builds what every bstore program reads the chain through from its configuration: the chain view (transactions, proofs, spends), the header source and the tip, the settlement leg, and the miner fee policy.
cmd
bstore command
Command bstore is bstore's command line: the publisher client (spec sections 9 and 14), the bucket owner's tooling (sections 3.4 to 3.6 and 4.4), a verified reader (section 15) and the S3 gateway (`bstore s3d`, section 16).
Command bstore is bstore's command line: the publisher client (spec sections 9 and 14), the bucket owner's tooling (sections 3.4 to 3.6 and 4.4), a verified reader (section 15) and the S3 gateway (`bstore s3d`, section 16).
bstore-provider command
Command bstore-provider is a bstore storage provider: the market front of spec section 17 over the native content-addressed hold backend.
Command bstore-provider is a bstore storage provider: the market front of spec section 17 over the native content-addressed hold backend.
devchain command
Command devchain is a local stand-in chain for trying bstore without a node, a settlement service or any coin: it serves a node's JSON-RPC (generatetoaddress, sendrawtransaction, getinfo) at /rpc, a node's asset API under /api/v1/, and a header source (/v1/root/<height>, /v1/tip) that the bstore commands, the providers and the overlay hosts check proofs against.
Command devchain is a local stand-in chain for trying bstore without a node, a settlement service or any coin: it serves a node's JSON-RPC (generatetoaddress, sendrawtransaction, getinfo) at /rpc, a node's asset API under /api/v1/, and a header source (/v1/root/<height>, /v1/tip) that the bstore commands, the providers and the overlay hosts check proofs against.
vectors command
Command vectors writes the golden vectors under testdata/vectors.
Command vectors writes the golden vectors under testdata/vectors.
internal
acceptcfg
Package acceptcfg is the payment acceptance settings every bstore configuration file names (bcommon acceptance.Policy): the writer's home, the gateway's and the provider's, the same keys in each.
Package acceptcfg is the payment acceptance settings every bstore configuration file names (bcommon acceptance.Policy): the writer's home, the gateway's and the provider's, the same keys in each.
anchor
Package anchor is the bucket owner's tooling (spec sections 3.4 to 3.6 and 4.4): it creates a bucket chain, and anchors the entries of the owner and its writers into the chain's next tokens, exactly as frozen.
Package anchor is the bucket owner's tooling (spec sections 3.4 to 3.6 and 4.4): it creates a bucket chain, and anchors the entries of the owner and its writers into the chain's next tokens, exactly as frozen.
efleg
Package efleg hands a settlement leg every transaction with its inputs' source transactions attached.
Package efleg hands a settlement leg every transaction with its inputs' source transactions attached.
publish
Package publish is bstore's publisher (spec sections 5, 9, 13 and 14): it builds an object's CHIRP closure and proof root while the content streams (Store.Stage), mints a hold output when a bounty is asked for, makes the piece carriers and the entry, and delivers them over the plane, by unicast to the hosts and providers configured, or by BRC-167 upload session; it judges each bounty's race (race.go), settles it by rank or reclaims it after its deadline (settle.go), challenges providers (challenge.go), publishes outcome records, and sweeps its funding trees (sweep.go).
Package publish is bstore's publisher (spec sections 5, 9, 13 and 14): it builds an object's CHIRP closure and proof root while the content streams (Store.Stage), mints a hold output when a bounty is asked for, makes the piece carriers and the entry, and delivers them over the plane, by unicast to the hosts and providers configured, or by BRC-167 upload session; it judges each bounty's race (race.go), settles it by rank or reclaims it after its deadline (settle.go), challenges providers (challenge.go), publishes outcome records, and sweeps its funding trees (sweep.go).
reader
Package reader is a bstore reader (spec section 15): it asks the hosts it is given the free lookup questions of spec section 11.1, verifies every token, entry and advertisement against its own headers, proves what a key names, that a key is absent and that a listing page is complete against the chain's latest token, and reads an object's closure from its advertisers, every byte held to its hash before it is released.
Package reader is a bstore reader (spec section 15): it asks the hosts it is given the free lookup questions of spec section 11.1, verifies every token, entry and advertisement against its own headers, proves what a key names, that a key is absent and that a listing page is complete against the chain's latest token, and reads an object's closure from its advertisers, every byte held to its hash before it is released.
s3d
Package s3d is `bstore s3d`, the S3 gateway of spec section 16: a reader and a writer for clients that speak S3, authenticated with AWS Signature Version 4 in gateway mode.
Package s3d is `bstore s3d`, the S3 gateway of spec section 16: a reader and a writer for clients that speak S3, authenticated with AWS Signature Version 4 in gateway mode.
testwriter
Package testwriter is a minimal bstore writer for tests only: it funds itself from a local test chain's coinbase (coinbase: only on a regtest chain you run, development and tests), builds an object's CHIRP closure, mints its piece carriers, a hold output and the entry, submits them, asks hosts for advertisements, challenges providers, verifies their signed responses as a buyer does (spec section 7.4), buys renewals, and settles a bounty by rank with BRC-29 outputs and remittances (spec section 9.5).
Package testwriter is a minimal bstore writer for tests only: it funds itself from a local test chain's coinbase (coinbase: only on a regtest chain you run, development and tests), builds an object's CHIRP closure, mints its piece carriers, a hold output and the entry, submits them, asks hosts for advertisements, challenges providers, verifies their signed responses as a buyer does (spec section 7.4), buys renewals, and settles a bounty by rank with BRC-29 outputs and remittances (spec section 9.5).
vectors
Package vectors generates the golden vectors under testdata/vectors from the codec in storerec.
Package vectors generates the golden vectors under testdata/vectors from the codec in storerec.
Package provider is bstore-provider: the market front of spec section 17 over a hold backend.
Package provider is bstore-provider: the market front of spec section 17 over a hold backend.
Package storerec is the byte-level contract of bstore: the bucket record a mined token carries, the object entry, the piece, the outcome record and the front statement that ride unmined carriers, the challenge request and response, the hold terms, the key map and its contexts, the proof tree, settlement, BRC-26 advertisements, the names and lookup questions, the topic manager's transaction rules and a reader's checks that need no network.
Package storerec is the byte-level contract of bstore: the bucket record a mined token carries, the object entry, the piece, the outcome record and the front statement that ride unmined carriers, the challenge request and response, the hold terms, the key map and its contexts, the proof tree, settlement, BRC-26 advertisements, the names and lookup questions, the topic manager's transaction rules and a reader's checks that need no network.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL