@smartledger/bsv 7.6.2 → 7.8.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 +115 -0
- package/README.md +38 -38
- package/bsv-gdaf.min.js +47 -47
- package/bsv-ltp.min.js +47 -47
- package/bsv-smartcontract.min.js +11 -11
- package/bsv.bundle.js +47 -47
- package/bsv.d.ts +6 -0
- package/bsv.min.js +47 -47
- 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/crypto/signature.js +2 -0
- package/lib/script/interpreter.js +152 -2
- package/lib/transaction/sighash.js +17 -1
- package/package.json +1 -1
- package/test/script/chronicle.js +318 -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.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.8.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.8.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.8.0/bsv.min.js` |
|
|
85
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.8.0/bsv.bundle.js` |
|
|
86
|
+
| **bsv-smartcontract.min.js** | 937KB | Covenant development | `unpkg.com/@smartledger/bsv@7.8.0/bsv-smartcontract.min.js` |
|
|
87
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.8.0/bsv-covenant.min.js` |
|
|
88
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.8.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.8.0/bsv-security.min.js` |
|
|
90
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.8.0/bsv-ecies.min.js` |
|
|
91
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.8.0/bsv-message.min.js` |
|
|
92
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.8.0/bsv-mnemonic.min.js` |
|
|
93
|
+
| **🆕 bsv-shamir.min.js** | 432KB | **Secret sharing** | `unpkg.com/@smartledger/bsv@7.8.0/bsv-shamir.min.js` |
|
|
94
|
+
| **🆕 bsv-gdaf.min.js** | 1184KB | **Digital attestation** | `unpkg.com/@smartledger/bsv@7.8.0/bsv-gdaf.min.js` |
|
|
95
|
+
| **🆕 bsv-ltp.min.js** | 1184KB | **Legal tokens** | `unpkg.com/@smartledger/bsv@7.8.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.8.0/bsv.min.js"></script>
|
|
104
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.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.8.0/bsv.min.js"></script>
|
|
110
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.0/bsv-covenant.min.js"></script>
|
|
111
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.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.8.0/bsv.min.js"></script>
|
|
117
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.0/bsv-ltp.min.js"></script>
|
|
118
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.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.8.0/bsv.min.js"></script>
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.0/bsv-security.min.js"></script>
|
|
137
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.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.8.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.8.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.8.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.8.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.8.0/bsv.min.js"></script>
|
|
75
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.0/bsv-covenant.min.js"></script>
|
|
76
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.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.8.0/bsv.min.js"></script>
|
|
86
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.0/bsv-ltp.min.js"></script>
|
|
87
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.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.8.0/bsv.min.js"></script>
|
|
102
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.0/bsv-security.min.js"></script>
|
|
103
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.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.8.0/bsv.min.js` |
|
|
118
|
+
| **bsv.bundle.js** | 937KB | Everything in one file | `unpkg.com/@smartledger/bsv@7.8.0/bsv.bundle.js` |
|
|
119
|
+
| **bsv-smartcontract.min.js** | 937KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@7.8.0/bsv-smartcontract.min.js` |
|
|
120
|
+
| **bsv-ltp.min.js** | 1184KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@7.8.0/bsv-ltp.min.js` |
|
|
121
|
+
| **bsv-gdaf.min.js** | 1184KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@7.8.0/bsv-gdaf.min.js` |
|
|
122
|
+
| **bsv-shamir.min.js** | 432KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@7.8.0/bsv-shamir.min.js` |
|
|
123
|
+
| **bsv-security.min.js** | 26KB | Security enhancements (opt-in helpers — see README › Security) | `unpkg.com/@smartledger/bsv@7.8.0/bsv-security.min.js` |
|
|
124
|
+
| **bsv-mnemonic.min.js** | 681KB | HD wallets | `unpkg.com/@smartledger/bsv@7.8.0/bsv-mnemonic.min.js` |
|
|
125
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@7.8.0/bsv-ecies.min.js` |
|
|
126
|
+
| **bsv-covenant.min.js** | 913KB | Covenant operations | `unpkg.com/@smartledger/bsv@7.8.0/bsv-covenant.min.js` |
|
|
127
|
+
| **bsv-script-helper.min.js** | 26KB | Custom script tools | `unpkg.com/@smartledger/bsv@7.8.0/bsv-script-helper.min.js` |
|
|
128
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@7.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.0/bsv-ltp.min.js"></script>
|
|
169
|
+
<script src="https://unpkg.com/@smartledger/bsv@7.8.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.8.0/bsv.bundle.js"></script>
|
|
173
173
|
```
|
|
174
174
|
|
|
175
175
|
## 🔍 **Testing Your Migration**
|
package/lib/crypto/signature.js
CHANGED
|
@@ -327,6 +327,8 @@ Signature.prototype.toTxFormat = function () {
|
|
|
327
327
|
Signature.SIGHASH_ALL = 0x01
|
|
328
328
|
Signature.SIGHASH_NONE = 0x02
|
|
329
329
|
Signature.SIGHASH_SINGLE = 0x03
|
|
330
|
+
// Chronicle: selects the Original Transaction Digest Algorithm for this input.
|
|
331
|
+
Signature.SIGHASH_CHRONICLE = 0x20
|
|
330
332
|
Signature.SIGHASH_FORKID = 0x40
|
|
331
333
|
Signature.SIGHASH_ANYONECANPAY = 0x80
|
|
332
334
|
|
|
@@ -385,6 +385,11 @@ Interpreter.SCRIPT_ENABLE_MONOLITH_OPCODES = (1 << 18)
|
|
|
385
385
|
//
|
|
386
386
|
Interpreter.SCRIPT_ENABLE_MAGNETIC_OPCODES = (1 << 19)
|
|
387
387
|
|
|
388
|
+
// Chronicle restores OP_2MUL/OP_2DIV and gives OP_VER/OP_VERIF/OP_VERNOTIF meaning.
|
|
389
|
+
// Off by default: enabling it changes script evaluation, so it is an explicit opt-in
|
|
390
|
+
// exactly like the Monolith and Magnetic flags above.
|
|
391
|
+
Interpreter.SCRIPT_ENABLE_CHRONICLE = (1 << 20)
|
|
392
|
+
|
|
388
393
|
/* Below flags apply in the context of BIP 68 */
|
|
389
394
|
/**
|
|
390
395
|
* If this flag set, CTxIn::nSequence is NOT interpreted as a relative
|
|
@@ -734,8 +739,14 @@ Interpreter.prototype.step = function () {
|
|
|
734
739
|
switch (opcode) {
|
|
735
740
|
case Opcode.OP_2MUL:
|
|
736
741
|
case Opcode.OP_2DIV:
|
|
737
|
-
//
|
|
738
|
-
|
|
742
|
+
// Chronicle restores both. Until it is enabled they stay disabled, and
|
|
743
|
+
// "disabled" is stronger than "unimplemented": a disabled opcode fails the
|
|
744
|
+
// script even in an UNEXECUTED branch, which is why this lives in
|
|
745
|
+
// isOpcodeDisabled rather than in the evaluation switch.
|
|
746
|
+
if ((self.flags & Interpreter.SCRIPT_ENABLE_CHRONICLE) === 0) {
|
|
747
|
+
return true
|
|
748
|
+
}
|
|
749
|
+
break
|
|
739
750
|
|
|
740
751
|
case Opcode.OP_INVERT:
|
|
741
752
|
case Opcode.OP_MUL:
|
|
@@ -954,6 +965,133 @@ Interpreter.prototype.step = function () {
|
|
|
954
965
|
}
|
|
955
966
|
break
|
|
956
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
|
+
|
|
1046
|
+
case Opcode.OP_VER:
|
|
1047
|
+
// Chronicle: pushes the executing transaction's version.
|
|
1048
|
+
if ((this.flags & Interpreter.SCRIPT_ENABLE_CHRONICLE) === 0) {
|
|
1049
|
+
this.errstr = 'SCRIPT_ERR_BAD_OPCODE'
|
|
1050
|
+
return false
|
|
1051
|
+
}
|
|
1052
|
+
if (this.tx == null) {
|
|
1053
|
+
this.errstr = 'SCRIPT_ERR_UNKNOWN_ERROR'
|
|
1054
|
+
return false
|
|
1055
|
+
}
|
|
1056
|
+
this.stack.push(new BN(this.tx.version).toScriptNumBuffer())
|
|
1057
|
+
break
|
|
1058
|
+
|
|
1059
|
+
case Opcode.OP_VERIF:
|
|
1060
|
+
case Opcode.OP_VERNOTIF:
|
|
1061
|
+
// Chronicle: an IF whose condition is "top of stack equals the executing
|
|
1062
|
+
// transaction's version", closed by OP_ENDIF.
|
|
1063
|
+
//
|
|
1064
|
+
// Before Chronicle these are invalid EVEN IN AN UNEXECUTED BRANCH — a rule
|
|
1065
|
+
// Bitcoin applies to no other opcode — so the flag check deliberately sits
|
|
1066
|
+
// OUTSIDE the fExec guard below, which preserves that.
|
|
1067
|
+
if ((this.flags & Interpreter.SCRIPT_ENABLE_CHRONICLE) === 0) {
|
|
1068
|
+
this.errstr = 'SCRIPT_ERR_BAD_OPCODE'
|
|
1069
|
+
return false
|
|
1070
|
+
}
|
|
1071
|
+
fValue = false
|
|
1072
|
+
if (fExec) {
|
|
1073
|
+
if (this.stack.length < 1) {
|
|
1074
|
+
this.errstr = 'SCRIPT_ERR_UNBALANCED_CONDITIONAL'
|
|
1075
|
+
return false
|
|
1076
|
+
}
|
|
1077
|
+
if (this.tx == null) {
|
|
1078
|
+
this.errstr = 'SCRIPT_ERR_UNKNOWN_ERROR'
|
|
1079
|
+
return false
|
|
1080
|
+
}
|
|
1081
|
+
// Popping mirrors OP_IF. The spec describes the comparison but not the
|
|
1082
|
+
// stack effect; the OP_VERIF ... OP_ENDIF form it documents is an IF, and
|
|
1083
|
+
// an IF that left its condition behind would unbalance every script using
|
|
1084
|
+
// it. Pinned by its own test so a correction shows up as a diff.
|
|
1085
|
+
bn = BN.fromScriptNumBuffer(stacktop(-1), fRequireMinimal)
|
|
1086
|
+
fValue = bn.cmp(new BN(this.tx.version)) === 0
|
|
1087
|
+
if (opcodenum === Opcode.OP_VERNOTIF) {
|
|
1088
|
+
fValue = !fValue
|
|
1089
|
+
}
|
|
1090
|
+
this.stack.pop()
|
|
1091
|
+
}
|
|
1092
|
+
this.vfExec.push(fValue)
|
|
1093
|
+
break
|
|
1094
|
+
|
|
957
1095
|
case Opcode.OP_IF:
|
|
958
1096
|
case Opcode.OP_NOTIF:
|
|
959
1097
|
// <expression> if [statements] [else [statements]] endif
|
|
@@ -1356,6 +1494,8 @@ Interpreter.prototype.step = function () {
|
|
|
1356
1494
|
//
|
|
1357
1495
|
// Numeric
|
|
1358
1496
|
//
|
|
1497
|
+
case Opcode.OP_2MUL:
|
|
1498
|
+
case Opcode.OP_2DIV:
|
|
1359
1499
|
case Opcode.OP_1ADD:
|
|
1360
1500
|
case Opcode.OP_1SUB:
|
|
1361
1501
|
case Opcode.OP_NEGATE:
|
|
@@ -1370,6 +1510,16 @@ Interpreter.prototype.step = function () {
|
|
|
1370
1510
|
buf = stacktop(-1)
|
|
1371
1511
|
bn = BN.fromScriptNumBuffer(buf, fRequireMinimal)
|
|
1372
1512
|
switch (opcodenum) {
|
|
1513
|
+
case Opcode.OP_2MUL:
|
|
1514
|
+
bn = bn.mul(new BN(2))
|
|
1515
|
+
break
|
|
1516
|
+
case Opcode.OP_2DIV:
|
|
1517
|
+
// Truncates toward zero: -5 OP_2DIV is -2, not -3. That matches the
|
|
1518
|
+
// existing OP_DIV (bn1.div(bn2) on the same BN type), so `x OP_2DIV` and
|
|
1519
|
+
// `x 2 OP_DIV` agree. bn.js `shrn` is unusable here — it asserts on
|
|
1520
|
+
// negative values.
|
|
1521
|
+
bn = bn.div(new BN(2))
|
|
1522
|
+
break
|
|
1373
1523
|
case Opcode.OP_1ADD:
|
|
1374
1524
|
bn = bn.add(BN.One)
|
|
1375
1525
|
break
|
|
@@ -160,7 +160,23 @@ var sighashPreimage = function sighashPreimage (transaction, sighashType, inputN
|
|
|
160
160
|
sighashType = (newForkValue << 8) | (sighashType & 0xff)
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
// Chronicle: SIGHASH_CHRONICLE selects the Original Transaction Digest Algorithm —
|
|
164
|
+
// the path below — in preference to BIP-143.
|
|
165
|
+
//
|
|
166
|
+
// It has to OVERRIDE SIGHASH_FORKID rather than merely coexist with it. FORKID is
|
|
167
|
+
// set on essentially every BSV signature written since 2018, so a CHRONICLE bit that
|
|
168
|
+
// only took effect when FORKID was absent could never select OTDA in practice, and
|
|
169
|
+
// the flag would mean nothing.
|
|
170
|
+
//
|
|
171
|
+
// Gated on SCRIPT_ENABLE_CHRONICLE, which is off by default: before the upgrade the
|
|
172
|
+
// 0x20 bit means nothing, so BIP-143 signatures already exist whose type byte happens
|
|
173
|
+
// to set it. Honouring it unconditionally would reinterpret those as OTDA.
|
|
174
|
+
//
|
|
175
|
+
// Note the sighash type byte is committed INSIDE the preimage either way, so setting
|
|
176
|
+
// this bit changes the digest even where it does not change the algorithm.
|
|
177
|
+
if ((sighashType & Signature.SIGHASH_CHRONICLE) && (flags & Interpreter.SCRIPT_ENABLE_CHRONICLE)) {
|
|
178
|
+
// fall through to the original algorithm
|
|
179
|
+
} else if ((sighashType & Signature.SIGHASH_FORKID) && (flags & Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID)) {
|
|
164
180
|
return sighashPreimageForForkId(txcopy, sighashType, inputNumber, subscript, satoshisBN)
|
|
165
181
|
}
|
|
166
182
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartledger/bsv",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.8.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",
|