From 69a97544dabdfb812c332ca37f4ef460f291d9a2 Mon Sep 17 00:00:00 2001 From: teahubxyz Date: Thu, 15 Oct 2026 00:32:29 -0700 Subject: [PATCH] Orgchain v1.7: items, standing offers and the first deal; a Mainnet setting The chain takes ordinary spends of up to eight inputs and outputs, whose key-path signatures may carry SIGHASH_SINGLE|ANYONECANPAY (0x83); reveals keep their two-in, two-out shape. A new make op records an item, an inscription its maker holds. Any node can offer test BTC for an item another node holds, in any holding: the buyer's SegWit key signs the whole deal, the offer stands in the lab, and the holder accepts by countersigning the item's input, so the item and the payment swap in one transaction. Offers go stale when a promised coin moves or a side re-keys or closes, and payments spend unpromised coins first. Sends take up to eight coins. Mainnet is a third mining setting: no holding mines, beats pay the lab wallet, and holdings are funded from it. The sample ends on lineage's open offer for sol's launch-kit. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01H4upF5LVwmPDDqrhdUfnXh --- AGENTS.md | 17 ++-- PROVENANCE.md | 2 +- README.md | 36 ++++++--- index.html | 35 ++++++-- src/adapters/chain.js | 16 ++-- src/main.js | 171 +++++++++++++++++++++++++++++++++------- src/orgchain.css | 10 +++ src/orgchain/actions.js | 63 ++++++++++++--- src/orgchain/lineage.js | 14 +++- src/orgchain/money.js | 106 +++++++++++++++++-------- src/orgchain/offers.js | 119 ++++++++++++++++++++++++++++ src/orgchain/store.js | 20 +++-- tests/money.test.js | 30 ++++++- tests/offers.test.js | 169 +++++++++++++++++++++++++++++++++++++++ tests/orgchain.spec.js | 67 ++++++++++++++++ 15 files changed, 764 insertions(+), 111 deletions(-) create mode 100644 src/orgchain/offers.js create mode 100644 tests/offers.test.js diff --git a/AGENTS.md b/AGENTS.md index 6ac8797..25eacdc 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -7,12 +7,17 @@ Orgchain is lineage's app for creating and operating lineage holdings on Super T is vetted by that reducer before it is signed. A new op means a reducer change, its tests and the README's table. - The engine (`src/adapters`, `src/upstream`, `src/storage.js`, `src/miner.js`) is Super Testnet's. Compose with it rather than rewriting it, and keep its tests passing. Preserve upstream licenses and provenance. Its local - changes are P2WPKH payments and a coinbase split across up to 64 outputs, both in `src/adapters/chain.js` - (PROVENANCE.md); keep them small and tested. -- Money lives in `src/orgchain/money.js`: beats pay the holdings (split by hashrate, or all to the last act), sends - spend SegWit coins only, so an inscription can never leave as change, and balances are read off the chain, never - stored. Gas (`src/orgchain/actions.js`): every act is paid by the actor's own keys and checked before anything is - signed; the lab wallet pays only for foundings and for holdings that predate lab keys. + changes are P2WPKH payments, a coinbase split across up to 64 outputs, and ordinary spends of up to eight inputs + and outputs whose key-path signatures may carry 0x83, all in `src/adapters/chain.js` (PROVENANCE.md); keep them + small and tested. +- Money lives in `src/orgchain/money.js`: beats pay the holdings (split by hashrate, or all to the last act; under + Mainnet none mine, and the lab wallet funds them), sends spend SegWit coins only, so an inscription can never leave + as change, and balances are read off the chain, never stored. Gas (`src/orgchain/actions.js`): every act is paid by + the actor's own keys and checked before anything is signed; the lab wallet pays only for foundings and for holdings + that predate lab keys. +- Deals live in `src/orgchain/offers.js`: the buyer pre-signs the whole transaction and the holder countersigns. + An offer is signatures kept in the lab, never chain state, and who holds an item is read off the chain, never + from metadata. Inscription metadata is public and permanent, so never put a secret in it (item notes included). - Keys follow the tree (`src/orgchain/keys.js`): store roots only (one per holding, one per graduated org) and derive every other key from its position. Every act is signed by whichever key holds the authorizing inscription. - A node's chain key is its account's BIP-86 Taproot key (`m/86'/1'/account'/0/0`); SegWit is BIP-84 at the same diff --git a/PROVENANCE.md b/PROVENANCE.md index 41702cd..ad2c401 100644 --- a/PROVENANCE.md +++ b/PROVENANCE.md @@ -20,7 +20,7 @@ Runtime dependencies are pinned in `package.json` and `package-lock.json`: - **@scure/bip32 1.7.0**, Patricio Palladino and Paul Miller, [upstream](https://github.com/paulmillr/scure-bip32), MIT. Used for HD derivation under the BIP-85, BIP-86, BIP-84 and NIP-06 paths. License retained at [`public/licenses/scure-bip32.txt`](public/licenses/scure-bip32.txt). - **@scure/bip39 1.6.0**, Patricio Palladino and Paul Miller, [upstream](https://github.com/paulmillr/scure-bip39), MIT. Used for the 24-word lab roots and their seeds. License retained at [`public/licenses/scure-bip39.txt`](public/licenses/scure-bip39.txt). -Two local changes to the engine, both original code in `src/adapters/chain.js`, tested in `tests/money.test.js`, with Super Testnet's tests (`tests/adapters.test.js`) passing unchanged. Orgchain v1.5: the chain also accepts native SegWit (P2WPKH) outputs and SIGHASH_ALL P2WPKH spends, verified per BIP-143, so lineage accounts can hold and send test BTC at their BIP-84 addresses; everything about inscriptions stays Taproot-only. Orgchain v1.6: a coinbase may split the block reward across up to 64 outputs (`mineTo`; `mine` still pays one script), so one beat can pay several holdings. +Three local changes to the engine, all original code in `src/adapters/chain.js`, tested in `tests/money.test.js`, with Super Testnet's tests (`tests/adapters.test.js`) passing unchanged. Orgchain v1.5: the chain also accepts native SegWit (P2WPKH) outputs and SIGHASH_ALL P2WPKH spends, verified per BIP-143, so lineage accounts can hold and send test BTC at their BIP-84 addresses; everything about inscriptions stays Taproot-only. Orgchain v1.6: a coinbase may split the block reward across up to 64 outputs (`mineTo`; `mine` still pays one script), so one beat can pay several holdings. Orgchain v1.7: ordinary (non-reveal) spends may take up to eight inputs and outputs (`MAX_IO`), and their key-path Taproot signatures may carry SIGHASH_SINGLE|ANYONECANPAY (0x83, the sell-order flag), so one transaction can carry a deal: an item, the buyer's coins, the price and change. Reveals keep their two-in, two-out shape and default signatures. Vite and Playwright are build/test dependencies, not runtime network services. Their installed package notices remain in the locked dependency installation. No unlicensed upstream code was copied. diff --git a/README.md b/README.md index 5c6bdab..d346c52 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,9 @@ inscription on a private toy chain in your browser, and its parent inscription i chain itself records who did what, and when. - **Found** a holding (a root: the LLC). **Birth** orgs and agents under any org. **Award** a belt (one skill, one - seat). **Decide** (a decision on a node's record). **Graduate** an org (its edge flips from derived to adopted). - **Close** a node (derived children close with it; graduated ones hold their own roots and stay open). + seat). **Decide** (a decision on a node's record). **Make** an item (an inscription its maker holds, and can sell). + **Graduate** an org (its edge flips from derived to adopted). **Close** a node (derived children close with it; + graduated ones hold their own roots and stay open). - **Time.** A beat is a block. At the default tempo each act is its own beat; at 10, 30 or 60 seconds, acts are cued and land together on the next beat; on manual they wait for *Beat now*. The slider and *Replay* show a holding as it stood at any beat. @@ -16,8 +17,10 @@ chain itself records who did what, and when. every active holding mines, and each beat's 50 test BTC splits pro rata by hashrate, a dial from 0 to 9 on each holding (1 unless set), one coinbase output per holding; under *Last act* the holding behind the latest act or send takes the whole beat (with nothing cued, *Beat now* pays the one being worked in), so at a timed tempo acts race - for the next beat. **Send** moves test BTC from any active node to any other, in - its holding or another, signed by the sender's BIP-84 key: at most two coins in, at most 50 test BTC out, and the + for the next beat; under *Mainnet* no holding mines, as on mainnet: beats pay the lab wallet, standing in for the + world's miners, and **Fund** moves test BTC from it to a holding, the way you'd fund a seed from a wallet you + already have. **Send** moves test BTC from any active node to any other, in + its holding or another, signed by the sender's BIP-84 key: at most eight coins in, at most 50 test BTC out, and the toy chain's fixed 500-sat fee. Sends land like acts, at once or cued, and *Beat now* mines a beat even when nothing is cued. A graduation moves each re-keyed node's money to its new address along with its inscription. Balances follow the slider, the timeline lists every reward, send and gas top-up, and Inspect has the exact amounts and the @@ -27,6 +30,13 @@ chain itself records who did what, and when. up from its own money 0.0001 test BTC at a time. A node with neither can't act until someone sends it money, and a graduating org pays for the claim on its new root itself. The lab wallet pays only for foundings (a holding owns nothing until it mines) and for holdings that predate lab keys. +- **Deals.** Any active node can **Offer** on an item another node holds, in any holding: OpenOrdex's buy order, with + a price. Its SegWit key signs the whole deal at once (SIGHASH_ALL): the item and its own coins in; the item to its + Taproot key, the price to the holder's SegWit address and its change out. Nothing reaches the chain until the + holder **Accepts** by countersigning the item's input, so the offer stands, kept in the lab like a PSBT in an + order book, until it is accepted, withdrawn, or goes stale (a coin it promised moved, or a side closed or re-keyed). + The buyer pays the fee; a price of 0 is a free claim. Payments spend coins no offer has promised first. Accepted + offers stay as the deals' receipts, and the timeline and Inspect show each deal (`src/orgchain/offers.js`). - **One interpretation.** `src/orgchain/lineage.js` folds `lineage/v0` events into trees, and vets every act before anything is signed. Events it rejects stay on the chain and show as rejected; they just don't change the tree. - **Keys.** Each holding gets its own 24-word lab root, and every node has lineage's keys at its place in the tree @@ -46,8 +56,9 @@ chain itself records who did what, and when. BIP-380 checksums), and its leaves' private keys (OpenSSH, DKIM, WireGuard, PKCS#8, Headscale). Hidden again on every selection; lab keys only. -Test coins and test keys only: a local chain, the lab wallet (the faucet that pays for foundings) and each holding's lab -root, kept in this browser (`localStorage`, key `orgchain:lab:v1`). Nothing here is a real key; minting a real root is +Test coins and test keys only: a local chain, the lab wallet (the faucet that pays for foundings, and under *Mainnet* +the wallet holdings are funded from) and each holding's lab root, kept in this browser (`localStorage`, key +`orgchain:lab:v1`). Nothing here is a real key; minting a real root is the operator's call. ## Events @@ -60,11 +71,14 @@ the operator's call. | `birth` | the parent | `name`, `kind` (`org` or `agent`) | | `award` | the issuing org or holding | `to`, `skill`, `belt` (`white`, `green`, `black`) | | `decide` | the deciding node | `title`, `why` | +| `make` | the making node, which then holds the item | `name`, `note` | | `graduate` | the child's parent (then the handoff to the child's fresh root) | `of` | | `close` | the node itself | none | Names are domain labels (lowercase letters, digits, hyphens). Org and agent indices count separately and are never -reused. +reused. The metadata says what an event means; the parent it spends proves who was allowed to make it; who holds an +item afterwards is the chain's to say, never the metadata's. Metadata is public and permanent: an item's note is for a +hash or a link, never a secret or a document. ## Build and test @@ -83,9 +97,11 @@ Deploy: copy `dist/` to `ventures/lineage/orgchain/` on `teahubxyz/time` `gh-pag ## Built on Super Testnet The chain, wallet, inscriptions, metadata and index (`src/adapters`, `src/upstream`, with `src/storage.js` and -`src/miner.js`) are [Super Testnet](https://supertestnet.lol)'s, with their tests (`tests/adapters.test.js`) and two -additions: the chain also moves native SegWit (P2WPKH) payments, BIP-143 signatures included, and a coinbase may -split its reward across up to 64 outputs (`tests/money.test.js`). +`src/miner.js`) are [Super Testnet](https://supertestnet.lol)'s, with their tests (`tests/adapters.test.js`) and three +additions: the chain also moves native SegWit (P2WPKH) payments, BIP-143 signatures included; a coinbase may split +its reward across up to 64 outputs; and ordinary spends take up to eight inputs and outputs, whose key-path +signatures may carry SIGHASH_SINGLE|ANYONECANPAY (0x83, the sell-order flag), while reveals keep their two-in, +two-out shape (`tests/money.test.js`). See `PROVENANCE.md` and `public/licenses/`. Lineage's key derivation and the claim and countersign handoff (`src/adapters/lineage-keys.js`, `src/adapters/handoff.js`, with their spec vectors in `tests/keys.test.js`) come from the `tree` branch. The full lab (explorer, delegates, recursion and diff --git a/index.html b/index.html index 8b8023d..629b981 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ Orgchain · Lineage - + @@ -16,7 +16,7 @@

Lineage /

Orgchain

-

Found a holding, then birth its orgs and agents, award belts, record decisions, send test BTC, graduate and close. Each act is an inscription whose parent is the node that authorizes it, paid for with the actor's own gas, and each beat is a block whose 50 test BTC the holdings mine. Lineage gives the structure; the chain adds time.

+

Found a holding, then birth its orgs and agents, award belts, record decisions, make and trade items, send test BTC, graduate and close. Each act is an inscription whose parent is the node that authorizes it, paid for with the actor's own gas, and each beat is a block whose 50 test BTC the holdings mine. Lineage gives the structure; the chain adds time.

Test coins only @@ -53,8 +53,15 @@

A holding is the root of a lineage tree: the LLC that births orgs and agents. Found one, or load the sample, the yolopreneur tree from the Lineage docs over six beats.

Mining -
+

+
@@ -81,7 +88,7 @@

Select a holding, or a node in its tree, to act through it.