dxs-stas-sdk 2.0.4 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +52 -0
- package/README.md +8 -0
- package/docs/AGENT_RUNBOOK.md +88 -0
- package/llms.txt +28 -0
- package/package.json +1 -1
package/AGENTS.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# AGENTS
|
|
2
|
+
|
|
3
|
+
This file is a fast onboarding entrypoint for AI coding agents working on this repository.
|
|
4
|
+
|
|
5
|
+
## Read order
|
|
6
|
+
|
|
7
|
+
1. `/Users/imighty/Code/dxs-stas-sdk/README.md` (public API and examples)
|
|
8
|
+
2. `/Users/imighty/Code/dxs-stas-sdk/docs/AGENT_RUNBOOK.md` (task-oriented execution flow)
|
|
9
|
+
3. `/Users/imighty/Code/dxs-stas-sdk/docs/DSTAS_0_0_8_SDK_SPEC.md` (normative protocol rules)
|
|
10
|
+
4. `/Users/imighty/Code/dxs-stas-sdk/docs/DSTAS_SCRIPT_INVARIANTS.md` (script-level invariants)
|
|
11
|
+
5. `/Users/imighty/Code/dxs-stas-sdk/docs/DSTAS_CONFORMANCE_MATRIX.md` (test mapping)
|
|
12
|
+
|
|
13
|
+
## Preferred implementation path
|
|
14
|
+
|
|
15
|
+
- Prefer high-level DSTAS APIs first:
|
|
16
|
+
- `DstasBundleFactory` for multi-step payout/split/merge planning.
|
|
17
|
+
- `BuildDstas*` helpers for single-flow transactions.
|
|
18
|
+
- Use legacy `stas*` APIs only for compatibility maintenance.
|
|
19
|
+
|
|
20
|
+
## Mandatory validation rule
|
|
21
|
+
|
|
22
|
+
For every protocol change or new flow, validate built tx hex with script evaluation:
|
|
23
|
+
|
|
24
|
+
- Use `evaluateTransactionHex(...)` from `/Users/imighty/Code/dxs-stas-sdk/src/script/eval/script-evaluator.ts`.
|
|
25
|
+
- Provide an explicit prevout resolver from known `OutPoint`/transaction fixtures.
|
|
26
|
+
- Never mark a DSTAS flow complete without script-level evaluation coverage.
|
|
27
|
+
|
|
28
|
+
## Testing expectations
|
|
29
|
+
|
|
30
|
+
- Put deterministic fixtures under `/Users/imighty/Code/dxs-stas-sdk/tests/fixtures/`.
|
|
31
|
+
- Keep debug/probe helpers under `/Users/imighty/Code/dxs-stas-sdk/tests/debug/`.
|
|
32
|
+
- Do not depend on local `.temp` files in CI-facing tests.
|
|
33
|
+
- Update conformance vectors when behavior intentionally changes:
|
|
34
|
+
- `/Users/imighty/Code/dxs-stas-sdk/tests/fixtures/dstas-conformance-vectors.json`
|
|
35
|
+
|
|
36
|
+
## Safety and constraints
|
|
37
|
+
|
|
38
|
+
- Keep strict parsing enabled by default (`strictTxParse=true`).
|
|
39
|
+
- Preserve flags/service-field ordering and optional-data continuity invariants.
|
|
40
|
+
- Keep multisig bounds enforced (`m <= n`, `n <= 5`) unless protocol spec changes.
|
|
41
|
+
- Avoid silent behavior changes in unlock/signing semantics; cover with negative tests.
|
|
42
|
+
|
|
43
|
+
## Standard local commands
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install
|
|
47
|
+
npm run build
|
|
48
|
+
npm run lint
|
|
49
|
+
npm test
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
For targeted runs, prefer file-scoped Jest execution over full-suite reruns while iterating.
|
package/README.md
CHANGED
|
@@ -12,6 +12,14 @@ All binary inputs/outputs are `Uint8Array` (no Node.js `Buffer` in the public AP
|
|
|
12
12
|
npm install dxs-stas-sdk
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
## AI Agent onboarding
|
|
16
|
+
|
|
17
|
+
If you are integrating this SDK through an AI coding agent, start with:
|
|
18
|
+
|
|
19
|
+
- `AGENTS.md` (fast onboarding and guardrails)
|
|
20
|
+
- `docs/AGENT_RUNBOOK.md` (task execution workflow)
|
|
21
|
+
- `docs/DSTAS_0_0_8_SDK_SPEC.md` (normative protocol behavior)
|
|
22
|
+
|
|
15
23
|
## Concepts
|
|
16
24
|
|
|
17
25
|
An `OutPoint` represents a spendable UTXO: txid, vout, locking script, satoshis, and owner address.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Agent Runbook
|
|
2
|
+
|
|
3
|
+
This runbook is the practical workflow for implementing or modifying DSTAS behavior in this SDK.
|
|
4
|
+
|
|
5
|
+
## 1. Pick the right API level
|
|
6
|
+
|
|
7
|
+
Use the highest-level API that satisfies the task:
|
|
8
|
+
|
|
9
|
+
1. `DstasBundleFactory` (`src/dstas-bundle-factory.ts`)
|
|
10
|
+
For many recipients and automatic merge/split/service planning.
|
|
11
|
+
2. `BuildDstas*` helpers (`src/dstas-factory.ts`)
|
|
12
|
+
For explicit issue/transfer/freeze/unfreeze/confiscate/swap/redeem flows.
|
|
13
|
+
3. `TransactionBuilder` + script builders
|
|
14
|
+
Only when lower-level control is required.
|
|
15
|
+
|
|
16
|
+
## 2. Keep protocol invariants intact
|
|
17
|
+
|
|
18
|
+
Before code changes, verify expected behavior against:
|
|
19
|
+
|
|
20
|
+
- `docs/DSTAS_0_0_8_SDK_SPEC.md`
|
|
21
|
+
- `docs/DSTAS_SCRIPT_INVARIANTS.md`
|
|
22
|
+
|
|
23
|
+
Critical invariant groups:
|
|
24
|
+
|
|
25
|
+
- flags/service-field coupling and order;
|
|
26
|
+
- action-data semantics (neutral/swap);
|
|
27
|
+
- optional-data continuity;
|
|
28
|
+
- issuer-only redeem rules;
|
|
29
|
+
- freeze/confiscation layering;
|
|
30
|
+
- multisig bounds (`n <= 5`, no duplicate keys).
|
|
31
|
+
|
|
32
|
+
## 3. Add or update tests first-class
|
|
33
|
+
|
|
34
|
+
Primary suites:
|
|
35
|
+
|
|
36
|
+
- `tests/dstas-flow.test.ts` (end-to-end protocol flows + negative cases)
|
|
37
|
+
- `tests/dstas-bundle-factory.test.ts` (high-level planning)
|
|
38
|
+
- `tests/dstas-factory-guards.test.ts` (input guards)
|
|
39
|
+
- `tests/dstas-conformance-vectors.test.ts` (vector conformance)
|
|
40
|
+
|
|
41
|
+
Rules:
|
|
42
|
+
|
|
43
|
+
- Use deterministic fixtures from `tests/fixtures/`.
|
|
44
|
+
- Do not depend on local `.temp` files.
|
|
45
|
+
- Keep debug-only probes in `tests/debug/`.
|
|
46
|
+
|
|
47
|
+
## 4. Mandatory script-level validation
|
|
48
|
+
|
|
49
|
+
For every flow-producing change, evaluate tx hex through script interpreter:
|
|
50
|
+
|
|
51
|
+
- Use `evaluateTransactionHex` from `src/script/eval/script-evaluator.ts`.
|
|
52
|
+
- Use a strict prevout resolver from known outputs.
|
|
53
|
+
- Cover both positive and negative paths where applicable.
|
|
54
|
+
|
|
55
|
+
Minimal expectation in tests:
|
|
56
|
+
|
|
57
|
+
- `success === true` for valid flow;
|
|
58
|
+
- explicit failure reason checks for invalid flow.
|
|
59
|
+
|
|
60
|
+
## 5. Update docs when behavior changes
|
|
61
|
+
|
|
62
|
+
When protocol behavior, API shape, or guarantees change, update:
|
|
63
|
+
|
|
64
|
+
- `README.md` for user-facing API examples;
|
|
65
|
+
- `docs/DSTAS_0_0_8_SDK_SPEC.md` for normative rules;
|
|
66
|
+
- `docs/DSTAS_CONFORMANCE_MATRIX.md` for coverage mapping.
|
|
67
|
+
|
|
68
|
+
If vectors changed intentionally, refresh fixtures and note it in PR summary.
|
|
69
|
+
|
|
70
|
+
## 6. Pre-commit checks
|
|
71
|
+
|
|
72
|
+
Run:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm run build
|
|
76
|
+
npm run lint
|
|
77
|
+
npm test
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
If only one suite changed, run targeted tests first, then full-suite before merge.
|
|
81
|
+
|
|
82
|
+
## 7. Common failure modes
|
|
83
|
+
|
|
84
|
+
- Missing/mismatched prevout resolver entries during evaluation.
|
|
85
|
+
- Action-data hash domain drift (`requestedScriptHash` scope regression).
|
|
86
|
+
- Wrong service-field order when multiple policy bits are enabled.
|
|
87
|
+
- Optional-data dropped on descendant outputs, causing merge/spend failures.
|
|
88
|
+
- Treating debug artifacts as fixtures.
|
package/llms.txt
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# dxs-stas-sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for building and validating Bitcoin SV transaction flows, including Divisible STAS (DSTAS) issue, transfer, split, merge, freeze/unfreeze, confiscation, swap, and redeem.
|
|
4
|
+
|
|
5
|
+
## Primary docs
|
|
6
|
+
|
|
7
|
+
- [README](README.md): public API, install, and usage examples.
|
|
8
|
+
- [AGENTS](AGENTS.md): shortest practical onboarding path for coding agents.
|
|
9
|
+
- [Agent Runbook](docs/AGENT_RUNBOOK.md): implementation and validation workflow.
|
|
10
|
+
|
|
11
|
+
## Protocol references
|
|
12
|
+
|
|
13
|
+
- [DSTAS 0.0.8 SDK Spec](docs/DSTAS_0_0_8_SDK_SPEC.md): normative behavior implemented by the SDK.
|
|
14
|
+
- [DSTAS Script Invariants](docs/DSTAS_SCRIPT_INVARIANTS.md): script-level invariants and conservation rules.
|
|
15
|
+
- [DSTAS Conformance Matrix](docs/DSTAS_CONFORMANCE_MATRIX.md): mapping of protocol rules to tests.
|
|
16
|
+
|
|
17
|
+
## Additional references
|
|
18
|
+
|
|
19
|
+
- [STAS3 Freeze/Multisig Notes](docs/STAS3_FREEZE_MULTISIG.md)
|
|
20
|
+
- [Migration Notes](docs/MIGRATION.md)
|
|
21
|
+
- [Agent Handbook (repo snapshot)](docs/AGENT_HANDBOOK.md)
|
|
22
|
+
|
|
23
|
+
## Code entry points
|
|
24
|
+
|
|
25
|
+
- `src/index.ts`
|
|
26
|
+
- `src/dstas-factory.ts`
|
|
27
|
+
- `src/dstas-bundle-factory.ts`
|
|
28
|
+
- `src/script/eval/script-evaluator.ts`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dxs-stas-sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "TypeScript SDK for building and validating multiple Bitcoin SV transaction flows, including DSTAS token issue, transfer, split, merge, swap, freeze/unfreeze, and redeem.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|