@smartledger/bsv 7.7.1 → 7.8.1
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 +66 -14
- package/README.md +38 -38
- package/bsv-gdaf.min.js +22 -22
- package/bsv-ltp.min.js +22 -22
- package/bsv-smartcontract.min.js +1 -1
- package/bsv.bundle.js +22 -22
- package/bsv.min.js +22 -22
- 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/script/interpreter.js +78 -0
- package/package.json +1 -1
- package/test/script/chronicle.js +96 -0
- package/test/script/interpreter.js +4 -9
- 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.8.1/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.8.1/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.8.1/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.8.1/bsv.min.js` |
|
|
85
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.8.1/bsv.bundle.js` |
|
|
86
|
+
| **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.8.1/bsv-smartcontract.min.js` |
|
|
87
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.8.1/bsv-covenant.min.js` |
|
|
88
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.8.1/bsv-script-helper.min.js` |
|
|
89
|
+
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.8.1/bsv-security.min.js` |
|
|
90
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.8.1/bsv-ecies.min.js` |
|
|
91
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.8.1/bsv-message.min.js` |
|
|
92
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.8.1/bsv-mnemonic.min.js` |
|
|
93
|
+
| **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.8.1/bsv-shamir.min.js` |
|
|
94
|
+
| **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.8.1/bsv-gdaf.min.js` |
|
|
95
|
+
| **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.8.1/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.8.1/bsv.min.js"></script>
|
|
104
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.1/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.8.1/bsv.min.js"></script>
|
|
110
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-covenant.min.js"></script>
|
|
111
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.1/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.8.1/bsv.min.js"></script>
|
|
117
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-ltp.min.js"></script>
|
|
118
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.1/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.8.1/bsv.min.js"></script>
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-security.min.js"></script>
|
|
137
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.1/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.8.1/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.8.1/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.8.1/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.8.1/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.8.1/bsv.min.js"></script>
|
|
75
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-covenant.min.js"></script>
|
|
76
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.1/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.8.1/bsv.min.js"></script>
|
|
86
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-ltp.min.js"></script>
|
|
87
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.1/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.8.1/bsv.min.js"></script>
|
|
102
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.1/bsv-security.min.js"></script>
|
|
103
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.1/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.8.1/bsv.min.js` |
|
|
118
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.8.1/bsv.bundle.js` |
|
|
119
|
+
| **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.8.1/bsv-smartcontract.min.js` |
|
|
120
|
+
| **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.8.1/bsv-ltp.min.js` |
|
|
121
|
+
| **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.8.1/bsv-gdaf.min.js` |
|
|
122
|
+
| **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.8.1/bsv-shamir.min.js` |
|
|
123
|
+
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.8.1/bsv-security.min.js` |
|
|
124
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.8.1/bsv-mnemonic.min.js` |
|
|
125
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.8.1/bsv-ecies.min.js` |
|
|
126
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.8.1/bsv-covenant.min.js` |
|
|
127
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.8.1/bsv-script-helper.min.js` |
|
|
128
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.8.1/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.8.1/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.8.1/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.8.1/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.8.1/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.8.1/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.8.1/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.8.1/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.8.1/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.8.1/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.8.1/bsv-ltp.min.js"></script>
|
|
169
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.1/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.8.1/bsv.bundle.js"></script>
|
|
173
173
|
```
|
|
174
174
|
|
|
175
175
|
## 🔍 **Testing Your Migration**
|
|
@@ -965,6 +965,84 @@ Interpreter.prototype.step = function () {
|
|
|
965
965
|
}
|
|
966
966
|
break
|
|
967
967
|
|
|
968
|
+
case Opcode.OP_LSHIFTNUM:
|
|
969
|
+
case Opcode.OP_RSHIFTNUM:
|
|
970
|
+
// Chronicle numeric shifts, ported from SV Node's src/script/interpreter.cpp.
|
|
971
|
+
//
|
|
972
|
+
// Before Chronicle activates for the UTXO these bytes are UPGRADABLE NOPS on
|
|
973
|
+
// the network, not errors — the node does exactly this:
|
|
974
|
+
//
|
|
975
|
+
// if(!utxo_after_chronicle) {
|
|
976
|
+
// if(IsDiscourageUpgradableNops(flags))
|
|
977
|
+
// return SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS;
|
|
978
|
+
// else break;
|
|
979
|
+
// }
|
|
980
|
+
//
|
|
981
|
+
// Rejecting them outright would make this library refuse scripts the network
|
|
982
|
+
// accepts, which is the mirror of the bug that made them silently succeed.
|
|
983
|
+
if ((this.flags & Interpreter.SCRIPT_ENABLE_CHRONICLE) === 0) {
|
|
984
|
+
if (this.flags & Interpreter.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS) {
|
|
985
|
+
this.errstr = 'SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS'
|
|
986
|
+
return false
|
|
987
|
+
}
|
|
988
|
+
break
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
// (x n -- out): the shift COUNT is on top, the value beneath.
|
|
992
|
+
if (this.stack.length < 2) {
|
|
993
|
+
this.errstr = 'SCRIPT_ERR_INVALID_STACK_OPERATION'
|
|
994
|
+
return false
|
|
995
|
+
}
|
|
996
|
+
var maxNumSize = Interpreter.MAXIMUM_ELEMENT_SIZE
|
|
997
|
+
var shiftBn = BN.fromScriptNumBuffer(stacktop(-1), fRequireMinimal, maxNumSize)
|
|
998
|
+
if (shiftBn.isNeg()) {
|
|
999
|
+
this.errstr = 'SCRIPT_ERR_INVALID_NUMBER_RANGE'
|
|
1000
|
+
return false
|
|
1001
|
+
}
|
|
1002
|
+
this.stack.pop()
|
|
1003
|
+
var valueBn = BN.fromScriptNumBuffer(stacktop(-1), fRequireMinimal, maxNumSize)
|
|
1004
|
+
this.stack.pop()
|
|
1005
|
+
|
|
1006
|
+
var shiftBy = shiftBn.toNumber()
|
|
1007
|
+
var negative = valueBn.isNeg()
|
|
1008
|
+
// Shift the MAGNITUDE and carry the sign. That is what "preserving sign"
|
|
1009
|
+
// means: CScriptNum is sign-magnitude (its bignum path is OpenSSL BN_lshift /
|
|
1010
|
+
// BN_rshift), and the int64 path spells the same thing out —
|
|
1011
|
+
// "Mathematical division by 2^bit_shift, rounding toward zero ...
|
|
1012
|
+
// For negative values: n / 2^k = -((-n) >> k)"
|
|
1013
|
+
// so -5 RSHIFTNUM 1 is -2, NOT -3. An arithmetic (two's-complement) shift
|
|
1014
|
+
// would floor to -3; this is division truncating toward zero, matching
|
|
1015
|
+
// OP_DIV and OP_2DIV. bn.js shrn/shln assert on negatives, so operating on
|
|
1016
|
+
// abs() is required anyway.
|
|
1017
|
+
var magnitude = valueBn.abs()
|
|
1018
|
+
var shifted
|
|
1019
|
+
if (opcodenum === Opcode.OP_LSHIFTNUM) {
|
|
1020
|
+
// Bound the result BEFORE shifting, exactly as CScriptNum does
|
|
1021
|
+
// (current_size + shift_bytes > max_length), so an enormous count cannot
|
|
1022
|
+
// allocate an enormous number on the way to being rejected.
|
|
1023
|
+
var currentSize = valueBn.toScriptNumBuffer().length
|
|
1024
|
+
if (currentSize + Math.floor(shiftBy / 8) > maxNumSize) {
|
|
1025
|
+
this.errstr = 'SCRIPT_ERR_SCRIPTNUM_OVERFLOW'
|
|
1026
|
+
return false
|
|
1027
|
+
}
|
|
1028
|
+
shifted = magnitude.shln(shiftBy)
|
|
1029
|
+
} else {
|
|
1030
|
+
// Right-shifting by at least the bit length is zero. Checking that first
|
|
1031
|
+
// keeps an arbitrarily large count cheap and matches the node, whose
|
|
1032
|
+
// int64 path returns 0 for counts >= 64 and whose bignum path reaches the
|
|
1033
|
+
// same value through BN_rshift.
|
|
1034
|
+
shifted = shiftBy >= magnitude.bitLength() ? new BN(0) : magnitude.shrn(shiftBy)
|
|
1035
|
+
}
|
|
1036
|
+
if (negative && !shifted.isZero()) {
|
|
1037
|
+
shifted = shifted.neg()
|
|
1038
|
+
}
|
|
1039
|
+
if (shifted.toScriptNumBuffer().length > maxNumSize) {
|
|
1040
|
+
this.errstr = 'SCRIPT_ERR_SCRIPTNUM_OVERFLOW'
|
|
1041
|
+
return false
|
|
1042
|
+
}
|
|
1043
|
+
this.stack.push(shifted.toScriptNumBuffer())
|
|
1044
|
+
break
|
|
1045
|
+
|
|
968
1046
|
case Opcode.OP_VER:
|
|
969
1047
|
// Chronicle: pushes the executing transaction's version.
|
|
970
1048
|
if ((this.flags & Interpreter.SCRIPT_ENABLE_CHRONICLE) === 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartledger/bsv",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.8.1",
|
|
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/script/chronicle.js
CHANGED
|
@@ -164,6 +164,102 @@ describe('Chronicle script surface', function () {
|
|
|
164
164
|
})
|
|
165
165
|
})
|
|
166
166
|
|
|
167
|
+
// Ported from SV Node src/script/interpreter.cpp (OP_LSHIFTNUM / OP_RSHIFTNUM) and
|
|
168
|
+
// the CScriptNum / bsv::bint arithmetic behind it. Each case below corresponds to a
|
|
169
|
+
// specific line of that implementation, so a divergence shows up as a named failure.
|
|
170
|
+
describe('OP_LSHIFTNUM / OP_RSHIFTNUM', function () {
|
|
171
|
+
// Push x then n then the opcode: the node's comment is literally `(x n -- out)`,
|
|
172
|
+
// so the COUNT is on top.
|
|
173
|
+
function shift (x, n, op, flags) {
|
|
174
|
+
return run(function (s) {
|
|
175
|
+
s.add(new BN(x).toScriptNumBuffer()).add(new BN(n).toScriptNumBuffer()).add(op)
|
|
176
|
+
}, { flags: flags == null ? CHRONICLE : flags })
|
|
177
|
+
}
|
|
178
|
+
function value (x, n, op) {
|
|
179
|
+
var r = shift(x, n, op)
|
|
180
|
+
return r.stack[r.stack.length - 1]
|
|
181
|
+
}
|
|
182
|
+
// A zero result makes the script fail EVAL_FALSE, so compare against OP_0 instead.
|
|
183
|
+
function isZero (x, n, op) {
|
|
184
|
+
return run(function (s) {
|
|
185
|
+
s.add(new BN(x).toScriptNumBuffer()).add(new BN(n).toScriptNumBuffer()).add(op)
|
|
186
|
+
.add(Opcode.OP_0).add(Opcode.OP_EQUAL)
|
|
187
|
+
}).verified
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
it('are upgradable NOPs before Chronicle, as the node has them', function () {
|
|
191
|
+
// if(!utxo_after_chronicle) { ... else break; } — a no-op, NOT an error.
|
|
192
|
+
// Rejecting here would refuse scripts the network accepts.
|
|
193
|
+
var r = shift(8, 1, Opcode.OP_LSHIFTNUM, 0)
|
|
194
|
+
r.verified.should.equal(true)
|
|
195
|
+
r.stack.should.deep.equal(['8', '1']) // untouched: no shift, nothing popped
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
it('honour DISCOURAGE_UPGRADABLE_NOPS before Chronicle', function () {
|
|
199
|
+
var r = shift(8, 1, Opcode.OP_LSHIFTNUM, Interpreter.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)
|
|
200
|
+
r.verified.should.equal(false)
|
|
201
|
+
r.errstr.should.match(/DISCOURAGE_UPGRADABLE_NOPS/)
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
it('left shift multiplies by 2^n, carrying the sign', function () {
|
|
205
|
+
value(1, 4, Opcode.OP_LSHIFTNUM).should.equal('16')
|
|
206
|
+
value(3, 3, Opcode.OP_LSHIFTNUM).should.equal('24')
|
|
207
|
+
value(1, 0, Opcode.OP_LSHIFTNUM).should.equal('1')
|
|
208
|
+
value(-1, 4, Opcode.OP_LSHIFTNUM).should.equal('-16')
|
|
209
|
+
value(-3, 3, Opcode.OP_LSHIFTNUM).should.equal('-24')
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
it('right shift TRUNCATES TOWARD ZERO, which is the whole of "preserving sign"', function () {
|
|
213
|
+
// The node spells this out: "Mathematical division by 2^bit_shift, rounding
|
|
214
|
+
// toward zero ... For negative values: n / 2^k = -((-n) >> k)". A two's
|
|
215
|
+
// complement arithmetic shift would FLOOR instead, giving -3 and -4 here.
|
|
216
|
+
value(-5, 1, Opcode.OP_RSHIFTNUM).should.equal('-2')
|
|
217
|
+
value(-7, 1, Opcode.OP_RSHIFTNUM).should.equal('-3')
|
|
218
|
+
value(5, 1, Opcode.OP_RSHIFTNUM).should.equal('2')
|
|
219
|
+
value(-1000, 3, Opcode.OP_RSHIFTNUM).should.equal('-125')
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
it('agrees with OP_DIV by 2^n, the same convention as OP_2DIV', function () {
|
|
223
|
+
[5, -5, 7, -7, 1000, -1000].forEach(function (x) {
|
|
224
|
+
var viaShift = value(x, 1, Opcode.OP_RSHIFTNUM)
|
|
225
|
+
var viaDiv = run(function (s) {
|
|
226
|
+
s.add(new BN(x).toScriptNumBuffer()).add(new BN(2).toScriptNumBuffer()).add(Opcode.OP_DIV)
|
|
227
|
+
})
|
|
228
|
+
viaShift.should.equal(viaDiv.stack[viaDiv.stack.length - 1])
|
|
229
|
+
})
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
it('rejects a negative shift count', function () {
|
|
233
|
+
// if(n < 0) return SCRIPT_ERR_INVALID_NUMBER_RANGE
|
|
234
|
+
;[Opcode.OP_LSHIFTNUM, Opcode.OP_RSHIFTNUM].forEach(function (op) {
|
|
235
|
+
var r = shift(8, -1, op)
|
|
236
|
+
r.verified.should.equal(false)
|
|
237
|
+
r.errstr.should.match(/INVALID_NUMBER_RANGE/)
|
|
238
|
+
})
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
it('right shift past the bit length is zero, not an error', function () {
|
|
242
|
+
isZero(5, 1000, Opcode.OP_RSHIFTNUM).should.equal(true)
|
|
243
|
+
isZero(-5, 1000, Opcode.OP_RSHIFTNUM).should.equal(true) // and no negative zero
|
|
244
|
+
isZero(1, 1, Opcode.OP_RSHIFTNUM).should.equal(true)
|
|
245
|
+
isZero(-1, 1, Opcode.OP_RSHIFTNUM).should.equal(true)
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
it('left shift overflows rather than growing without bound', function () {
|
|
249
|
+
// CScriptNum bounds this BEFORE shifting (current_size + shift_bytes >
|
|
250
|
+
// max_length), so a huge count cannot allocate a huge number first.
|
|
251
|
+
var r = shift(5, 1000, Opcode.OP_LSHIFTNUM)
|
|
252
|
+
r.verified.should.equal(false)
|
|
253
|
+
r.errstr.should.match(/OVERFLOW/)
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
it('fails on a short stack', function () {
|
|
257
|
+
var r = run(function (s) { s.add(new BN(1).toScriptNumBuffer()).add(Opcode.OP_LSHIFTNUM) })
|
|
258
|
+
r.verified.should.equal(false)
|
|
259
|
+
r.errstr.should.match(/INVALID_STACK_OPERATION/)
|
|
260
|
+
})
|
|
261
|
+
})
|
|
262
|
+
|
|
167
263
|
describe('SIGHASH_CHRONICLE selects the original digest algorithm', function () {
|
|
168
264
|
function fixture () {
|
|
169
265
|
var key = bsv.PrivateKey.fromBuffer(Buffer.alloc(32, 5))
|
|
@@ -643,10 +643,9 @@ describe('Interpreter', function () {
|
|
|
643
643
|
// - Chronicle reassigned 0xb3-0xb7 to OP_SUBSTR/OP_LEFT/OP_RIGHT/OP_LSHIFTNUM/
|
|
644
644
|
// OP_RSHIFTNUM, so Core's NOP4..NOP8 no longer exist as no-ops. Vectors that
|
|
645
645
|
// expect those bytes to do nothing now fail here: 0xb3-0xb5 consume stack as
|
|
646
|
-
// string ops (INVALID_STACK_OPERATION)
|
|
647
|
-
//
|
|
648
|
-
//
|
|
649
|
-
// refusing. This is a real consensus divergence from Core, not a quirk.
|
|
646
|
+
// string ops (INVALID_STACK_OPERATION). 0xb6/0xb7 are NOT divergent: they are
|
|
647
|
+
// upgradable NOPs until Chronicle activates, exactly as in SV Node and Core,
|
|
648
|
+
// and only perform a shift under SCRIPT_ENABLE_CHRONICLE.
|
|
650
649
|
// (0xba is no longer a NOP either; it is unassigned, which now AGREES with
|
|
651
650
|
// Core, so its former override has been removed.)
|
|
652
651
|
var BSV_DIVERGENCES = {
|
|
@@ -670,11 +669,7 @@ describe('Interpreter', function () {
|
|
|
670
669
|
"'NOP_1_to_10' NOP1 CHECKLOCKTIMEVERIFY CHECKSEQUENCEVERIFY NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10|'NOP_1_to_10' EQUAL|P2SH,STRICTENC": 'SCRIPT_ERR_INVALID_STACK_OPERATION',
|
|
671
670
|
'NOP|NOP4 1|P2SH,STRICTENC': 'SCRIPT_ERR_INVALID_STACK_OPERATION',
|
|
672
671
|
'NOP|NOP5 1|P2SH,STRICTENC': 'SCRIPT_ERR_INVALID_STACK_OPERATION',
|
|
673
|
-
'NOP|NOP6 1|P2SH,STRICTENC': 'SCRIPT_ERR_INVALID_STACK_OPERATION'
|
|
674
|
-
'NOP|NOP7 1|P2SH,STRICTENC': 'SCRIPT_ERR_BAD_OPCODE',
|
|
675
|
-
'NOP|NOP8 1|P2SH,STRICTENC': 'SCRIPT_ERR_BAD_OPCODE',
|
|
676
|
-
'0x47 0x3044022018a2a81a93add5cb5f5da76305718e4ea66045ec4888b28d84cb22fae7f4645b02201e6daa5ed5d2e4b2b2027cf7ffd43d8d9844dd49f74ef86899ec8e669dfd39aa01 NOP8 0x23 0x2103363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640ac|HASH160 0x14 0x215640c2f72f0d16b4eced26762035a42ffed39a EQUAL|': 'SCRIPT_ERR_BAD_OPCODE',
|
|
677
|
-
'0x47 0x304402203e4516da7253cf068effec6b95c41221c0cf3a8e6ccb8cbf1725b562e9afde2c022054e1c258c2981cdfba5df1f46661fb6541c44f77ca0092f3600331abfffb125101 NOP8|0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 CHECKSIG|': 'SCRIPT_ERR_BAD_OPCODE'
|
|
672
|
+
'NOP|NOP6 1|P2SH,STRICTENC': 'SCRIPT_ERR_INVALID_STACK_OPERATION'
|
|
678
673
|
}
|
|
679
674
|
|
|
680
675
|
describe('bitcoind script evaluation fixtures', function () {
|
package/version.js
CHANGED