@bsv/sdk 1.0.0 → 1.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.
Files changed (123) hide show
  1. package/README.md +25 -3
  2. package/package.json +9 -5
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -40
  4. package/.github/ISSUE_TEMPLATE/discussion.md +0 -24
  5. package/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +0 -23
  6. package/CHANGELOG.md +0 -72
  7. package/CONTRIBUTING.md +0 -85
  8. package/ROADMAP.md +0 -3
  9. package/docs/getting-started/COMMONJS.md +0 -94
  10. package/docs/getting-started/REACT-TS.md +0 -131
  11. package/docs/getting-started/TS-NODE.md +0 -106
  12. package/docs/getting-started/VUE.md +0 -103
  13. package/jest.config.js +0 -6
  14. package/mod.ts +0 -8
  15. package/src/compat/BSM.ts +0 -51
  16. package/src/compat/ECIES.ts +0 -557
  17. package/src/compat/HD.ts +0 -348
  18. package/src/compat/Mnemonic.ts +0 -295
  19. package/src/compat/__tests/BSM.test.ts +0 -38
  20. package/src/compat/__tests/ECIES.test.ts +0 -90
  21. package/src/compat/__tests/HD.test.ts +0 -405
  22. package/src/compat/__tests/Mnemonic.test.ts +0 -177
  23. package/src/compat/__tests/Mnemonic.vectors.ts +0 -172
  24. package/src/compat/bip-39-wordlist-en.ts +0 -2053
  25. package/src/compat/index.ts +0 -4
  26. package/src/messages/EncryptedMessage.ts +0 -70
  27. package/src/messages/SignedMessage.ts +0 -87
  28. package/src/messages/__tests/EncryptedMessage.test.ts +0 -36
  29. package/src/messages/__tests/SignedMessage.test.ts +0 -53
  30. package/src/messages/index.ts +0 -2
  31. package/src/primitives/AESGCM.ts +0 -479
  32. package/src/primitives/BasePoint.ts +0 -21
  33. package/src/primitives/BigNumber.ts +0 -4619
  34. package/src/primitives/Curve.ts +0 -1163
  35. package/src/primitives/DRBG.ts +0 -102
  36. package/src/primitives/ECDSA.ts +0 -164
  37. package/src/primitives/Hash.ts +0 -1420
  38. package/src/primitives/JacobianPoint.ts +0 -410
  39. package/src/primitives/K256.ts +0 -116
  40. package/src/primitives/Mersenne.ts +0 -123
  41. package/src/primitives/MontgomoryMethod.ts +0 -160
  42. package/src/primitives/Point.ts +0 -852
  43. package/src/primitives/PrivateKey.ts +0 -195
  44. package/src/primitives/PublicKey.ts +0 -154
  45. package/src/primitives/Random.ts +0 -55
  46. package/src/primitives/ReductionContext.ts +0 -528
  47. package/src/primitives/Signature.ts +0 -235
  48. package/src/primitives/SymmetricKey.ts +0 -75
  49. package/src/primitives/TransactionSignature.ts +0 -189
  50. package/src/primitives/__tests/AESGCM.test.ts +0 -338
  51. package/src/primitives/__tests/BRC42.private.vectors.ts +0 -33
  52. package/src/primitives/__tests/BRC42.public.vectors.ts +0 -33
  53. package/src/primitives/__tests/BigNumber.arithmatic.test.ts +0 -572
  54. package/src/primitives/__tests/BigNumber.binary.test.ts +0 -203
  55. package/src/primitives/__tests/BigNumber.constructor.test.ts +0 -176
  56. package/src/primitives/__tests/BigNumber.dhGroup.test.ts +0 -18
  57. package/src/primitives/__tests/BigNumber.fixtures.ts +0 -264
  58. package/src/primitives/__tests/BigNumber.serializers.test.ts +0 -157
  59. package/src/primitives/__tests/BigNumber.utils.test.ts +0 -347
  60. package/src/primitives/__tests/Curve.unit.test.ts +0 -192
  61. package/src/primitives/__tests/DRBG.test.ts +0 -18
  62. package/src/primitives/__tests/DRBG.vectors.ts +0 -167
  63. package/src/primitives/__tests/ECDH.test.ts +0 -31
  64. package/src/primitives/__tests/ECDSA.test.ts +0 -58
  65. package/src/primitives/__tests/HMAC.test.ts +0 -59
  66. package/src/primitives/__tests/Hash.test.ts +0 -121
  67. package/src/primitives/__tests/PBKDF2.vectors.ts +0 -119
  68. package/src/primitives/__tests/PrivateKey.test.ts +0 -17
  69. package/src/primitives/__tests/PublicKey.test.ts +0 -66
  70. package/src/primitives/__tests/Random.test.ts +0 -14
  71. package/src/primitives/__tests/Reader.test.ts +0 -296
  72. package/src/primitives/__tests/ReductionContext.test.ts +0 -279
  73. package/src/primitives/__tests/SymmetricKey.test.ts +0 -58
  74. package/src/primitives/__tests/SymmetricKey.vectors.ts +0 -40
  75. package/src/primitives/__tests/Writer.test.ts +0 -198
  76. package/src/primitives/__tests/sighash.vectors.ts +0 -3503
  77. package/src/primitives/__tests/utils.test.ts +0 -108
  78. package/src/primitives/index.ts +0 -8
  79. package/src/primitives/utils.ts +0 -665
  80. package/src/script/LockingScript.ts +0 -30
  81. package/src/script/OP.ts +0 -219
  82. package/src/script/Script.ts +0 -426
  83. package/src/script/ScriptChunk.ts +0 -7
  84. package/src/script/ScriptTemplate.ts +0 -36
  85. package/src/script/Spend.ts +0 -1379
  86. package/src/script/UnlockingScript.ts +0 -30
  87. package/src/script/__tests/Script.test.ts +0 -369
  88. package/src/script/__tests/Spend.test.ts +0 -248
  89. package/src/script/__tests/script.invalid.vectors.ts +0 -925
  90. package/src/script/__tests/script.valid.vectors.ts +0 -1120
  91. package/src/script/__tests/scriptFromVector.ts +0 -42
  92. package/src/script/__tests/spend.valid.vectors.ts +0 -2288
  93. package/src/script/index.ts +0 -7
  94. package/src/script/templates/P2PKH.ts +0 -109
  95. package/src/script/templates/RPuzzle.ts +0 -140
  96. package/src/script/templates/index.ts +0 -2
  97. package/src/transaction/Broadcaster.ts +0 -42
  98. package/src/transaction/ChainTracker.ts +0 -22
  99. package/src/transaction/FeeModel.ts +0 -13
  100. package/src/transaction/MerklePath.ts +0 -259
  101. package/src/transaction/Transaction.ts +0 -602
  102. package/src/transaction/TransactionInput.ts +0 -63
  103. package/src/transaction/TransactionOutput.ts +0 -37
  104. package/src/transaction/__tests/MerklePath.test.ts +0 -181
  105. package/src/transaction/__tests/Transaction.test.ts +0 -413
  106. package/src/transaction/__tests/bigtx.vectors.ts +0 -4
  107. package/src/transaction/__tests/bump.invalid.vectors.ts +0 -8
  108. package/src/transaction/__tests/bump.valid.vectors.ts +0 -4
  109. package/src/transaction/__tests/tx.invalid.vectors.ts +0 -281
  110. package/src/transaction/__tests/tx.valid.vectors.ts +0 -364
  111. package/src/transaction/broadcasters/ARC.ts +0 -106
  112. package/src/transaction/broadcasters/__tests/ARC.test.ts +0 -115
  113. package/src/transaction/broadcasters/index.ts +0 -1
  114. package/src/transaction/fee-models/SatoshisPerKilobyte.ts +0 -71
  115. package/src/transaction/fee-models/index.ts +0 -1
  116. package/src/transaction/index.ts +0 -6
  117. package/ts2md.json +0 -5
  118. package/tsconfig.base.json +0 -26
  119. package/tsconfig.cjs.json +0 -11
  120. package/tsconfig.eslint.json +0 -12
  121. package/tsconfig.esm.json +0 -9
  122. package/tsconfig.json +0 -17
  123. package/tsconfig.types.json +0 -11
@@ -1,103 +0,0 @@
1
- # Getting Started with BSV SDK in a Vue TypeScript Project
2
-
3
- Welcome to the quick start guide for integrating the BSV SDK into your Vue TypeScript project. This guide will walk you through the setup and basic usage of the BSV SDK, enabling you to build scalable applications on the BSV Blockchain. Let’s dive into how you can add blockchain capabilities to your Vue application.
4
-
5
- ## Prerequisites
6
-
7
- Before starting, ensure you have the following installed:
8
- - Node.js (12.x or later)
9
- - npm (6.x or later)
10
- - Vue CLI (3.x or later)
11
-
12
- If you're new to Vue or TypeScript, it might be helpful to familiarize yourself with the basics of creating a Vue project with TypeScript support.
13
-
14
- ## Step 1: Create Your Vue Project
15
-
16
- If you haven't already, start by creating a new Vue project. Open your terminal and run:
17
-
18
- ```bash
19
- vue create my-bsv-app
20
- ```
21
-
22
- During the setup, choose "Manually select features" to select TypeScript. Follow the prompts to set up TypeScript with Vue.
23
-
24
- ## Step 2: Install the BSV SDK
25
-
26
- Navigate to your project directory in the terminal and install the BSV SDK by running:
27
-
28
- ```bash
29
- npm install @bsv/sdk
30
- ```
31
-
32
- This command will add the BSV SDK as a dependency to your project, making its functionality available for use in your Vue components.
33
-
34
- ## Step 3: Initialize the SDK in Your Vue Application
35
-
36
- Create a new file `bsvPlugin.ts` in your project's `src` directory. This file will set up the BSV SDK so that it can be easily used throughout your application.
37
-
38
- ```typescript
39
- // src/bsvPlugin.ts
40
-
41
- import { createApp } from 'vue';
42
- import App from './App.vue';
43
-
44
- // Import the SDK
45
- import * as BSV from '@bsv/sdk';
46
-
47
- const app = createApp(App);
48
-
49
- // Here you can add BSV SDK to Vue's global properties for easy access in components
50
- app.config.globalProperties.$bsv = BSV;
51
-
52
- app.mount('#app');
53
- ```
54
-
55
- Update your `main.ts` to use this new setup:
56
-
57
- ```typescript
58
- // src/main.ts
59
-
60
- import './bsvPlugin';
61
- ```
62
-
63
- ## Step 4: Using the BSV SDK in Your Components
64
-
65
- Now that you have the BSV SDK integrated into your Vue application, you can start using it in your components. Here's an example of how to create and sign a transaction within a Vue component:
66
-
67
- 1. **Create a new Vue component** `TransactionComponent.vue` in your `src/components` directory.
68
- 2. **Implement the BSV SDK logic** within your component:
69
-
70
- ```vue
71
- <template>
72
- <div>
73
- <h1>Create and Sign a Transaction</h1>
74
- <!-- Transaction form and submission button will go here -->
75
- </div>
76
- </template>
77
-
78
- <script lang="ts">
79
- import { defineComponent } from 'vue';
80
-
81
- export default defineComponent({
82
- name: 'TransactionComponent',
83
- methods: {
84
- async createAndSignTransaction() {
85
- // Access the BSV SDK from the global properties
86
- const BSV = this.$bsv;
87
-
88
- // Example: Creating a new PublicKey
89
- const privateKey = BSV.PrivateKey.fromRandom();
90
- const publicKey = privateKey.toPublicKey();
91
-
92
- console.log('PublicKey:', publicKey.toString());
93
-
94
- // Add your transaction logic here
95
- }
96
- }
97
- });
98
- </script>
99
- ```
100
-
101
- ## Step 5: Interacting with the Blockchain
102
-
103
- With the BSV SDK now part of your Vue application, you can extend the functionality as needed to interact with the BSV Blockchain. Use the SDK's comprehensive API to create transactions, manage keys, verify signatures, and much more.
package/jest.config.js DELETED
@@ -1,6 +0,0 @@
1
- /** @type {import('ts-jest').JestConfigWithTsJest} */
2
- export default {
3
- preset: 'ts-jest',
4
- testEnvironment: 'node',
5
- testPathIgnorePatterns: ['dist/']
6
- }
package/mod.ts DELETED
@@ -1,8 +0,0 @@
1
- export * from "./src/primitives/index.js"
2
- export * from "./src/script/index.js"
3
- export * from "./src/script/templates/index.js"
4
- export * from "./src/transaction/index.js"
5
- export * from "./src/transaction/fee-models/index.js"
6
- export * from "./src/transaction/broadcasters/index.js"
7
- export * from "./src/messages/index.js"
8
- export * from "./src/compat/index.js"
package/src/compat/BSM.ts DELETED
@@ -1,51 +0,0 @@
1
- import BigNumber from '../primitives/BigNumber.js'
2
- import { Writer, toArray } from '../primitives/utils.js'
3
- import * as ECDSA from '../primitives/ECDSA.js'
4
- import * as Hash from '../primitives/Hash.js'
5
- import PrivateKey from '../primitives/PrivateKey.js'
6
- import PublicKey from '../primitives/PublicKey.js'
7
- import Signature from '../primitives/Signature.js'
8
-
9
- const prefix = 'Bitcoin Signed Message:\n'
10
-
11
- /**
12
- * Generates a SHA256 double-hash of the prefixed message.
13
- * @deprecated Replaced by BRC-77 which uses a more secure and private method for message signing.
14
- * @param messageBuf The message buffer to be hashed.
15
- * @returns The double-hash of the prefixed message as a number array.
16
- */
17
- export const magicHash = (messageBuf: number[]): number[] => {
18
- const bw = new Writer()
19
- bw.writeVarIntNum(prefix.length)
20
- bw.write(toArray(prefix, 'utf8'))
21
- bw.writeVarIntNum(messageBuf.length)
22
- bw.write(messageBuf)
23
- const buf = bw.toArray()
24
- const hashBuf = Hash.hash256(buf) as number[]
25
- return hashBuf
26
- }
27
-
28
- /**
29
- * Signs a BSM message using the given private key.
30
- * @deprecated Replaced by BRC-77 which employs BRC-42 key derivation and BRC-43 invoice numbers for enhanced security and privacy.
31
- * @param message The message to be signed as a number array.
32
- * @param privateKey The private key used for signing the message.
33
- * @returns The signature object.
34
- */
35
- export const sign = (message: number[], privateKey: PrivateKey): Signature => {
36
- const hashBuf = magicHash(message)
37
- return ECDSA.sign(new BigNumber(hashBuf), privateKey, true)
38
- }
39
-
40
- /**
41
- * Verifies a BSM signed message using the given public key.
42
- * @deprecated Replaced by BRC-77 which provides privately-verifiable signatures and avoids key reuse.
43
- * @param message The message to be verified as a number array.
44
- * @param sig The signature object.
45
- * @param pubKey The public key for verification.
46
- * @returns True if the signature is valid, false otherwise.
47
- */
48
- export const verify = (message: number[], sig: Signature, pubKey: PublicKey): boolean => {
49
- const hashBuf = magicHash(message)
50
- return ECDSA.verify(new BigNumber(hashBuf), sig, pubKey)
51
- }