smartledger-bsv 3.1.1 → 3.2.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +123 -1
  2. package/README.md +233 -277
  3. package/bsv.bundle.js +39 -0
  4. package/bsv.min.js +8 -8
  5. package/docs/ADVANCED_COVENANT_DEVELOPMENT.md +533 -0
  6. package/docs/COVENANT_DEVELOPMENT_RESOLVED.md +169 -0
  7. package/docs/CUSTOM_SCRIPT_DEVELOPMENT.md +320 -0
  8. package/docs/README.md +201 -0
  9. package/docs/block.md +46 -0
  10. package/docs/ecies.md +102 -0
  11. package/docs/index.md +104 -0
  12. package/docs/nchain.md +958 -0
  13. package/docs/networks.md +55 -0
  14. package/docs/preimage.md +126 -0
  15. package/docs/script.md +139 -0
  16. package/docs/transaction.md +174 -0
  17. package/docs/unspentoutput.md +32 -0
  18. package/examples/README.md +200 -0
  19. package/examples/basic/transaction-creation.js +534 -0
  20. package/examples/basic/transaction_signature_api_gap.js +178 -0
  21. package/examples/covenants/advanced_covenant_demo.js +219 -0
  22. package/examples/covenants/covenant_interface_demo.js +270 -0
  23. package/examples/covenants/covenant_manual_signature_resolved.js +212 -0
  24. package/examples/covenants/covenant_signature_template.js +117 -0
  25. package/examples/covenants2/covenant_bidirectional_example.js +262 -0
  26. package/examples/covenants2/covenant_utils_demo.js +120 -0
  27. package/examples/covenants2/preimage_covenant_utils.js +287 -0
  28. package/examples/covenants2/production_integration.js +256 -0
  29. package/examples/data/covenant_utxos.json +28 -0
  30. package/examples/data/utxos.json +26 -0
  31. package/examples/preimage/README.md +178 -0
  32. package/examples/preimage/extract_preimage_bidirectional.js +421 -0
  33. package/examples/preimage/generate_sample_preimage.js +208 -0
  34. package/examples/preimage/generate_sighash_examples.js +152 -0
  35. package/examples/preimage/parse_preimage.js +117 -0
  36. package/examples/preimage/test_preimage_extractor.js +53 -0
  37. package/examples/preimage/test_varint_extraction.js +95 -0
  38. package/examples/scripts/custom_script_helper_example.js +273 -0
  39. package/examples/scripts/custom_script_signature_test.js +344 -0
  40. package/examples/scripts/script_interpreter.js +193 -0
  41. package/examples/smart_contract/complete_workflow_demo.js +343 -0
  42. package/examples/smart_contract/covenant_builder_demo.js +176 -0
  43. package/examples/smart_contract/script_testing_integration.js +198 -0
  44. package/index.js +3 -0
  45. package/lib/covenant-interface.js +713 -0
  46. package/lib/opcode.js +14 -7
  47. package/lib/smart_contract/API_REFERENCE.md +754 -0
  48. package/lib/smart_contract/DOCUMENTATION_SUMMARY.md +201 -0
  49. package/lib/smart_contract/EXAMPLES.md +751 -0
  50. package/lib/smart_contract/QUICK_START.md +549 -0
  51. package/lib/smart_contract/README.md +395 -0
  52. package/lib/smart_contract/builder.js +452 -0
  53. package/lib/smart_contract/covenant.js +336 -0
  54. package/lib/smart_contract/covenant_builder.js +512 -0
  55. package/lib/smart_contract/index.js +311 -0
  56. package/lib/smart_contract/opcode_list.js +30 -0
  57. package/lib/smart_contract/opcode_map.js +1174 -0
  58. package/lib/smart_contract/opcodes.md +1173 -0
  59. package/lib/smart_contract/preimage.js +903 -0
  60. package/lib/smart_contract/script_tester.js +487 -0
  61. package/lib/smart_contract/script_utils.js +609 -0
  62. package/lib/smart_contract/sighash.js +310 -0
  63. package/lib/smart_contract/smartledger-opcode_review.md +70 -0
  64. package/lib/smart_contract/test_integration.js +269 -0
  65. package/lib/smart_contract/utxo_generator.js +367 -0
  66. package/package.json +43 -10
  67. package/utilities/blockchain-state.json +20478 -3
package/docs/index.md ADDED
@@ -0,0 +1,104 @@
1
+ # bsv v0.21.0
2
+
3
+ ## Principles
4
+
5
+ Bitcoin is a powerful new peer-to-peer platform for the next generation of financial technology. The decentralized nature of the Bitcoin network allows for highly resilient bitcoin infrastructure, and the developer community needs reliable, open-source tools to implement bitcoin apps and services. Bitcore provides a reliable API for JavaScript apps that need to interface with Bitcoin.
6
+
7
+ To get started, just `npm install bsv` or `bower install bsv`.
8
+
9
+ # Documentation Index
10
+
11
+ ## Addresses and Key Management
12
+
13
+ * [Addresses](address.md)
14
+ * [Using Different Networks](networks.md)
15
+ * [Private Keys](privatekey.md) and [Public Keys](publickey.md)
16
+ * [Hierarchically-derived Private and Public Keys](hierarchical.md)
17
+
18
+ ## Payment Handling
19
+ * [Using Different Units](unit.md)
20
+ * [Acknowledging and Requesting Payments: Bitcoin URIs](uri.md)
21
+ * [The Transaction Class](transaction.md)
22
+
23
+ ## Bitcoin Internals
24
+ * [Scripts](script.md)
25
+ * [Block](block.md)
26
+
27
+ ## Extra
28
+ * [Crypto](crypto.md)
29
+ * [Encoding](encoding.md)
30
+
31
+ ## Module Development
32
+ * [Browser Builds](browser.md)
33
+
34
+ ## Modules
35
+
36
+ Some functionality is implemented as a module that can be installed separately:
37
+
38
+ * [Payment Protocol Support](https://github.com/bitpay/bsv-payment-protocol)
39
+ * [Peer to Peer Networking](https://github.com/bitpay/bsv-p2p)
40
+ * [Bitcoin Core JSON-RPC](https://github.com/bitpay/bitcoind-rpc)
41
+ * [Payment Channels](https://github.com/bitpay/bsv-channel)
42
+ * [Mnemonics](https://github.com/bitpay/bsv-mnemonic)
43
+ * [Elliptical Curve Integrated Encryption Scheme](https://github.com/bitpay/bsv-ecies)
44
+ * [Blockchain Explorers](https://github.com/bitpay/bsv-explorers)
45
+ * [Signed Messages](https://github.com/bitpay/bsv-message)
46
+
47
+ # Examples
48
+
49
+ ## Create and Save a Private Key
50
+
51
+ ```javascript
52
+ var privateKey = new bsv.PrivateKey();
53
+
54
+ var exported = privateKey.toWIF();
55
+ // e.g. L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m
56
+ var imported = bsv.PrivateKey.fromWIF(exported);
57
+ var hexa = privateKey.toString();
58
+ // e.g. 'b9de6e778fe92aa7edb69395556f843f1dce0448350112e14906efc2a80fa61a'
59
+ ```
60
+
61
+ ## Create an Address
62
+
63
+ ```javascript
64
+ var address = privateKey.toAddress();
65
+ ```
66
+
67
+ ## Create a Multisig Address
68
+
69
+ ```javascript
70
+ // Build a 2-of-3 address from public keys
71
+ var p2shAddress = new bsv.Address([publicKey1, publicKey2, publicKey3], 2);
72
+ ```
73
+
74
+ ## Request a Payment
75
+
76
+ ```javascript
77
+ var paymentInfo = {
78
+ address: '1DNtTk4PUCGAdiNETAzQFWZiy2fCHtGnPx',
79
+ amount: 120000 //satoshis
80
+ };
81
+ var uri = new bsv.URI(paymentInfo).toString();
82
+ ```
83
+
84
+ ## Create a Transaction
85
+
86
+ ```javascript
87
+ var transaction = new Transaction()
88
+ .from(utxos) // Feed information about what unspent outputs one can use
89
+ .to(address, amount) // Add an output with the given amount of satoshis
90
+ .change(address) // Sets up a change address where the rest of the funds will go
91
+ .sign(privkeySet) // Signs all the inputs it can
92
+ ```
93
+
94
+ ## Connect to the Network
95
+
96
+ ```javascript
97
+ var peer = new Peer('5.9.85.34');
98
+
99
+ peer.on('inv', function(message) {
100
+ // new inventory
101
+ });
102
+
103
+ peer.connect();
104
+ ```