@bsv/sdk 1.4.11 → 1.4.13
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/dist/cjs/package.json +3 -1
- package/dist/cjs/src/primitives/index.js +3 -1
- package/dist/cjs/src/primitives/index.js.map +1 -1
- package/dist/cjs/src/registry/RegistryClient.js +5 -5
- package/dist/cjs/src/registry/RegistryClient.js.map +1 -1
- package/dist/cjs/src/transaction/Transaction.js +2 -2
- package/dist/cjs/src/transaction/Transaction.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/primitives/index.js +1 -0
- package/dist/esm/src/primitives/index.js.map +1 -1
- package/dist/esm/src/registry/RegistryClient.js +5 -5
- package/dist/esm/src/registry/RegistryClient.js.map +1 -1
- package/dist/esm/src/transaction/Transaction.js +2 -2
- package/dist/esm/src/transaction/Transaction.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/primitives/index.d.ts +1 -0
- package/dist/types/src/primitives/index.d.ts.map +1 -1
- package/dist/types/src/registry/RegistryClient.d.ts.map +1 -1
- package/dist/types/src/transaction/Transaction.d.ts +1 -1
- package/dist/types/src/transaction/Transaction.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/package.json +3 -1
- package/src/primitives/__tests/ECDH.test.ts +2 -2
- package/src/primitives/index.ts +1 -0
- package/src/registry/RegistryClient.ts +6 -6
- package/src/transaction/Transaction.ts +2 -2
- package/src/transaction/__tests/Transaction.test.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsv/sdk",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "BSV Blockchain Software Development Kit",
|
|
6
6
|
"main": "dist/cjs/mod.js",
|
|
@@ -230,7 +230,9 @@
|
|
|
230
230
|
"homepage": "https://github.com/bitcoin-sv/ts-sdk#readme",
|
|
231
231
|
"devDependencies": {
|
|
232
232
|
"@eslint/js": "^9.19.0",
|
|
233
|
+
"@jest/globals": "^29.7.0",
|
|
233
234
|
"@types/jest": "^29.5.14",
|
|
235
|
+
"@types/node": "^22.13.14",
|
|
234
236
|
"eslint": "^8.57.1",
|
|
235
237
|
"globals": "^15.14.0",
|
|
236
238
|
"jest": "^29.7.0",
|
|
@@ -12,12 +12,12 @@ describe('ECDH', function () {
|
|
|
12
12
|
expect(sh1.toString()).toEqual(sh2.toString())
|
|
13
13
|
sh1 = s1.deriveSharedSecret(
|
|
14
14
|
PublicKey.fromString(
|
|
15
|
-
|
|
15
|
+
s2.toPublicKey().toDER('hex') as string
|
|
16
16
|
)
|
|
17
17
|
)
|
|
18
18
|
sh2 = s2.deriveSharedSecret(
|
|
19
19
|
PublicKey.fromString(
|
|
20
|
-
|
|
20
|
+
s1.toPublicKey().toDER('hex') as string
|
|
21
21
|
)
|
|
22
22
|
)
|
|
23
23
|
|
package/src/primitives/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { default as PublicKey } from './PublicKey.js'
|
|
|
5
5
|
export { default as Signature } from './Signature.js'
|
|
6
6
|
export { default as PrivateKey, KeyShares } from './PrivateKey.js'
|
|
7
7
|
export { default as SymmetricKey } from './SymmetricKey.js'
|
|
8
|
+
export { default as DRBG } from './DRBG.js'
|
|
8
9
|
export * as ECDSA from './ECDSA.js'
|
|
9
10
|
export * as Utils from './utils.js'
|
|
10
11
|
export * as Hash from './Hash.js'
|
|
@@ -199,6 +199,12 @@ export class RegistryClient {
|
|
|
199
199
|
throw new Error('Invalid registry record. Missing txid, outputIndex, or lockingScript.')
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
// Check if the registry record belongs to the current user
|
|
203
|
+
const currentIdentityKey = (await this.wallet.getPublicKey({ identityKey: true })).publicKey
|
|
204
|
+
if (registryRecord.registryOperator !== currentIdentityKey) {
|
|
205
|
+
throw new Error('This registry token does not belong to the current wallet.')
|
|
206
|
+
}
|
|
207
|
+
|
|
202
208
|
// Create a descriptive label for the item we’re revoking
|
|
203
209
|
const itemIdentifier =
|
|
204
210
|
registryRecord.definitionType === 'basket'
|
|
@@ -421,12 +427,6 @@ export class RegistryClient {
|
|
|
421
427
|
throw new Error(`Unsupported definition type: ${definitionType as string}`)
|
|
422
428
|
}
|
|
423
429
|
|
|
424
|
-
// Enforce that the pushdrop belongs to the CURRENT identity key
|
|
425
|
-
const currentIdentityKey = (await this.wallet.getPublicKey({ identityKey: true })).publicKey
|
|
426
|
-
if (registryOperator !== currentIdentityKey) {
|
|
427
|
-
throw new Error('This registry token does not belong to the current wallet.')
|
|
428
|
-
}
|
|
429
|
-
|
|
430
430
|
// Return the typed data plus the operator key
|
|
431
431
|
return { ...parsedData, registryOperator }
|
|
432
432
|
}
|
|
@@ -403,7 +403,7 @@ export default class Transaction {
|
|
|
403
403
|
|
|
404
404
|
/**
|
|
405
405
|
* Computes fees prior to signing.
|
|
406
|
-
* If no fee model is provided, uses a SatoshisPerKilobyte fee model that pays
|
|
406
|
+
* If no fee model is provided, uses a SatoshisPerKilobyte fee model that pays 1 sat/kb.
|
|
407
407
|
* If fee is a number, the transaction uses that value as fee.
|
|
408
408
|
*
|
|
409
409
|
* @param modelOrFee - The initialized fee model to use or fixed fee for the transaction
|
|
@@ -412,7 +412,7 @@ export default class Transaction {
|
|
|
412
412
|
*
|
|
413
413
|
*/
|
|
414
414
|
async fee (
|
|
415
|
-
modelOrFee: FeeModel | number = new SatoshisPerKilobyte(
|
|
415
|
+
modelOrFee: FeeModel | number = new SatoshisPerKilobyte(1),
|
|
416
416
|
changeDistribution: 'equal' | 'random' = 'equal'
|
|
417
417
|
): Promise<void> {
|
|
418
418
|
this.cachedHash = undefined
|
|
@@ -348,9 +348,9 @@ describe('Transaction', () => {
|
|
|
348
348
|
expect(spendTx.outputs[1].satoshis).not.toBeDefined()
|
|
349
349
|
await spendTx.fee()
|
|
350
350
|
// Transaction size is 225 bytes for one-input two-output P2PKH.
|
|
351
|
-
// Default fee rate is
|
|
352
|
-
// 4000 sats in - 1000 sats out - 3 sats fee = expected
|
|
353
|
-
expect(spendTx.outputs[1].satoshis).toEqual(
|
|
351
|
+
// Default fee rate is 1 sat/kb = 0.225 sats (round up to 1).
|
|
352
|
+
// 4000 sats in - 1000 sats out - 3 sats fee = expected 2999 sats change.
|
|
353
|
+
expect(spendTx.outputs[1].satoshis).toEqual(2999)
|
|
354
354
|
})
|
|
355
355
|
it('Computes fees with a custom fee model', async () => {
|
|
356
356
|
const privateKey = new PrivateKey(1)
|