smartledger-bsv 3.1.1 → 3.2.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 +123 -1
- package/README.md +233 -277
- package/bsv.bundle.js +39 -0
- package/bsv.min.js +8 -8
- package/docs/ADVANCED_COVENANT_DEVELOPMENT.md +533 -0
- package/docs/COVENANT_DEVELOPMENT_RESOLVED.md +169 -0
- package/docs/CUSTOM_SCRIPT_DEVELOPMENT.md +320 -0
- package/docs/README.md +201 -0
- package/docs/block.md +46 -0
- package/docs/ecies.md +102 -0
- package/docs/index.md +104 -0
- package/docs/nchain.md +958 -0
- package/docs/networks.md +55 -0
- package/docs/preimage.md +126 -0
- package/docs/script.md +139 -0
- package/docs/transaction.md +174 -0
- package/docs/unspentoutput.md +32 -0
- package/examples/README.md +200 -0
- package/examples/basic/transaction-creation.js +534 -0
- package/examples/basic/transaction_signature_api_gap.js +178 -0
- package/examples/covenants/advanced_covenant_demo.js +219 -0
- package/examples/covenants/covenant_interface_demo.js +270 -0
- package/examples/covenants/covenant_manual_signature_resolved.js +212 -0
- package/examples/covenants/covenant_signature_template.js +117 -0
- package/examples/covenants2/covenant_bidirectional_example.js +262 -0
- package/examples/covenants2/covenant_utils_demo.js +120 -0
- package/examples/covenants2/preimage_covenant_utils.js +287 -0
- package/examples/covenants2/production_integration.js +256 -0
- package/examples/data/covenant_utxos.json +28 -0
- package/examples/data/utxos.json +26 -0
- package/examples/preimage/README.md +178 -0
- package/examples/preimage/extract_preimage_bidirectional.js +421 -0
- package/examples/preimage/generate_sample_preimage.js +208 -0
- package/examples/preimage/generate_sighash_examples.js +152 -0
- package/examples/preimage/parse_preimage.js +117 -0
- package/examples/preimage/test_preimage_extractor.js +53 -0
- package/examples/preimage/test_varint_extraction.js +95 -0
- package/examples/scripts/custom_script_helper_example.js +273 -0
- package/examples/scripts/custom_script_signature_test.js +344 -0
- package/examples/scripts/script_interpreter.js +193 -0
- package/examples/smart_contract/complete_workflow_demo.js +343 -0
- package/examples/smart_contract/covenant_builder_demo.js +176 -0
- package/examples/smart_contract/script_testing_integration.js +198 -0
- package/index.js +3 -0
- package/lib/covenant-interface.js +713 -0
- package/lib/opcode.js +14 -7
- package/lib/smart_contract/API_REFERENCE.md +862 -0
- package/lib/smart_contract/DOCUMENTATION_SUMMARY.md +201 -0
- package/lib/smart_contract/EXAMPLES.md +751 -0
- package/lib/smart_contract/QUICK_START.md +549 -0
- package/lib/smart_contract/README.md +395 -0
- package/lib/smart_contract/builder.js +452 -0
- package/lib/smart_contract/covenant.js +336 -0
- package/lib/smart_contract/covenant_builder.js +512 -0
- package/lib/smart_contract/index.js +350 -0
- package/lib/smart_contract/opcode_list.js +30 -0
- package/lib/smart_contract/opcode_map.js +1174 -0
- package/lib/smart_contract/opcodes.md +1173 -0
- package/lib/smart_contract/preimage.js +903 -0
- package/lib/smart_contract/script_interpreter.js +236 -0
- package/lib/smart_contract/script_tester.js +487 -0
- package/lib/smart_contract/script_utils.js +621 -0
- package/lib/smart_contract/sighash.js +310 -0
- package/lib/smart_contract/smartledger-opcode_review.md +70 -0
- package/lib/smart_contract/stack_examiner.js +129 -0
- package/lib/smart_contract/test_integration.js +269 -0
- package/lib/smart_contract/utxo_generator.js +367 -0
- package/package.json +43 -10
- 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
|
+
```
|