@smartledger/bsv 7.1.0 → 7.2.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 +87 -0
- package/README.md +38 -38
- package/bsv-gdaf.min.js +27 -27
- package/bsv-ltp.min.js +27 -27
- package/bsv-smartcontract.min.js +1 -1
- package/bsv.bundle.js +27 -27
- package/bsv.d.ts +17 -1
- package/bsv.min.js +27 -27
- 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 +24 -1
- package/lib/ordinals/inscription.js +113 -23
- package/lib/ordinals/ordlock.js +1 -0
- package/package.json +1 -1
- package/test/ordinals/inscription.js +154 -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.2.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.2.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.2.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.2.0/bsv.min.js` |
|
|
85
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.2.0/bsv.bundle.js` |
|
|
86
|
+
| **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.2.0/bsv-smartcontract.min.js` |
|
|
87
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.2.0/bsv-covenant.min.js` |
|
|
88
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.2.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.2.0/bsv-security.min.js` |
|
|
90
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.2.0/bsv-ecies.min.js` |
|
|
91
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.2.0/bsv-message.min.js` |
|
|
92
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.2.0/bsv-mnemonic.min.js` |
|
|
93
|
+
| **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.2.0/bsv-shamir.min.js` |
|
|
94
|
+
| **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.2.0/bsv-gdaf.min.js` |
|
|
95
|
+
| **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.2.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.2.0/bsv.min.js"></script>
|
|
104
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.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.2.0/bsv.min.js"></script>
|
|
110
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-covenant.min.js"></script>
|
|
111
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.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.2.0/bsv.min.js"></script>
|
|
117
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-ltp.min.js"></script>
|
|
118
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.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.2.0/bsv.min.js"></script>
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-security.min.js"></script>
|
|
137
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.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.2.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.2.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.2.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.2.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.2.0/bsv.min.js"></script>
|
|
75
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-covenant.min.js"></script>
|
|
76
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.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.2.0/bsv.min.js"></script>
|
|
86
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-ltp.min.js"></script>
|
|
87
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.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.2.0/bsv.min.js"></script>
|
|
102
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-security.min.js"></script>
|
|
103
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.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.2.0/bsv.min.js` |
|
|
118
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.2.0/bsv.bundle.js` |
|
|
119
|
+
| **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.2.0/bsv-smartcontract.min.js` |
|
|
120
|
+
| **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.2.0/bsv-ltp.min.js` |
|
|
121
|
+
| **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.2.0/bsv-gdaf.min.js` |
|
|
122
|
+
| **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.2.0/bsv-shamir.min.js` |
|
|
123
|
+
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.2.0/bsv-security.min.js` |
|
|
124
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.2.0/bsv-mnemonic.min.js` |
|
|
125
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.2.0/bsv-ecies.min.js` |
|
|
126
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.2.0/bsv-covenant.min.js` |
|
|
127
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.2.0/bsv-script-helper.min.js` |
|
|
128
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.2.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.2.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.2.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.2.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.2.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.2.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.2.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.2.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.2.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.2.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.2.0/bsv-ltp.min.js"></script>
|
|
169
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.2.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.2.0/bsv.bundle.js"></script>
|
|
173
173
|
```
|
|
174
174
|
|
|
175
175
|
## 🔍 **Testing Your Migration**
|
package/lib/ordinals/README.md
CHANGED
|
@@ -29,7 +29,8 @@ var script = Ord.buildInscription({
|
|
|
29
29
|
})
|
|
30
30
|
var output = Ord.createInscriptionOutput({ address: ownerAddress, contentType: 'image/png', content: pngBuffer })
|
|
31
31
|
|
|
32
|
-
// Parse it back.
|
|
32
|
+
// Parse it back. `lock` is the whole script minus the envelope: the 1Sat spec allows the
|
|
33
|
+
// locking script to be prepended OR appended, and both are recovered.
|
|
33
34
|
var insc = Ord.parseInscription(script) // { contentType, content, contentText, lock }
|
|
34
35
|
Ord.isInscription(script) // true
|
|
35
36
|
|
|
@@ -40,6 +41,28 @@ var outs = Ord.batchInscriptionOutputs([
|
|
|
40
41
|
])
|
|
41
42
|
```
|
|
42
43
|
|
|
44
|
+
### Arguments are checked, because an inscription is permanent
|
|
45
|
+
|
|
46
|
+
`content` may be any data — a string or a `Buffer` of arbitrary bytes, under any MIME
|
|
47
|
+
type. What the builder will not do is guess, because every guess it used to make wrote
|
|
48
|
+
something other than what the caller asked for onto a permanent record:
|
|
49
|
+
|
|
50
|
+
| Call | Before | Now |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| `content` omitted | built a valid-looking script inscribing **nothing** | throws, and names the field you passed instead (`data`, `body`, `payload`, …) |
|
|
53
|
+
| `content: {…}` or a number | inscribed `[object Object]` / `"42"` | throws; encode it yourself (`JSON.stringify`, `Buffer.from`) |
|
|
54
|
+
| `Buffer` content, no `contentType` | labelled it `text/plain` | throws — bytes carry no hint about what they are |
|
|
55
|
+
| empty `lock` | emitted an **anyone-can-spend** ordinal | throws unless you pass `allowEmptyLock: true` |
|
|
56
|
+
| both `lock` and `address` | silently used `lock` | throws — they name different owners |
|
|
57
|
+
| `satoshis: 0` | built a 0-sat output carrying no ordinal | throws; must be a positive integer |
|
|
58
|
+
|
|
59
|
+
Deliberate cases are still expressible: pass `content: ''` for an empty payload, and
|
|
60
|
+
`allowEmptyLock: true` when you are appending the envelope to a lock you supply yourself
|
|
61
|
+
(this is how the OrdLock listing carries its inline inscription).
|
|
62
|
+
|
|
63
|
+
The default `contentType` of `text/plain` still applies to **string** content, which is
|
|
64
|
+
the common case and is truthfully described by it.
|
|
65
|
+
|
|
43
66
|
## Marketplace: the OrdLock covenant
|
|
44
67
|
|
|
45
68
|
A listing locks the 1-sat ordinal behind a script with two spend paths:
|
|
@@ -23,47 +23,118 @@ var ORD = Buffer.from('ord', 'utf8')
|
|
|
23
23
|
function scriptClass () { return bsv.Script }
|
|
24
24
|
function op () { return bsv.Opcode }
|
|
25
25
|
|
|
26
|
+
/** Describe a rejected value for an error message, without dumping its contents. */
|
|
27
|
+
function typeName (v) {
|
|
28
|
+
if (v === null) return 'null'
|
|
29
|
+
if (v === undefined) return 'undefined'
|
|
30
|
+
if (Array.isArray(v)) return 'an array'
|
|
31
|
+
var t = typeof v
|
|
32
|
+
return (t === 'object' ? 'an ' : 'a ') + t
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Coerce a caller-supplied field to bytes.
|
|
37
|
+
*
|
|
38
|
+
* Only strings and Buffers are accepted. Everything else is rejected rather than run
|
|
39
|
+
* through `String(v)`: an inscription is permanent, and stringifying an object writes
|
|
40
|
+
* the literal text `[object Object]` to the chain, which is never what the caller meant.
|
|
41
|
+
*/
|
|
42
|
+
function toBuf (v, name) {
|
|
43
|
+
if (Buffer.isBuffer(v)) return v
|
|
44
|
+
if (typeof v === 'string') return Buffer.from(v, 'utf8')
|
|
45
|
+
throw new Error(name + ' must be a string or Buffer, got ' + typeName(v))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Fields callers reach for when they mean `content`; named back to them on error. */
|
|
49
|
+
var CONTENT_ALIASES = ['data', 'body', 'payload', 'text', 'message']
|
|
50
|
+
|
|
26
51
|
/** Resolve a base locking script from a Script, an Address, or an address string. */
|
|
27
52
|
function resolveLock (params) {
|
|
28
53
|
var Script = scriptClass()
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
54
|
+
var hasLock = params.lock != null
|
|
55
|
+
var hasAddress = params.address != null
|
|
56
|
+
|
|
57
|
+
// `lock` used to win silently. Two different owners in one call is a mistake worth
|
|
58
|
+
// surfacing, not resolving by precedence.
|
|
59
|
+
if (hasLock && hasAddress) {
|
|
60
|
+
throw new Error('buildInscription accepts `lock` or `address`, not both — they name ' +
|
|
61
|
+
'different owners and one would be silently ignored')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (hasLock) {
|
|
65
|
+
var lock
|
|
66
|
+
if (params.lock instanceof Script) lock = params.lock
|
|
67
|
+
else if (Buffer.isBuffer(params.lock)) lock = Script.fromBuffer(params.lock)
|
|
68
|
+
else if (typeof params.lock === 'string') lock = Script.fromHex(params.lock)
|
|
69
|
+
else throw new Error('lock must be a Script, Buffer, or hex string, got ' + typeName(params.lock))
|
|
70
|
+
|
|
71
|
+
// An empty base lock leaves nothing but the inert envelope, and the envelope is
|
|
72
|
+
// skipped at execution — so whatever the spender pushes is the final stack and the
|
|
73
|
+
// ordinal is anyone-can-spend. Only a caller appending the envelope to a lock it
|
|
74
|
+
// supplies itself (as ordlock.js does) legitimately wants this.
|
|
75
|
+
if (!lock.chunks.length && !params.allowEmptyLock) {
|
|
76
|
+
throw new Error('lock is empty: the inscription would carry no locking script at ' +
|
|
77
|
+
'all and the ordinal would be spendable by anyone. Pass a real lock, or ' +
|
|
78
|
+
'{ allowEmptyLock: true } if you are appending this envelope to your own script')
|
|
79
|
+
}
|
|
80
|
+
return lock
|
|
34
81
|
}
|
|
35
|
-
|
|
82
|
+
|
|
83
|
+
if (hasAddress) {
|
|
36
84
|
var addr = (params.address instanceof bsv.Address)
|
|
37
85
|
? params.address
|
|
38
86
|
: bsv.Address.fromString(String(params.address))
|
|
39
87
|
return Script.buildPublicKeyHashOut(addr)
|
|
40
88
|
}
|
|
41
|
-
throw new Error('buildInscription requires an address or a lock script')
|
|
42
|
-
}
|
|
43
89
|
|
|
44
|
-
|
|
45
|
-
if (Buffer.isBuffer(v)) return v
|
|
46
|
-
if (v == null) return Buffer.alloc(0)
|
|
47
|
-
return Buffer.from(String(v), enc || 'utf8')
|
|
90
|
+
throw new Error('buildInscription requires an address or a lock script')
|
|
48
91
|
}
|
|
49
92
|
|
|
50
93
|
/**
|
|
51
94
|
* Build a 1Sat Ordinals inscription locking script: a base lock followed by the
|
|
52
95
|
* inert `OP_FALSE OP_IF ... OP_ENDIF` envelope carrying the content.
|
|
53
96
|
*
|
|
97
|
+
* `content` is required. An inscription with no body is a well-formed script that
|
|
98
|
+
* inscribes nothing, so omitting it throws rather than silently producing one; pass an
|
|
99
|
+
* explicit `''` if an empty payload is genuinely what you want.
|
|
100
|
+
*
|
|
54
101
|
* @param {object} params
|
|
55
|
-
* @param {string|Buffer} params.
|
|
56
|
-
* @param {string|Buffer} params.
|
|
57
|
-
*
|
|
58
|
-
*
|
|
102
|
+
* @param {string|Buffer} params.content the inscription body (required)
|
|
103
|
+
* @param {string|Buffer} [params.contentType] e.g. 'text/plain', 'image/png'.
|
|
104
|
+
* Defaults to 'text/plain' for string content; required for Buffer content, which
|
|
105
|
+
* carries no hint about what it is.
|
|
106
|
+
* @param {Script|Buffer|string} [params.lock] base locking script (mutually exclusive
|
|
107
|
+
* with `address`)
|
|
108
|
+
* @param {Address|string} [params.address] P2PKH owner (mutually exclusive with `lock`)
|
|
109
|
+
* @param {boolean} [params.allowEmptyLock] permit an empty base lock; see resolveLock
|
|
59
110
|
* @returns {Script} the full inscription locking script
|
|
60
111
|
*/
|
|
61
112
|
function buildInscription (params) {
|
|
62
113
|
params = params || {}
|
|
63
114
|
var Opcode = op()
|
|
64
115
|
var lock = resolveLock(params)
|
|
65
|
-
|
|
66
|
-
|
|
116
|
+
|
|
117
|
+
if (params.content == null) {
|
|
118
|
+
var alias = CONTENT_ALIASES.filter(function (k) { return params[k] != null })[0]
|
|
119
|
+
throw new Error('buildInscription requires `content`' +
|
|
120
|
+
(alias ? ' — received `' + alias + '`, which is not read' : '') +
|
|
121
|
+
'. Omitting it would inscribe an empty payload; pass content: \'\' if that is intended')
|
|
122
|
+
}
|
|
123
|
+
var content = toBuf(params.content, 'content')
|
|
124
|
+
|
|
125
|
+
var contentType
|
|
126
|
+
if (params.contentType == null) {
|
|
127
|
+
// A Buffer is opaque — defaulting it to text/plain mislabels binary content on a
|
|
128
|
+
// permanent record, so make the caller declare it.
|
|
129
|
+
if (Buffer.isBuffer(params.content)) {
|
|
130
|
+
throw new Error('contentType is required when content is a Buffer (e.g. ' +
|
|
131
|
+
"'image/png', 'application/octet-stream') — it cannot be inferred from bytes")
|
|
132
|
+
}
|
|
133
|
+
contentType = Buffer.from('text/plain', 'utf8')
|
|
134
|
+
} else {
|
|
135
|
+
contentType = toBuf(params.contentType, 'contentType')
|
|
136
|
+
if (!contentType.length) throw new Error('contentType must not be empty')
|
|
137
|
+
}
|
|
67
138
|
|
|
68
139
|
// Clone the base lock so we never mutate the caller's Script.
|
|
69
140
|
var s = scriptClass().fromBuffer(lock.toBuffer())
|
|
@@ -84,6 +155,14 @@ function chunkIsOp (chunk, opcodenum) {
|
|
|
84
155
|
|
|
85
156
|
/**
|
|
86
157
|
* Parse a 1Sat Ordinals inscription out of a locking script.
|
|
158
|
+
*
|
|
159
|
+
* The 1Sat spec allows the locking script to be *prepended or appended* to the
|
|
160
|
+
* envelope ("A locking script (typically P2PKH) is then prepended/appended to the
|
|
161
|
+
* inscription script, optionally separated by OP_CODESEPARATOR"). `lock` is therefore
|
|
162
|
+
* the whole script minus the envelope, in script order — not merely what precedes it.
|
|
163
|
+
* A separating OP_CODESEPARATOR is kept, because it is genuinely part of the script
|
|
164
|
+
* that runs and affects the sighash.
|
|
165
|
+
*
|
|
87
166
|
* @param {Script|Buffer|string} script
|
|
88
167
|
* @returns {null|{ contentType: string, content: Buffer, contentText: string, lock: Script }}
|
|
89
168
|
* null if the script carries no inscription envelope.
|
|
@@ -108,16 +187,13 @@ function parseInscription (script) {
|
|
|
108
187
|
}
|
|
109
188
|
if (start === -1) return null
|
|
110
189
|
|
|
111
|
-
// Everything before the envelope is the base lock.
|
|
112
|
-
var lock = new Script()
|
|
113
|
-
for (var k = 0; k < start; k++) lock.chunks.push(chunks[k])
|
|
114
|
-
|
|
115
190
|
// Walk fields after "ord" until OP_ENDIF: OP_1 => content-type, OP_0 => body.
|
|
116
191
|
var contentType = Buffer.alloc(0)
|
|
117
192
|
var content = Buffer.alloc(0)
|
|
193
|
+
var end = chunks.length // index of OP_ENDIF, or past the end if the envelope is unterminated
|
|
118
194
|
for (var j = start + 3; j < chunks.length; j++) {
|
|
119
195
|
var c = chunks[j]
|
|
120
|
-
if (chunkIsOp(c, Opcode.OP_ENDIF)) break
|
|
196
|
+
if (chunkIsOp(c, Opcode.OP_ENDIF)) { end = j; break }
|
|
121
197
|
if (chunkIsOp(c, Opcode.OP_1) && chunks[j + 1] && chunks[j + 1].buf) {
|
|
122
198
|
contentType = chunks[j + 1].buf; j++
|
|
123
199
|
} else if (chunkIsOp(c, Opcode.OP_0) && chunks[j + 1] && chunks[j + 1].buf) {
|
|
@@ -125,6 +201,13 @@ function parseInscription (script) {
|
|
|
125
201
|
}
|
|
126
202
|
}
|
|
127
203
|
|
|
204
|
+
// The lock is everything outside the envelope. Taking only what precedes it dropped
|
|
205
|
+
// the lock entirely for the spec-legal appended form, reporting an owned ordinal as
|
|
206
|
+
// having no locking script at all.
|
|
207
|
+
var lock = new Script()
|
|
208
|
+
for (var k = 0; k < start; k++) lock.chunks.push(chunks[k])
|
|
209
|
+
for (var m = end + 1; m < chunks.length; m++) lock.chunks.push(chunks[m])
|
|
210
|
+
|
|
128
211
|
return {
|
|
129
212
|
contentType: contentType.toString('utf8'),
|
|
130
213
|
content: content,
|
|
@@ -140,11 +223,18 @@ function isInscription (script) {
|
|
|
140
223
|
|
|
141
224
|
/**
|
|
142
225
|
* Build the 1-satoshi Transaction.Output carrying an inscription.
|
|
226
|
+
* @param {object} params as buildInscription, plus:
|
|
227
|
+
* @param {number} [params.satoshis] defaults to 1 (the 1Sat Ordinals convention)
|
|
143
228
|
* @returns {Transaction.Output}
|
|
144
229
|
*/
|
|
145
230
|
function createInscriptionOutput (params) {
|
|
146
231
|
params = params || {}
|
|
147
232
|
var satoshis = params.satoshis != null ? params.satoshis : 1
|
|
233
|
+
// Output rejects negatives and fractions, but 0 and the string '1' slipped through:
|
|
234
|
+
// a 0-sat output carries no ordinal at all.
|
|
235
|
+
if (typeof satoshis !== 'number' || !Number.isInteger(satoshis) || satoshis < 1) {
|
|
236
|
+
throw new Error('satoshis must be a positive integer (1 for a standard 1Sat ordinal)')
|
|
237
|
+
}
|
|
148
238
|
return new bsv.Transaction.Output({
|
|
149
239
|
script: buildInscription(params),
|
|
150
240
|
satoshis: satoshis
|
package/lib/ordinals/ordlock.js
CHANGED
|
@@ -182,6 +182,7 @@ function buildOrdLock (params) {
|
|
|
182
182
|
if (params.inscription) {
|
|
183
183
|
var env = inscription.buildInscription({
|
|
184
184
|
lock: new Script(), // envelope only; the covenant above is the real lock
|
|
185
|
+
allowEmptyLock: true, // ...which is why the empty-lock guard does not apply here
|
|
185
186
|
contentType: params.inscription.contentType,
|
|
186
187
|
content: params.inscription.content
|
|
187
188
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartledger/bsv",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.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",
|