@smartledger/bsv 7.3.0 → 7.4.0
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/CHANGELOG.md +44 -0
- package/README.md +38 -38
- package/bsv-gdaf.min.js +43 -43
- package/bsv-ltp.min.js +43 -43
- package/bsv-smartcontract.min.js +1 -1
- package/bsv.bundle.js +43 -43
- package/bsv.d.ts +19 -4
- package/bsv.min.js +43 -43
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/getting-started/INSTALLATION.md +23 -23
- package/docs/getting-started/QUICK_START.md +7 -7
- package/docs/migration/FROM_BSV_1_5_6.md +5 -5
- package/lib/ordinals/README.md +15 -5
- package/lib/ordinals/bsv20.js +96 -3
- package/package.json +1 -1
- package/test/ordinals/bsv20.js +115 -0
- package/version.js +1 -1
|
@@ -55,19 +55,19 @@ Three advanced modules totaling **~2.7MB** of functionality:
|
|
|
55
55
|
- **Purpose**: Threshold cryptography for secure secret distribution
|
|
56
56
|
- **Use Cases**: Backup keys, multi-party security, key recovery
|
|
57
57
|
- **Features**: Split secrets into N shares, require M to reconstruct
|
|
58
|
-
- **CDN**: `unpkg.com/@smartledger/bsv@7.
|
|
58
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@7.4.0/bsv-shamir.min.js`
|
|
59
59
|
|
|
60
60
|
#### **🌐 Global Digital Attestation Framework - GDAF (1184KB)**
|
|
61
61
|
- **Purpose**: W3C Verifiable Credentials and decentralized identity
|
|
62
62
|
- **Use Cases**: Identity verification, attestations, zero-knowledge proofs
|
|
63
63
|
- **Features**: DID creation, credential issuance, selective disclosure
|
|
64
|
-
- **CDN**: `unpkg.com/@smartledger/bsv@7.
|
|
64
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js`
|
|
65
65
|
|
|
66
66
|
#### **⚖️ Legal Token Protocol - LTP (1184KB)**
|
|
67
67
|
- **Purpose**: Legal compliance framework for tokenized assets
|
|
68
68
|
- **Use Cases**: Property rights, obligations, compliant tokenization
|
|
69
69
|
- **Features**: Legal primitives, compliance checking, attestation anchoring
|
|
70
|
-
- **CDN**: `unpkg.com/@smartledger/bsv@7.
|
|
70
|
+
- **CDN**: `unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js`
|
|
71
71
|
|
|
72
72
|
### **2. Incorrect File Sizes in Documentation**
|
|
73
73
|
|
|
@@ -81,18 +81,18 @@ Three advanced modules totaling **~2.7MB** of functionality:
|
|
|
81
81
|
|
|
82
82
|
| Module | Size | Use Case | CDN Link |
|
|
83
83
|
|--------|------|----------|----------|
|
|
84
|
-
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.
|
|
85
|
-
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.
|
|
86
|
-
| **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.
|
|
87
|
-
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.
|
|
88
|
-
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.
|
|
89
|
-
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.
|
|
90
|
-
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.
|
|
91
|
-
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.
|
|
92
|
-
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.
|
|
93
|
-
| **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.
|
|
94
|
-
| **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.
|
|
95
|
-
| **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.
|
|
84
|
+
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js` |
|
|
85
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js` |
|
|
86
|
+
| **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js` |
|
|
87
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.4.0/bsv-covenant.min.js` |
|
|
88
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.4.0/bsv-script-helper.min.js` |
|
|
89
|
+
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.4.0/bsv-security.min.js` |
|
|
90
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.4.0/bsv-ecies.min.js` |
|
|
91
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.4.0/bsv-message.min.js` |
|
|
92
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.4.0/bsv-mnemonic.min.js` |
|
|
93
|
+
| **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-shamir.min.js` |
|
|
94
|
+
| **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js` |
|
|
95
|
+
| **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js` |
|
|
96
96
|
|
|
97
97
|
## 🎯 **Updated Usage Examples**
|
|
98
98
|
|
|
@@ -100,22 +100,22 @@ Three advanced modules totaling **~2.7MB** of functionality:
|
|
|
100
100
|
|
|
101
101
|
#### **1. Basic Development (~963KB)**
|
|
102
102
|
```html
|
|
103
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
104
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
103
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
|
|
104
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-script-helper.min.js"></script>
|
|
105
105
|
```
|
|
106
106
|
|
|
107
107
|
#### **2. Smart Contract Development (~2.7MB — each bundle re-embeds core BSV)**
|
|
108
108
|
```html
|
|
109
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
110
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
111
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
109
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
|
|
110
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-covenant.min.js"></script>
|
|
111
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js"></script>
|
|
112
112
|
```
|
|
113
113
|
|
|
114
114
|
#### **3. 🆕 Legal & Compliance Development (~3.2MB — each bundle re-embeds core BSV)**
|
|
115
115
|
```html
|
|
116
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
117
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
118
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
116
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
|
|
117
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js"></script>
|
|
118
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js"></script>
|
|
119
119
|
<script>
|
|
120
120
|
// Legal Token Protocol
|
|
121
121
|
const legalToken = bsv.createLegalToken({
|
|
@@ -132,9 +132,9 @@ Three advanced modules totaling **~2.7MB** of functionality:
|
|
|
132
132
|
|
|
133
133
|
#### **4. 🆕 Security & Cryptography (~1.4MB)**
|
|
134
134
|
```html
|
|
135
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
136
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
137
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
135
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-security.min.js"></script>
|
|
137
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-shamir.min.js"></script>
|
|
138
138
|
<script>
|
|
139
139
|
// Shamir Secret Sharing
|
|
140
140
|
const shares = bsv.splitSecret('my_secret_key', 5, 3); // 5 shares, 3 needed
|
|
@@ -146,7 +146,7 @@ Three advanced modules totaling **~2.7MB** of functionality:
|
|
|
146
146
|
|
|
147
147
|
#### **5. Everything Bundle (937KB)**
|
|
148
148
|
```html
|
|
149
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
149
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js"></script>
|
|
150
150
|
<script>
|
|
151
151
|
// Everything available immediately
|
|
152
152
|
const shares = bsv.splitSecret('secret', 5, 3);
|
|
@@ -722,7 +722,7 @@ interface UTXO {
|
|
|
722
722
|
<html>
|
|
723
723
|
<head>
|
|
724
724
|
<title>UTXO Manager Demo</title>
|
|
725
|
-
<script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@7.
|
|
725
|
+
<script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@7.4.0/bsv.min.js"></script>
|
|
726
726
|
</head>
|
|
727
727
|
<body>
|
|
728
728
|
<script>
|
|
@@ -48,7 +48,7 @@ const tx: Transaction = new Transaction();
|
|
|
48
48
|
#### **Core Library Only (937KB)**
|
|
49
49
|
For basic Bitcoin SV operations:
|
|
50
50
|
```html
|
|
51
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
51
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
|
|
52
52
|
<script>
|
|
53
53
|
const privateKey = new bsv.PrivateKey();
|
|
54
54
|
const address = privateKey.toAddress();
|
|
@@ -58,7 +58,7 @@ For basic Bitcoin SV operations:
|
|
|
58
58
|
#### **Complete Bundle (937KB)**
|
|
59
59
|
Everything in one file:
|
|
60
60
|
```html
|
|
61
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
61
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js"></script>
|
|
62
62
|
<script>
|
|
63
63
|
// All features available immediately
|
|
64
64
|
const shares = bsv.splitSecret('secret', 5, 3);
|
|
@@ -71,9 +71,9 @@ Everything in one file:
|
|
|
71
71
|
|
|
72
72
|
#### **Smart Contract Development (~2.7MB total — each bundle is self-contained and re-embeds core BSV)**
|
|
73
73
|
```html
|
|
74
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
75
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
76
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
74
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
|
|
75
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-covenant.min.js"></script>
|
|
76
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js"></script>
|
|
77
77
|
<script>
|
|
78
78
|
const covenant = bsv.SmartContract.createCovenantBuilder()
|
|
79
79
|
.extractField('amount').push(50000).greaterThanOrEqual().build();
|
|
@@ -82,9 +82,9 @@ Everything in one file:
|
|
|
82
82
|
|
|
83
83
|
#### **Legal & Identity Development (~3.2MB total — each bundle is self-contained and re-embeds core BSV)**
|
|
84
84
|
```html
|
|
85
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
86
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
87
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
85
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
|
|
86
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js"></script>
|
|
87
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js"></script>
|
|
88
88
|
<script>
|
|
89
89
|
// Legal Token Protocol
|
|
90
90
|
const propertyToken = bsv.createPropertyToken({
|
|
@@ -98,9 +98,9 @@ Everything in one file:
|
|
|
98
98
|
|
|
99
99
|
#### **Security & Cryptography (~1.4MB total — each bundle is self-contained and re-embeds core BSV)**
|
|
100
100
|
```html
|
|
101
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
102
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
103
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
101
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
|
|
102
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-security.min.js"></script>
|
|
103
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-shamir.min.js"></script>
|
|
104
104
|
<script>
|
|
105
105
|
// Threshold Cryptography
|
|
106
106
|
const shares = bsv.splitSecret('my_secret_key', 5, 3);
|
|
@@ -114,18 +114,18 @@ Everything in one file:
|
|
|
114
114
|
|
|
115
115
|
| Module | Size | Purpose | CDN Link |
|
|
116
116
|
|--------|------|---------|----------|
|
|
117
|
-
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.
|
|
118
|
-
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.
|
|
119
|
-
| **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.
|
|
120
|
-
| **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.
|
|
121
|
-
| **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.
|
|
122
|
-
| **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.
|
|
123
|
-
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.
|
|
124
|
-
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.
|
|
125
|
-
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.
|
|
126
|
-
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.
|
|
127
|
-
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.
|
|
128
|
-
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.
|
|
117
|
+
| **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js` |
|
|
118
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js` |
|
|
119
|
+
| **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js` |
|
|
120
|
+
| **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js` |
|
|
121
|
+
| **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js` |
|
|
122
|
+
| **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.4.0/bsv-shamir.min.js` |
|
|
123
|
+
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.4.0/bsv-security.min.js` |
|
|
124
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.4.0/bsv-mnemonic.min.js` |
|
|
125
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.4.0/bsv-ecies.min.js` |
|
|
126
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.4.0/bsv-covenant.min.js` |
|
|
127
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.4.0/bsv-script-helper.min.js` |
|
|
128
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.4.0/bsv-message.min.js` |
|
|
129
129
|
|
|
130
130
|
## ⚙️ **Development Environment Setup**
|
|
131
131
|
|
|
@@ -14,10 +14,10 @@ npm install @smartledger/bsv
|
|
|
14
14
|
### Browser CDN (Instant)
|
|
15
15
|
```html
|
|
16
16
|
<!-- Core library (937KB) -->
|
|
17
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
17
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
|
|
18
18
|
|
|
19
19
|
<!-- Everything included (937KB) -->
|
|
20
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
20
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js"></script>
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
## 💰 **Your First Transaction (60 seconds)**
|
|
@@ -127,19 +127,19 @@ SmartLedger-BSV offers 12 different loading options - use only what you need:
|
|
|
127
127
|
|
|
128
128
|
```html
|
|
129
129
|
<!-- Core BSV only (937KB) -->
|
|
130
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
130
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
|
|
131
131
|
|
|
132
132
|
<!-- Smart contracts (937KB) -->
|
|
133
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
133
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js"></script>
|
|
134
134
|
|
|
135
135
|
<!-- Legal tokens (1.16MB) -->
|
|
136
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js"></script>
|
|
137
137
|
|
|
138
138
|
<!-- Digital identity (1.16MB) -->
|
|
139
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
139
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js"></script>
|
|
140
140
|
|
|
141
141
|
<!-- Everything (937KB) -->
|
|
142
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
142
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js"></script>
|
|
143
143
|
```
|
|
144
144
|
|
|
145
145
|
## ⚡ **Key Advantages**
|
|
@@ -159,17 +159,17 @@ const recovered = bsv.reconstructSecret([shares[0], shares[2], shares[4]]);
|
|
|
159
159
|
### **New Modular Options**
|
|
160
160
|
```html
|
|
161
161
|
<!-- Core compatibility (same size as bsv@1.5.6) -->
|
|
162
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
162
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.min.js"></script>
|
|
163
163
|
|
|
164
164
|
<!-- Add smart contracts when ready -->
|
|
165
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
165
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-smartcontract.min.js"></script>
|
|
166
166
|
|
|
167
167
|
<!-- Add advanced features as needed -->
|
|
168
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
169
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
168
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-ltp.min.js"></script>
|
|
169
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv-gdaf.min.js"></script>
|
|
170
170
|
|
|
171
171
|
<!-- Everything in one file -->
|
|
172
|
-
<script src="https://unpkg.com/@smartledger/bsv@7.
|
|
172
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.4.0/bsv.bundle.js"></script>
|
|
173
173
|
```
|
|
174
174
|
|
|
175
175
|
## 🔍 **Testing Your Migration**
|
package/lib/ordinals/README.md
CHANGED
|
@@ -176,10 +176,17 @@ B.buildDeploy({ address: owner, tick: 'ORDI', max: '21000000', lim: '1000', dec:
|
|
|
176
176
|
B.buildMint({ address: owner, tick: 'ORDI', amt: '1000' })
|
|
177
177
|
B.buildTransfer({ address: newOwner, tick: 'ORDI', amt: '250' })
|
|
178
178
|
|
|
179
|
-
// v2 / BSV-21: deploy+mint
|
|
179
|
+
// v2 / BSV-21, fixed supply: deploy+mint, then transfer by id.
|
|
180
180
|
B.buildDeployMint({ address: owner, amt: '1000000', dec: 8, sym: 'XYZ' })
|
|
181
181
|
B.buildTransfer({ address: newOwner, id: deployTxid + '_0', amt: '5' })
|
|
182
182
|
|
|
183
|
+
// v2 / BSV-21, authority model: no supply at deploy; an auth output carries the right
|
|
184
|
+
// to mint, and minting names the token by id (and needs an auth input on chain).
|
|
185
|
+
B.buildDeployAuth({ address: owner, sym: 'STABLE', dec: 6 })
|
|
186
|
+
B.buildAuth({ address: minter, id: deployTxid + '_0' }) // delegate mint authority
|
|
187
|
+
B.buildMint({ address: holder, id: deployTxid + '_0', amt: '1000000' })
|
|
188
|
+
B.buildBurn({ address: holder, id: deployTxid + '_0', amt: '400' })
|
|
189
|
+
|
|
183
190
|
// 1-sat outputs and parsing.
|
|
184
191
|
var out = B.createMintOutput({ address: owner, tick: 'ORDI', amt: '1' })
|
|
185
192
|
B.isBsv20(out.script) // true
|
|
@@ -201,10 +208,12 @@ it — so a stray object can no longer be written as the literal text `[object O
|
|
|
201
208
|
**`parseBsv20` / `isBsv20` enforce validity rather than assuming it.** The operation must be
|
|
202
209
|
one the spec defines and must carry the fields that operation requires — a `transfer` with no
|
|
203
210
|
amount and no token, an `auth` carrying `amt` (which the spec forbids), an over-uint64 amount,
|
|
204
|
-
or an unknown `op` all return `null`.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
211
|
+
or an unknown `op` all return `null`. Every operation the spec defines is both built and
|
|
212
|
+
read. Non-canonical amounts (leading zeros) are tolerated when reading other people's
|
|
213
|
+
payloads, though our builders always emit canonical ones.
|
|
214
|
+
|
|
215
|
+
An operation names its token by `tick` (v1) **or** `id` (BSV-21), never both — passing both
|
|
216
|
+
throws rather than silently picking one, since they are different tokens.
|
|
208
217
|
|
|
209
218
|
Balance tracking is an indexer concern — this module builds and reads the on-chain payloads.
|
|
210
219
|
|
|
@@ -222,5 +231,6 @@ Balance tracking is an indexer concern — this module builds and reads the on-c
|
|
|
222
231
|
| `payOutputFor` | build a P2PKH payment output |
|
|
223
232
|
| `ORDLOCK_SIGHASH` | `SIGHASH_ALL\|ANYONECANPAY\|FORKID` (0xc1) |
|
|
224
233
|
| `BSV20.buildDeploy` / `buildMint` / `buildTransfer` / `buildDeployMint` | build BSV-20/21 token inscriptions |
|
|
234
|
+
| `BSV20.buildDeployAuth` / `buildAuth` / `buildBurn` | BSV-21 authority model: deploy without supply, delegate mint rights, burn |
|
|
225
235
|
| `BSV20.create*Output` | 1-sat token outputs |
|
|
226
236
|
| `BSV20.parseBsv20`, `BSV20.isBsv20` | read a token payload back |
|
package/lib/ordinals/bsv20.js
CHANGED
|
@@ -143,9 +143,38 @@ function buildDeploy (params) {
|
|
|
143
143
|
* @param {object} params { tick, amt, address|lock, contentType? }
|
|
144
144
|
* @returns {Script}
|
|
145
145
|
*/
|
|
146
|
+
/**
|
|
147
|
+
* Name the token an operation acts on: `tick` (v1) or `id` (BSV-21), never both.
|
|
148
|
+
* Passing both used to silently drop the `tick`, which is the wrong token, not a preference.
|
|
149
|
+
*/
|
|
150
|
+
function assignToken (p, params, op) {
|
|
151
|
+
var hasTick = params.tick != null
|
|
152
|
+
var hasId = params.id != null
|
|
153
|
+
if (hasTick && hasId) {
|
|
154
|
+
throw new Error(op + ' names a token by `tick` (v1) or `id` (BSV-21), not both')
|
|
155
|
+
}
|
|
156
|
+
if (!hasTick && !hasId) {
|
|
157
|
+
throw new Error(op + ' requires `tick` (v1) or `id` (BSV-21)')
|
|
158
|
+
}
|
|
159
|
+
if (hasId) p.id = assertId(params.id)
|
|
160
|
+
else p.tick = assertTick(params.tick)
|
|
161
|
+
return p
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Reject `amt` on the operations the spec says must not carry one. */
|
|
165
|
+
function assertNoAmt (params, op) {
|
|
166
|
+
if (params.amt != null) {
|
|
167
|
+
throw new Error(op + ' must not carry an amt — the specification forbids it, and a ' +
|
|
168
|
+
'payload that does is discarded')
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
146
172
|
function buildMint (params) {
|
|
147
173
|
params = params || {}
|
|
148
|
-
|
|
174
|
+
// `{p, op, tick|id, amt}` — the token first, then the amount.
|
|
175
|
+
var p = { p: 'bsv-20', op: 'mint' }
|
|
176
|
+
assignToken(p, params, 'mint')
|
|
177
|
+
p.amt = normPositive(params.amt, 'amt')
|
|
149
178
|
return buildBsv20(p, params)
|
|
150
179
|
}
|
|
151
180
|
|
|
@@ -157,8 +186,63 @@ function buildMint (params) {
|
|
|
157
186
|
function buildTransfer (params) {
|
|
158
187
|
params = params || {}
|
|
159
188
|
var p = { p: 'bsv-20', op: 'transfer', amt: normPositive(params.amt, 'amt') }
|
|
160
|
-
|
|
161
|
-
|
|
189
|
+
assignToken(p, params, 'transfer')
|
|
190
|
+
return buildBsv20(p, params)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Burn an amount of a BSV-21 token: `{p, op:'burn', id, amt}`.
|
|
195
|
+
*
|
|
196
|
+
* BSV-21 (id-based) only — the specification defines `burn` under BSV-21, so there is no
|
|
197
|
+
* ticker form. To retire v1 supply, transfer it to an unspendable output instead.
|
|
198
|
+
*
|
|
199
|
+
* @param {object} params { id, amt, address|lock, contentType? }
|
|
200
|
+
* @returns {Script}
|
|
201
|
+
*/
|
|
202
|
+
function buildBurn (params) {
|
|
203
|
+
params = params || {}
|
|
204
|
+
if (params.tick != null) {
|
|
205
|
+
throw new Error('burn is a BSV-21 operation and names its token by `id` (<txid>_<vout>), ' +
|
|
206
|
+
'not `tick`')
|
|
207
|
+
}
|
|
208
|
+
var p = { p: 'bsv-20', op: 'burn', id: assertId(params.id), amt: normPositive(params.amt, 'amt') }
|
|
209
|
+
return buildBsv20(p, params)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Deploy a BSV-21 token under an AUTHORITY rather than a fixed supply:
|
|
214
|
+
* `{p, op:'deploy+auth', sym?, dec?, icon?}`.
|
|
215
|
+
*
|
|
216
|
+
* Unlike `deploy+mint`, no supply is created here — minting happens later via `buildMint`
|
|
217
|
+
* against this deploy's outpoint, and requires an auth input. The spec is explicit that
|
|
218
|
+
* `amt` must NOT be present.
|
|
219
|
+
*
|
|
220
|
+
* @param {object} params { sym?, dec?, icon?, address|lock, contentType? }
|
|
221
|
+
* @returns {Script}
|
|
222
|
+
*/
|
|
223
|
+
function buildDeployAuth (params) {
|
|
224
|
+
params = params || {}
|
|
225
|
+
assertNoAmt(params, 'deploy+auth')
|
|
226
|
+
var p = { p: 'bsv-20', op: 'deploy+auth' }
|
|
227
|
+
if (params.dec != null) p.dec = normDec(params.dec)
|
|
228
|
+
if (params.sym != null) p.sym = assertText(params.sym, 'sym')
|
|
229
|
+
if (params.icon != null) p.icon = assertIcon(params.icon)
|
|
230
|
+
return buildBsv20(p, params)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Mint authority for a BSV-21 token: `{p, op:'auth', id}`.
|
|
235
|
+
*
|
|
236
|
+
* The output this locks carries the right to mint the token, and "can be split, combined,
|
|
237
|
+
* or transferred to delegate minting authority". It carries no amount — `amt` is forbidden.
|
|
238
|
+
*
|
|
239
|
+
* @param {object} params { id, address|lock, contentType? }
|
|
240
|
+
* @returns {Script}
|
|
241
|
+
*/
|
|
242
|
+
function buildAuth (params) {
|
|
243
|
+
params = params || {}
|
|
244
|
+
assertNoAmt(params, 'auth')
|
|
245
|
+
var p = { p: 'bsv-20', op: 'auth', id: assertId(params.id) }
|
|
162
246
|
return buildBsv20(p, params)
|
|
163
247
|
}
|
|
164
248
|
|
|
@@ -186,6 +270,9 @@ function createDeployOutput (params) { return outputFor(buildDeploy(params), par
|
|
|
186
270
|
function createMintOutput (params) { return outputFor(buildMint(params), params && params.satoshis) }
|
|
187
271
|
function createTransferOutput (params) { return outputFor(buildTransfer(params), params && params.satoshis) }
|
|
188
272
|
function createDeployMintOutput (params) { return outputFor(buildDeployMint(params), params && params.satoshis) }
|
|
273
|
+
function createBurnOutput (params) { return outputFor(buildBurn(params), params && params.satoshis) }
|
|
274
|
+
function createDeployAuthOutput (params) { return outputFor(buildDeployAuth(params), params && params.satoshis) }
|
|
275
|
+
function createAuthOutput (params) { return outputFor(buildAuth(params), params && params.satoshis) }
|
|
189
276
|
|
|
190
277
|
/** Extract the JSON body from a locking script, a JSON string, a Buffer, or an object. */
|
|
191
278
|
function bodyOf (input) {
|
|
@@ -283,10 +370,16 @@ module.exports = {
|
|
|
283
370
|
buildMint: buildMint,
|
|
284
371
|
buildTransfer: buildTransfer,
|
|
285
372
|
buildDeployMint: buildDeployMint,
|
|
373
|
+
buildBurn: buildBurn,
|
|
374
|
+
buildDeployAuth: buildDeployAuth,
|
|
375
|
+
buildAuth: buildAuth,
|
|
286
376
|
createDeployOutput: createDeployOutput,
|
|
287
377
|
createMintOutput: createMintOutput,
|
|
288
378
|
createTransferOutput: createTransferOutput,
|
|
289
379
|
createDeployMintOutput: createDeployMintOutput,
|
|
380
|
+
createBurnOutput: createBurnOutput,
|
|
381
|
+
createDeployAuthOutput: createDeployAuthOutput,
|
|
382
|
+
createAuthOutput: createAuthOutput,
|
|
290
383
|
parseBsv20: parseBsv20,
|
|
291
384
|
isBsv20: isBsv20
|
|
292
385
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartledger/bsv",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"description": "🚀 Complete Bitcoin SV development framework with legally-recognizable DID:web + W3C VC-JWT toolkit, Legal Token Protocol (LTP), Global Digital Attestation Framework (GDAF), StatusList2021 revocation, and 16 flexible loading options. Standards-based credentials with ES256/ES256K support, on-chain BSV anchoring, and comprehensive Bitcoin SV API. Perfect for legal tokens, verifiable credentials, DeFi, smart contracts, and secure Bitcoin applications.",
|
|
5
5
|
"author": "SmartLedger Technology <hello@smartledger.technology> (https://smartledger.technology)",
|
|
6
6
|
"homepage": "https://github.com/codenlighten/smartledger-bsv#readme",
|
package/test/ordinals/bsv20.js
CHANGED
|
@@ -216,7 +216,122 @@ describe('Ordinals BSV-20 fungible tokens', function () {
|
|
|
216
216
|
B.isBsv20(B.buildMint({ address: address, tick: 'ORDI', amt: '1' })).should.equal(true)
|
|
217
217
|
B.isBsv20(B.buildTransfer({ address: address, id: OUTPOINT, amt: '1' })).should.equal(true)
|
|
218
218
|
B.isBsv20(B.buildDeployMint({ address: address, amt: '1000' })).should.equal(true)
|
|
219
|
+
B.isBsv20(B.buildBurn({ address: address, id: OUTPOINT, amt: '1' })).should.equal(true)
|
|
220
|
+
B.isBsv20(B.buildAuth({ address: address, id: OUTPOINT })).should.equal(true)
|
|
221
|
+
B.isBsv20(B.buildDeployAuth({ address: address, sym: 'STABLE' })).should.equal(true)
|
|
219
222
|
})
|
|
220
223
|
})
|
|
221
224
|
})
|
|
225
|
+
|
|
226
|
+
// BSV-21 authority model: deploy+auth creates no supply, an auth output carries the right
|
|
227
|
+
// to mint, and mint names its token by `id`. Previously only the fixed-supply deploy+mint
|
|
228
|
+
// path could be built, so these operations could be read but never written.
|
|
229
|
+
describe('BSV-21 authority operations', function () {
|
|
230
|
+
var OUTPOINT = '3b31'.repeat(16) + '_0'
|
|
231
|
+
|
|
232
|
+
it('mints by id, which requires an auth input on chain', function () {
|
|
233
|
+
var p = B.parseBsv20(B.buildMint({ address: address, id: OUTPOINT, amt: '1000000' }))
|
|
234
|
+
p.op.should.equal('mint')
|
|
235
|
+
p.id.should.equal(OUTPOINT)
|
|
236
|
+
p.amt.should.equal('1000000')
|
|
237
|
+
;(p.tick === undefined).should.equal(true)
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
it('leaves the v1 ticker mint byte-for-byte unchanged', function () {
|
|
241
|
+
var p = B.parseBsv20(B.buildMint({ address: address, tick: 'ORDI', amt: '1000' }))
|
|
242
|
+
JSON.stringify(p).should.equal('{"p":"bsv-20","op":"mint","tick":"ORDI","amt":"1000"}')
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
it('refuses to guess which token an operation means', function () {
|
|
246
|
+
// Naming both used to silently drop the tick — a different token, not a preference.
|
|
247
|
+
(function () {
|
|
248
|
+
B.buildMint({ address: address, tick: 'ORDI', id: OUTPOINT, amt: '1' })
|
|
249
|
+
}).should.throw(/not both/)
|
|
250
|
+
;(function () {
|
|
251
|
+
B.buildTransfer({ address: address, tick: 'ORDI', id: OUTPOINT, amt: '1' })
|
|
252
|
+
}).should.throw(/not both/)
|
|
253
|
+
;(function () {
|
|
254
|
+
B.buildMint({ address: address, amt: '1' })
|
|
255
|
+
}).should.throw(/requires `tick` \(v1\) or `id`/)
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
it('builds a burn', function () {
|
|
259
|
+
var p = B.parseBsv20(B.buildBurn({ address: address, id: OUTPOINT, amt: '5' }))
|
|
260
|
+
p.op.should.equal('burn')
|
|
261
|
+
p.id.should.equal(OUTPOINT)
|
|
262
|
+
p.amt.should.equal('5')
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
it('rejects a ticker burn, which the spec does not define', function () {
|
|
266
|
+
(function () {
|
|
267
|
+
B.buildBurn({ address: address, tick: 'ORDI', amt: '5' })
|
|
268
|
+
}).should.throw(/BSV-21 operation/)
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
it('builds deploy+auth with no supply', function () {
|
|
272
|
+
var p = B.parseBsv20(B.buildDeployAuth({ address: address, sym: 'STABLE', dec: 6 }))
|
|
273
|
+
p.op.should.equal('deploy+auth')
|
|
274
|
+
p.sym.should.equal('STABLE')
|
|
275
|
+
p.dec.should.equal('6')
|
|
276
|
+
;(p.amt === undefined).should.equal(true)
|
|
277
|
+
// Every field is optional.
|
|
278
|
+
B.parseBsv20(B.buildDeployAuth({ address: address })).op.should.equal('deploy+auth')
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
it('builds an auth output carrying no amount', function () {
|
|
282
|
+
var p = B.parseBsv20(B.buildAuth({ address: address, id: OUTPOINT }))
|
|
283
|
+
p.op.should.equal('auth')
|
|
284
|
+
p.id.should.equal(OUTPOINT)
|
|
285
|
+
;(p.amt === undefined).should.equal(true)
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
it('refuses to attach an amt where the spec forbids one', function () {
|
|
289
|
+
(function () {
|
|
290
|
+
B.buildAuth({ address: address, id: OUTPOINT, amt: '1' })
|
|
291
|
+
}).should.throw(/must not carry an amt/)
|
|
292
|
+
;(function () {
|
|
293
|
+
B.buildDeployAuth({ address: address, sym: 'X', amt: '1' })
|
|
294
|
+
}).should.throw(/must not carry an amt/)
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
it('applies the same amount rules as the other operations', function () {
|
|
298
|
+
(function () {
|
|
299
|
+
B.buildBurn({ address: address, id: OUTPOINT, amt: '0' })
|
|
300
|
+
}).should.throw(/greater than zero/)
|
|
301
|
+
;(function () {
|
|
302
|
+
B.buildBurn({ address: address, id: OUTPOINT, amt: '9'.repeat(26) })
|
|
303
|
+
}).should.throw(/exceeds the uint64 maximum/)
|
|
304
|
+
;(function () {
|
|
305
|
+
B.buildMint({ address: address, id: 'notanid', amt: '1' })
|
|
306
|
+
}).should.throw(/<txid>/)
|
|
307
|
+
;(function () {
|
|
308
|
+
B.buildDeployAuth({ address: address, sym: {} })
|
|
309
|
+
}).should.throw(/sym must be a string/)
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
it('builds 1-sat outputs for each new operation', function () {
|
|
313
|
+
var outs = [
|
|
314
|
+
B.createBurnOutput({ address: address, id: OUTPOINT, amt: '5' }),
|
|
315
|
+
B.createAuthOutput({ address: address, id: OUTPOINT }),
|
|
316
|
+
B.createDeployAuthOutput({ address: address, sym: 'STABLE' })
|
|
317
|
+
]
|
|
318
|
+
outs.forEach(function (o) {
|
|
319
|
+
o.satoshis.should.equal(1)
|
|
320
|
+
B.isBsv20(o.script).should.equal(true)
|
|
321
|
+
})
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
it('round-trips a full authority lifecycle', function () {
|
|
325
|
+
// deploy+auth -> auth output delegating mint rights -> mint by id -> burn.
|
|
326
|
+
var deploy = B.parseBsv20(B.buildDeployAuth({ address: address, sym: 'GOLD', dec: 8 }))
|
|
327
|
+
var auth = B.parseBsv20(B.buildAuth({ address: address, id: OUTPOINT }))
|
|
328
|
+
var mint = B.parseBsv20(B.buildMint({ address: address, id: OUTPOINT, amt: '1000' }))
|
|
329
|
+
var burn = B.parseBsv20(B.buildBurn({ address: address, id: OUTPOINT, amt: '400' }))
|
|
330
|
+
deploy.op.should.equal('deploy+auth')
|
|
331
|
+
auth.op.should.equal('auth')
|
|
332
|
+
mint.amt.should.equal('1000')
|
|
333
|
+
burn.amt.should.equal('400')
|
|
334
|
+
;[deploy, auth, mint, burn].forEach(function (p) { p.p.should.equal('bsv-20') })
|
|
335
|
+
})
|
|
336
|
+
})
|
|
222
337
|
})
|
package/version.js
CHANGED