@smartledger/bsv 7.2.0 → 7.3.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.
@@ -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.2.0/bsv-shamir.min.js`
58
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.3.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.2.0/bsv-gdaf.min.js`
64
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.3.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.2.0/bsv-ltp.min.js`
70
+ - **CDN**: `unpkg.com/@smartledger/bsv@7.3.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.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` |
84
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.3.0/bsv.min.js` |
85
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.3.0/bsv.bundle.js` |
86
+ | **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.3.0/bsv-smartcontract.min.js` |
87
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.3.0/bsv-covenant.min.js` |
88
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.3.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.3.0/bsv-security.min.js` |
90
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.3.0/bsv-ecies.min.js` |
91
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.3.0/bsv-message.min.js` |
92
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.3.0/bsv-mnemonic.min.js` |
93
+ | **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.3.0/bsv-shamir.min.js` |
94
+ | **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.3.0/bsv-gdaf.min.js` |
95
+ | **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.3.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.2.0/bsv.min.js"></script>
104
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-script-helper.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv.min.js"></script>
104
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.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.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>
109
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv.min.js"></script>
110
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv-covenant.min.js"></script>
111
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.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.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>
116
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv.min.js"></script>
117
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv-ltp.min.js"></script>
118
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.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.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>
135
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv-security.min.js"></script>
137
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.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.2.0/bsv.bundle.js"></script>
149
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.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.2.0/bsv.min.js"></script>
725
+ <script src="https://cdn.jsdelivr.net/npm/@smartledger/bsv@7.3.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.2.0/bsv.min.js"></script>
51
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.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.2.0/bsv.bundle.js"></script>
61
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.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.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>
74
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv.min.js"></script>
75
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv-covenant.min.js"></script>
76
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.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.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>
85
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv.min.js"></script>
86
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv-ltp.min.js"></script>
87
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.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.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>
101
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv.min.js"></script>
102
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv-security.min.js"></script>
103
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.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.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` |
117
+ | **bsv.min.js** | 937KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@7.3.0/bsv.min.js` |
118
+ | **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.3.0/bsv.bundle.js` |
119
+ | **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.3.0/bsv-smartcontract.min.js` |
120
+ | **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.3.0/bsv-ltp.min.js` |
121
+ | **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.3.0/bsv-gdaf.min.js` |
122
+ | **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.3.0/bsv-shamir.min.js` |
123
+ | **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.3.0/bsv-security.min.js` |
124
+ | **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.3.0/bsv-mnemonic.min.js` |
125
+ | **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.3.0/bsv-ecies.min.js` |
126
+ | **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.3.0/bsv-covenant.min.js` |
127
+ | **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.3.0/bsv-script-helper.min.js` |
128
+ | **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.3.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.2.0/bsv.min.js"></script>
17
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv.min.js"></script>
18
18
 
19
19
  <!-- Everything included (937KB) -->
20
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.bundle.js"></script>
20
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.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.2.0/bsv.min.js"></script>
130
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv.min.js"></script>
131
131
 
132
132
  <!-- Smart contracts (937KB) -->
133
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-smartcontract.min.js"></script>
133
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv-smartcontract.min.js"></script>
134
134
 
135
135
  <!-- Legal tokens (1.16MB) -->
136
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-ltp.min.js"></script>
136
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv-ltp.min.js"></script>
137
137
 
138
138
  <!-- Digital identity (1.16MB) -->
139
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-gdaf.min.js"></script>
139
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv-gdaf.min.js"></script>
140
140
 
141
141
  <!-- Everything (937KB) -->
142
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.bundle.js"></script>
142
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.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.2.0/bsv.min.js"></script>
162
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv.min.js"></script>
163
163
 
164
164
  <!-- Add smart contracts when ready -->
165
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv-smartcontract.min.js"></script>
165
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv-smartcontract.min.js"></script>
166
166
 
167
167
  <!-- Add advanced features as needed -->
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>
168
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv-ltp.min.js"></script>
169
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv-gdaf.min.js"></script>
170
170
 
171
171
  <!-- Everything in one file -->
172
- <script src="https://unpkg.com/@smartledger/bsv@7.2.0/bsv.bundle.js"></script>
172
+ <script src="https://unpkg.com/@smartledger/bsv@7.3.0/bsv.bundle.js"></script>
173
173
  ```
174
174
 
175
175
  ## 🔍 **Testing Your Migration**
@@ -113,6 +113,22 @@ var terms = Ord.parseOrdLock(script)
113
113
  // }
114
114
  ```
115
115
 
116
+ **`parseOrdLock` verifies, it does not pattern-match.** The terms are recovered from the
117
+ script's shape and then checked by reconstruction: the listing is rebuilt from the recovered
118
+ seller / payments / inscription and must match the input byte-for-byte. A script that merely
119
+ wears the same arrangement of opcodes — without the `OP_PUSH_TX` covenant that actually binds
120
+ the payment into `hashOutputs` — is rejected. So a non-null result means the purchase branch
121
+ really does enforce payment, and a UI can display the price without inventing a listing that
122
+ does not exist.
123
+
124
+ > **Interoperability.** This is *this library's* OrdLock. Semantically it is the widely
125
+ > deployed ordinal-lock pattern — `hash256(destOutput ‖ payOutput ‖ trailingOutputs) ==
126
+ > hashOutputs` under `SIGHASH_ALL|ANYONECANPAY` — generalized to multiple payment outputs.
127
+ > But it is built on our audited `OP_PUSH_TX` core rather than compiled from the sCrypt
128
+ > `OrdinalLock` contract, so **the script bytes differ and listings are not interchangeable
129
+ > with that template**: `parseOrdLock` reads listings this library built, not arbitrary
130
+ > marketplace listings.
131
+
116
132
  ### Buy (purchase side)
117
133
 
118
134
  ```js
@@ -171,9 +187,26 @@ B.parseBsv20(script) // { p:'bsv-20', op:'mint', tick:'ORDI', a
171
187
  B.parseBsv20('{"p":"bsv-20","op":"mint","tick":"ORDI","amt":"1"}') // also accepts JSON / objects
172
188
  ```
173
189
 
174
- Builders validate their inputs (ticker ≤ 4 bytes, non-negative integer amounts, `dec` 0–18,
175
- well-formed BSV-21 `id`) and throw on bad data. Balance tracking is an indexer concern —
176
- this module builds and reads the on-chain payloads.
190
+ Builders validate their inputs against the specification and throw on bad data: ticker ≤ 4
191
+ bytes, `dec` 0–18, well-formed BSV-21 `id`, and amounts that are non-negative integers
192
+ **within uint64** (`amt`/`max`/`lim` are "strings representing uint64" — a larger value is
193
+ valid JSON that indexers discard, burning the tokens). A numeric amount past
194
+ `Number.MAX_SAFE_INTEGER` is rejected rather than silently rounded; pass a string. `sym` and
195
+ `icon` must be strings — `icon` an outpoint reference (`<txid>_<vout>`), as the spec defines
196
+ it — so a stray object can no longer be written as the literal text `[object Object]`.
197
+
198
+ `lim: 0` is accepted and means *unlimited*, per the spec ("0 or omitted = unlimited"); only
199
+ `max`/`amt` must be greater than zero.
200
+
201
+ **`parseBsv20` / `isBsv20` enforce validity rather than assuming it.** The operation must be
202
+ one the spec defines and must carry the fields that operation requires — a `transfer` with no
203
+ amount and no token, an `auth` carrying `amt` (which the spec forbids), an over-uint64 amount,
204
+ or an unknown `op` all return `null`. Operations this library does not yet *build* are still
205
+ *read*: `burn`, `auth`, and `deploy+auth` parse correctly. Non-canonical amounts (leading
206
+ zeros) are tolerated when reading other people's payloads, though our builders always emit
207
+ canonical ones.
208
+
209
+ Balance tracking is an indexer concern — this module builds and reads the on-chain payloads.
177
210
 
178
211
  ## API
179
212
 
@@ -182,7 +215,7 @@ this module builds and reads the on-chain payloads.
182
215
  | `buildInscription`, `createInscriptionOutput`, `batchInscriptionOutputs` | build inscription scripts / outputs |
183
216
  | `parseInscription`, `isInscription` | read an inscription back |
184
217
  | `buildOrdLock`, `listInscriptionOutput` | build an OrdLock listing script / 1-sat output |
185
- | `parseOrdLock`, `isOrdLock` | recover a listing's seller, payments, price, inscription |
218
+ | `parseOrdLock`, `isOrdLock` | recover a listing's seller, payments, price, inscription — **verified**, see below |
186
219
  | `buildListingTx` | assemble a signed listing tx (P2PKH ordinal → OrdLock) |
187
220
  | `buildPurchaseTx` | assemble a signed purchase tx from a listing UTXO + buyer coins |
188
221
  | `purchaseOrdLock`, `cancelOrdLock` | build unlock scripts for a spend you assemble |
@@ -21,19 +21,41 @@ var inscription = require('./inscription')
21
21
  var CONTENT_TYPE = 'application/bsv-20'
22
22
  var MAX_DEC = 18
23
23
 
24
+ // "Amounts in BSV-21: strings representing uint64" — amt/max/lim are bounded by 2^64-1.
25
+ // A larger value is emitted happily by JSON but rejected by indexers, burning the tokens.
26
+ var MAX_UINT64 = '18446744073709551615'
27
+
24
28
  /** A non-negative integer string (no sign, no decimal point). */
25
29
  function isIntString (v) { return typeof v === 'string' && /^\d+$/.test(v) }
26
30
 
31
+ /** True if the CANONICAL decimal string `s` is greater than 2^64-1. */
32
+ function exceedsUint64 (s) {
33
+ return s.length > MAX_UINT64.length || (s.length === MAX_UINT64.length && s > MAX_UINT64)
34
+ }
35
+
27
36
  /** Normalize an amount-like field to a CANONICAL non-negative integer string (no leading zeros). */
28
37
  function normInt (v, name) {
38
+ var s
29
39
  if (typeof v === 'number') {
30
40
  if (!Number.isInteger(v) || v < 0) throw new Error(name + ' must be a non-negative integer')
31
- return String(v)
41
+ // Beyond 2^53 a JS number is already an approximation, so String(v) would silently
42
+ // emit a *different* amount than the caller believes they passed.
43
+ if (v > Number.MAX_SAFE_INTEGER) {
44
+ throw new Error(name + ' exceeds Number.MAX_SAFE_INTEGER and would lose precision — ' +
45
+ 'pass it as a string')
46
+ }
47
+ s = String(v)
48
+ } else if (isIntString(v)) {
49
+ // Strip leading zeros ("007" -> "7", "000" -> "0") so the emitted payload is canonical
50
+ // and not rejected by indexers that expect canonical decimal integers.
51
+ s = v.replace(/^0+(?=\d)/, '')
52
+ } else {
53
+ throw new Error(name + ' must be a non-negative integer (string or number)')
54
+ }
55
+ if (exceedsUint64(s)) {
56
+ throw new Error(name + ' exceeds the uint64 maximum (' + MAX_UINT64 + ')')
32
57
  }
33
- // Strip leading zeros ("007" -> "7", "000" -> "0") so the emitted payload is canonical
34
- // and not rejected by indexers that expect canonical decimal integers.
35
- if (isIntString(v)) return v.replace(/^0+(?=\d)/, '')
36
- throw new Error(name + ' must be a non-negative integer (string or number)')
58
+ return s
37
59
  }
38
60
 
39
61
  /** Normalize a strictly-positive amount (mint/transfer/supply must move > 0). */
@@ -57,14 +79,39 @@ function normDec (dec) {
57
79
  return String(d)
58
80
  }
59
81
 
82
+ var OUTPOINT_RE = /^[0-9a-fA-F]{64}_\d+$/
83
+
60
84
  /** Validate a BSV-21 token id: `<64-hex-txid>_<vout>`. */
61
85
  function assertId (id) {
62
- if (typeof id !== 'string' || !/^[0-9a-fA-F]{64}_\d+$/.test(id)) {
86
+ if (typeof id !== 'string' || !OUTPOINT_RE.test(id)) {
63
87
  throw new Error('id must be "<txid>_<vout>" (64-hex txid, underscore, output index)')
64
88
  }
65
89
  return id
66
90
  }
67
91
 
92
+ /**
93
+ * Validate a free-text field (`sym`). Rejects non-strings rather than running them through
94
+ * `String()`, which wrote the literal text `[object Object]` into a permanent payload.
95
+ */
96
+ function assertText (v, name) {
97
+ if (typeof v !== 'string') {
98
+ var t = v === null ? 'null' : Array.isArray(v) ? 'an array' : (typeof v === 'object' ? 'an ' : 'a ') + typeof v
99
+ throw new Error(name + ' must be a string, got ' + t)
100
+ }
101
+ if (!v.length) throw new Error(name + ' must not be empty')
102
+ return v
103
+ }
104
+
105
+ /** Validate `icon`, which the spec defines as an outpoint reference (`<txid>_<vout>`). */
106
+ function assertIcon (v) {
107
+ assertText(v, 'icon')
108
+ if (!OUTPOINT_RE.test(v)) {
109
+ throw new Error('icon must be an outpoint reference "<txid>_<vout>" (64-hex txid, ' +
110
+ 'underscore, output index)')
111
+ }
112
+ return v
113
+ }
114
+
68
115
  /** Wrap a BSV-20 JSON payload in an inscription locking script (P2PKH owner by default). */
69
116
  function buildBsv20 (payload, params) {
70
117
  params = params || {}
@@ -84,7 +131,9 @@ function buildBsv20 (payload, params) {
84
131
  function buildDeploy (params) {
85
132
  params = params || {}
86
133
  var p = { p: 'bsv-20', op: 'deploy', tick: assertTick(params.tick), max: normPositive(params.max, 'max') }
87
- if (params.lim != null) p.lim = normPositive(params.lim, 'lim')
134
+ // `lim` is "0 or omitted = unlimited" per the spec, so 0 is a meaningful value here and
135
+ // must not be rejected the way a zero `max`/`amt` is.
136
+ if (params.lim != null) p.lim = normInt(params.lim, 'lim')
88
137
  if (params.dec != null) p.dec = normDec(params.dec)
89
138
  return buildBsv20(p, params)
90
139
  }
@@ -122,8 +171,8 @@ function buildDeployMint (params) {
122
171
  params = params || {}
123
172
  var p = { p: 'bsv-20', op: 'deploy+mint', amt: normPositive(params.amt, 'amt') }
124
173
  if (params.dec != null) p.dec = normDec(params.dec)
125
- if (params.sym != null) p.sym = String(params.sym)
126
- if (params.icon != null) p.icon = String(params.icon)
174
+ if (params.sym != null) p.sym = assertText(params.sym, 'sym')
175
+ if (params.icon != null) p.icon = assertIcon(params.icon)
127
176
  return buildBsv20(p, params)
128
177
  }
129
178
 
@@ -149,10 +198,69 @@ function bodyOf (input) {
149
198
  return insc ? insc.contentText : null
150
199
  }
151
200
 
201
+ /**
202
+ * Required-field rules per operation, from the BSV-20 / BSV-21 specification.
203
+ *
204
+ * `tickOrId` means the operation must carry exactly one of `tick` (v1) or `id` (v2/BSV-21).
205
+ * `noAmt` marks the operations the spec says must NOT carry an `amt` at all.
206
+ */
207
+ var OP_RULES = {
208
+ deploy: { need: ['tick', 'max'] },
209
+ mint: { need: ['amt'], tickOrId: true },
210
+ transfer: { need: ['amt'], tickOrId: true },
211
+ 'deploy+mint': { need: ['amt'] },
212
+ 'deploy+auth': { need: [], noAmt: true },
213
+ auth: { need: ['id'], noAmt: true },
214
+ burn: { need: ['id', 'amt'] }
215
+ }
216
+
217
+ /**
218
+ * Is `v` a uint64 amount as it may appear ON CHAIN? Leading zeros are tolerated here even
219
+ * though the builder emits canonical values: this reads other people's payloads, and a
220
+ * non-canonical amount is still an amount.
221
+ */
222
+ function isParsedAmount (v) {
223
+ var s = typeof v === 'number' ? (Number.isInteger(v) && v >= 0 ? String(v) : null) : (isIntString(v) ? v : null)
224
+ if (s == null) return false
225
+ return !exceedsUint64(s.replace(/^0+(?=\d)/, ''))
226
+ }
227
+
228
+ /** Validate a parsed payload against the spec's per-operation field rules. */
229
+ function isValidPayload (obj) {
230
+ if (!obj || obj.p !== 'bsv-20' || typeof obj.op !== 'string') return false
231
+ var rule = OP_RULES[obj.op]
232
+ if (!rule) return false // unknown operation: we cannot vouch for it
233
+ for (var i = 0; i < rule.need.length; i++) {
234
+ if (obj[rule.need[i]] == null) return false
235
+ }
236
+ if (rule.tickOrId && (obj.tick == null) === (obj.id == null)) return false
237
+ if (rule.noAmt && obj.amt != null) return false
238
+ if (obj.tick != null) {
239
+ if (typeof obj.tick !== 'string' || !obj.tick.length || Buffer.byteLength(obj.tick, 'utf8') > 4) return false
240
+ }
241
+ if (obj.id != null && (typeof obj.id !== 'string' || !OUTPOINT_RE.test(obj.id))) return false
242
+ var amounts = ['amt', 'max', 'lim']
243
+ for (var j = 0; j < amounts.length; j++) {
244
+ if (obj[amounts[j]] != null && !isParsedAmount(obj[amounts[j]])) return false
245
+ }
246
+ if (obj.dec != null) {
247
+ var d = typeof obj.dec === 'string' ? Number(obj.dec) : obj.dec
248
+ if (!Number.isInteger(d) || d < 0 || d > MAX_DEC) return false
249
+ }
250
+ return true
251
+ }
252
+
152
253
  /**
153
254
  * Parse a BSV-20 payload from a locking script (Script/Buffer/hex), a JSON string, or an
154
255
  * already-parsed object. Returns the payload object (with `p:'bsv-20'`) or null if the
155
256
  * input carries no valid BSV-20 inscription.
257
+ *
258
+ * "Valid" is enforced, not assumed: the operation must be one the spec defines and must
259
+ * carry the fields that operation requires, with `tick`/`id`/amount/`dec` well-formed.
260
+ * A payload this returns is one an indexer will act on; previously any JSON object with
261
+ * `p: 'bsv-20'` and a string `op` was returned, including `{p:'bsv-20', op:'transfer'}`
262
+ * with no amount and no token — which an indexer discards.
263
+ *
156
264
  * @returns {null|{ p:'bsv-20', op:string, tick?:string, id?:string, amt?:string, max?:string, lim?:string, dec?:string, sym?:string, icon?:string }}
157
265
  */
158
266
  function parseBsv20 (input) {
@@ -160,14 +268,13 @@ function parseBsv20 (input) {
160
268
  var body = bodyOf(input)
161
269
  if (body == null) return null
162
270
  var obj = (typeof body === 'object') ? body : JSON.parse(body)
163
- if (!obj || obj.p !== 'bsv-20' || typeof obj.op !== 'string') return null
164
- return obj
271
+ return isValidPayload(obj) ? obj : null
165
272
  } catch (e) {
166
273
  return null
167
274
  }
168
275
  }
169
276
 
170
- /** True if the input carries a valid BSV-20 inscription. */
277
+ /** True if the input carries a valid BSV-20 inscription (see parseBsv20 for what that means). */
171
278
  function isBsv20 (input) { return parseBsv20(input) !== null }
172
279
 
173
280
  module.exports = {
@@ -205,7 +205,19 @@ function splitPayBlob (blob) {
205
205
 
206
206
  /**
207
207
  * Parse an OrdLock listing script into its economic terms. Returns null if `script`
208
- * is not a recognizable OrdLock (so it doubles as a detector).
208
+ * is not an OrdLock (so it doubles as a detector).
209
+ *
210
+ * The terms are recovered from the script's shape and then **verified by reconstruction**:
211
+ * the listing is rebuilt from the recovered seller / payment outputs / inscription and must
212
+ * match the input byte-for-byte. A script that merely wears the same arrangement of opcodes
213
+ * — without the OP_PUSH_TX covenant that actually binds the payment into `hashOutputs` —
214
+ * is rejected, so a non-null result means the purchase branch genuinely enforces payment.
215
+ *
216
+ * Note this is *this library's* OrdLock. It is semantically the widely-deployed
217
+ * ordinal-lock pattern (`hash256(destOutput ‖ payOutput ‖ trailingOutputs) == hashOutputs`
218
+ * under SIGHASH_ALL|ANYONECANPAY), generalized to multiple payment outputs, but it is built
219
+ * on our OP_PUSH_TX core rather than compiled from the sCrypt contract — so the bytes differ
220
+ * and listings are not interchangeable with that template.
209
221
  *
210
222
  * @param {Script|Buffer|string} script
211
223
  * @param {object} [opts] { network } network for the returned address strings
@@ -269,6 +281,20 @@ function parseOrdLock (script, opts) {
269
281
  insc = { contentType: parsedInsc.contentType, content: parsedInsc.content, contentText: parsedInsc.contentText }
270
282
  }
271
283
 
284
+ // Everything above recovers terms from the script's SHAPE. Shape alone proves nothing:
285
+ // a script carrying this arrangement of opcodes but no OP_PUSH_TX covenant enforces no
286
+ // payment at all, and reporting a seller and a price for it invents a listing that does
287
+ // not exist. So rebuild the listing from the recovered terms and require it to match
288
+ // byte-for-byte — the only way to know the purchase branch really binds the payment.
289
+ var rebuilt = buildOrdLock({
290
+ seller: sellerPKH,
291
+ payOutputs: splitPayBlob(payBlob),
292
+ inscription: parsedInsc
293
+ ? { contentType: parsedInsc.contentType, content: parsedInsc.content }
294
+ : undefined
295
+ })
296
+ if (rebuilt.toHex() !== s.toHex()) return null
297
+
272
298
  return {
273
299
  seller: { pubKeyHash: sellerPKH, address: bsv.Address.fromPublicKeyHash(sellerPKH, network).toString() },
274
300
  payOutputs: payOutputs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartledger/bsv",
3
- "version": "7.2.0",
3
+ "version": "7.3.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",