@smartledger/bsv 3.4.5 → 4.0.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 +184 -0
- package/README.md +40 -40
- package/SECURITY.md +6 -3
- package/bsv-covenant.min.js +7 -7
- package/bsv-ecies.min.js +1 -1
- package/bsv-gdaf.min.js +8 -8
- package/bsv-ltp.min.js +8 -8
- package/bsv-smartcontract.min.js +8 -8
- package/bsv.bundle.js +8 -8
- package/bsv.min.js +7 -7
- package/docs/COVENANT_DEVELOPMENT_RESOLVED.md +2 -2
- package/docs/MODULE_REFERENCE_COMPLETE.md +27 -27
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +1 -1
- package/docs/getting-started/INSTALLATION.md +25 -25
- package/docs/getting-started/QUICK_START.md +7 -7
- package/docs/migration/FROM_BSV_1_5_6.md +5 -5
- package/index.js +29 -1
- package/lib/crypto/ecdsa.js +10 -27
- package/lib/ecies/electrum-ecies.js +12 -1
- package/lib/gdaf/attestation-signer.js +37 -2
- package/lib/gdaf/attestation-verifier.js +48 -10
- package/lib/smart_contract/utxo_generator.js +9 -4
- package/lib/smartutxo.js +44 -17
- package/package.json +1 -4
- package/utilities/wallet.json +0 -30
package/lib/smartutxo.js
CHANGED
|
@@ -1,8 +1,29 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* SmartLedger UTXO Management System
|
|
5
|
-
*
|
|
4
|
+
* SmartLedger UTXO Management System — DEVELOPMENT ONLY
|
|
5
|
+
* =====================================================
|
|
6
|
+
*
|
|
7
|
+
* `SmartUTXOManager` is a file-backed wallet/UTXO simulator intended for
|
|
8
|
+
* local testing and example scripts. It persists state to
|
|
9
|
+
* `<package-root>/utilities/blockchain-state.json`, has no concurrency
|
|
10
|
+
* controls (multiple processes will race on the same file), and ships
|
|
11
|
+
* with an empty seed for npm consumers (the 3.3 MB development fixture
|
|
12
|
+
* is `.npmignore`d). Do NOT use it as a production UTXO manager —
|
|
13
|
+
* production wallets should track UTXOs themselves and never rely on a
|
|
14
|
+
* shared file inside `node_modules`.
|
|
15
|
+
*
|
|
16
|
+
* Supported import path (works in any consumer):
|
|
17
|
+
*
|
|
18
|
+
* const SmartUTXO = require('@smartledger/bsv/lib/smartutxo')
|
|
19
|
+
*
|
|
20
|
+
* Or, from within the smartledger-bsv repo:
|
|
21
|
+
*
|
|
22
|
+
* const SmartUTXO = require('./lib/smartutxo')
|
|
23
|
+
*
|
|
24
|
+
* The legacy `bsv.SmartUTXO` namespace export was soft-deprecated in
|
|
25
|
+
* v4.0.1 (logs a one-shot warning on access) and will be removed in
|
|
26
|
+
* v5.0.0.
|
|
6
27
|
*/
|
|
7
28
|
|
|
8
29
|
// Set BSV_DEBUG=1 (Node) or window.BSV_DEBUG = true (browser) to surface
|
|
@@ -119,31 +140,37 @@ class SmartUTXOManager {
|
|
|
119
140
|
}
|
|
120
141
|
|
|
121
142
|
/**
|
|
122
|
-
* Create mock UTXOs for testing
|
|
123
|
-
*
|
|
143
|
+
* Create mock UTXOs for testing. Each mock has a fresh random txid and
|
|
144
|
+
* a P2PKH locking script that actually encodes the provided address
|
|
145
|
+
* (so any private key for `address` can sign against the resulting
|
|
146
|
+
* `script` via the high-level API).
|
|
147
|
+
*
|
|
148
|
+
* This is a pure factory — the returned UTXOs are NOT added to the
|
|
149
|
+
* simulator state. Call `.addUTXO(...)` on each one to persist them.
|
|
150
|
+
*
|
|
151
|
+
* @param {string} address - Target address (livenet or testnet)
|
|
124
152
|
* @param {number} count - Number of UTXOs to create
|
|
125
153
|
* @param {number} satoshis - Satoshis per UTXO
|
|
126
154
|
* @returns {Array} Array of created UTXOs
|
|
127
155
|
*/
|
|
128
156
|
createMockUTXOs(address, count = 5, satoshis = 100000) {
|
|
157
|
+
// Use bsv's own RNG so this works in both Node and browser builds
|
|
158
|
+
// (the Node `crypto` import above is undefined in browser context).
|
|
159
|
+
const bsv = require('../')
|
|
160
|
+
const lockingScriptHex = bsv.Script.buildPublicKeyHashOut(
|
|
161
|
+
bsv.Address.fromString(address)
|
|
162
|
+
).toHex()
|
|
163
|
+
|
|
129
164
|
const mockUTXOs = []
|
|
130
|
-
|
|
131
165
|
for (let i = 0; i < count; i++) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const utxo = {
|
|
137
|
-
txid,
|
|
138
|
-
vout,
|
|
166
|
+
mockUTXOs.push({
|
|
167
|
+
txid: bsv.crypto.Random.getRandomBuffer(32).toString('hex'),
|
|
168
|
+
vout: i,
|
|
139
169
|
address,
|
|
140
170
|
satoshis,
|
|
141
|
-
script
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
mockUTXOs.push(utxo)
|
|
171
|
+
script: lockingScriptHex
|
|
172
|
+
})
|
|
145
173
|
}
|
|
146
|
-
|
|
147
174
|
return mockUTXOs
|
|
148
175
|
}
|
|
149
176
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartledger/bsv",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.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",
|
|
@@ -74,7 +74,6 @@
|
|
|
74
74
|
"lib/",
|
|
75
75
|
"utilities/*.js",
|
|
76
76
|
"utilities/README.md",
|
|
77
|
-
"utilities/wallet.json",
|
|
78
77
|
"ecies/",
|
|
79
78
|
"message/",
|
|
80
79
|
"mnemonic/",
|
|
@@ -132,7 +131,6 @@
|
|
|
132
131
|
"debug-tools",
|
|
133
132
|
"modular-loading",
|
|
134
133
|
"standalone-modules",
|
|
135
|
-
"security-hardened",
|
|
136
134
|
"elliptic-curve-fix",
|
|
137
135
|
"smartledger",
|
|
138
136
|
"transaction",
|
|
@@ -184,7 +182,6 @@
|
|
|
184
182
|
"webpack-ready",
|
|
185
183
|
"cdn-ready",
|
|
186
184
|
"typescript-definitions",
|
|
187
|
-
"vulnerability-free",
|
|
188
185
|
"drop-in-replacement",
|
|
189
186
|
"performance-optimized",
|
|
190
187
|
"bip21",
|
package/utilities/wallet.json
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"wallet": {
|
|
3
|
-
"privateKeyWIF": "KwbaQqFUpt9MYQRrkVWk7QC799nAfcqYRYKj4ZNeZBkut3YP45rJ",
|
|
4
|
-
"privateKeyHex": "KwbaQqFUpt9MYQRrkVWk7QC799nAfcqYRYKj4ZNeZBkut3YP45rJ",
|
|
5
|
-
"publicKey": "02330726b97010d7bb1f88b1213330e644916cedfd5fee9c57153592c6b5a44fe9",
|
|
6
|
-
"address": "15XJXD7CSMqHL2ivFCu8PZTACQQ8MPbWY9",
|
|
7
|
-
"pubkeyHash160": "319b9b8eef10d00cf84b5d4772dca69b5f5a7b5c"
|
|
8
|
-
},
|
|
9
|
-
"utxo": {
|
|
10
|
-
"txid": "d6625d13f3130360dea7ebe8ccf8ccdb5e40b3cd5ea51b2094983a3789354c3e",
|
|
11
|
-
"vout": 0,
|
|
12
|
-
"outputIndex": 0,
|
|
13
|
-
"script": "76a914319b9b8eef10d00cf84b5d4772dca69b5f5a7b5c88ac",
|
|
14
|
-
"scriptPubKey": "76a914319b9b8eef10d00cf84b5d4772dca69b5f5a7b5c88ac",
|
|
15
|
-
"satoshis": 50000,
|
|
16
|
-
"address": "15XJXD7CSMqHL2ivFCu8PZTACQQ8MPbWY9"
|
|
17
|
-
},
|
|
18
|
-
"testParams": {
|
|
19
|
-
"nLockTimeTarget": 1000,
|
|
20
|
-
"sighashType": 65,
|
|
21
|
-
"covenantAmount": 40000,
|
|
22
|
-
"fee": 1000,
|
|
23
|
-
"changeAmount": 9000
|
|
24
|
-
},
|
|
25
|
-
"metadata": {
|
|
26
|
-
"created": "2025-10-19T14:33:10.987Z",
|
|
27
|
-
"description": "Test wallet and UTXO for BSV preimage covenant testing",
|
|
28
|
-
"version": "1.0"
|
|
29
|
-
}
|
|
30
|
-
}
|