@psf/bch-js 6.8.2 → 7.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/README.md +10 -28
- package/fix-docs-contrast.sh +38 -0
- package/llm-bch-js.md +10451 -0
- package/package.json +37 -46
- package/src/address.js +12 -23
- package/src/bch-js.js +81 -48
- package/src/bitcoincash.js +10 -11
- package/src/blockchain.js +57 -68
- package/src/control.js +11 -22
- package/src/crypto.js +3 -3
- package/src/dsproof.js +6 -17
- package/src/ecash.js +1 -1
- package/src/ecpair.js +3 -3
- package/src/electrumx.js +32 -44
- package/src/encryption.js +8 -17
- package/src/generating.js +8 -19
- package/src/hdnode.js +5 -5
- package/src/mining.js +11 -22
- package/src/mnemonic.js +8 -11
- package/src/price.js +7 -108
- package/src/psf-slp-indexer.js +21 -32
- package/src/raw-transactions.js +22 -35
- package/src/schnorr.js +5 -16
- package/src/script.js +4 -2
- package/src/slp/address.js +4 -4
- package/src/slp/ecpair.js +4 -4
- package/src/slp/nft1.js +6 -6
- package/src/slp/slp.js +11 -22
- package/src/slp/tokentype1.js +11 -22
- package/src/slp/utils.js +9 -19
- package/src/transaction-builder.js +5 -5
- package/src/transaction.js +5 -5
- package/src/util.js +5 -98
- package/src/utxo.js +6 -6
- package/test/e2e/bch-js-e2e-tests.js +4 -3
- package/test/e2e/ipfs/ipfs-e2e.js +8 -2
- package/test/e2e/rate-limits/anonymous-rate-limits.js +5 -4
- package/test/e2e/rate-limits/basic-auth-rate-limits.js +4 -3
- package/test/e2e/rate-limits/free-rate-limits.js +4 -3
- package/test/e2e/rate-limits/full-node-rate-limits.js +4 -3
- package/test/e2e/rate-limits/indexer-rate-limits.js +4 -3
- package/test/e2e/send-raw-transaction-bulk/sendrawtransaction.js +28 -18
- package/test/e2e/send-raw-transaction-single/sendrawtransaction.js +28 -18
- package/test/e2e/send-token/send-token.js +4 -4
- package/test/e2e/util/e2e-util.js +6 -3
- package/test/e2e/utxo/unsynced-indexer.js +1 -1
- package/test/integration/blockchain.js +5 -5
- package/test/integration/control.js +2 -2
- package/test/integration/{chains/bchn/dsproof.js → dsproof.js} +6 -2
- package/test/integration/electrumx.js +5 -12
- package/test/integration/price.js +3 -39
- package/test/integration/{chains/bchn/psf-slp-indexer.integration.js → psf-slp-indexer.integration.js} +5 -6
- package/test/integration/rawtransaction.js +39 -5
- package/test/integration/slp.js +147 -5
- package/test/integration/transaction-integration.js +27 -2
- package/test/integration/{chains/bchn/utxo-integration.js → utxo-integration.js} +3 -2
- package/test/unit/address.js +7 -4
- package/test/unit/bitcoin-cash.js +5 -3
- package/test/unit/blockchain.js +23 -22
- package/test/unit/control.js +6 -6
- package/test/unit/crypto.js +5 -3
- package/test/unit/dsproof.js +5 -4
- package/test/unit/ecash.js +3 -2
- package/test/unit/ecpairs.js +6 -4
- package/test/unit/electrumx.js +7 -7
- package/test/unit/encryption.js +6 -5
- package/test/unit/fixtures/bitcore-mock.js +1 -1
- package/test/unit/fixtures/block-mock.js +1 -1
- package/test/unit/fixtures/blockchain-mock.js +1 -1
- package/test/unit/fixtures/dsproof-mock.js +1 -1
- package/test/unit/fixtures/electrumx-mock.js +1 -1
- package/test/unit/fixtures/encryption-mock.js +1 -1
- package/test/unit/fixtures/ipfs-mock.js +1 -1
- package/test/unit/fixtures/openbazaar-mock.js +1 -1
- package/test/unit/fixtures/price-mocks.js +1 -1
- package/test/unit/fixtures/psf-slp-indexer-mock.js +1 -1
- package/test/unit/fixtures/rawtransaction-mock.js +1 -1
- package/test/unit/fixtures/slp/mock-utils.js +1 -1
- package/test/unit/fixtures/transaction-mock.js +1 -1
- package/test/unit/fixtures/utxo-mocks.js +1 -1
- package/test/unit/generating.js +5 -5
- package/test/unit/hdnode.js +6 -4
- package/test/unit/mining.js +8 -8
- package/test/unit/mnemonic.js +4 -2
- package/test/unit/price.js +5 -14
- package/test/unit/psf-slp-indexer.js +7 -7
- package/test/unit/raw-tranactions.js +14 -13
- package/test/unit/scripts.js +8 -6
- package/test/unit/slp-address.js +6 -4
- package/test/unit/slp-ecpair.js +5 -3
- package/test/unit/slp-nft1.js +7 -6
- package/test/unit/slp-tokentype1.js +7 -6
- package/test/unit/slp-utils.js +8 -7
- package/test/unit/transaction-builder.js +7 -4
- package/test/unit/transaction-unit.js +5 -4
- package/test/unit/util.js +11 -32
- package/test/unit/utxo-unit.js +6 -5
- package/test/unit/x402.js +193 -0
- package/test/integration/chains/abc/psf-slp-indexer-integration.js +0 -38
- package/test/integration/chains/abc/rawtransaction.js +0 -73
- package/test/integration/chains/abc/utxo-integration.js +0 -38
- package/test/integration/chains/bchn/rawtransaction.js +0 -71
- package/test/integration/chains/bchn/slp.js +0 -301
- package/test/integration/chains/bchn/transaction-integration.js +0 -37
- package/test/integration/chains/bchn/util.js +0 -103
- package/test/integration/chains/testnet/blockchain.js +0 -260
- package/test/integration/chains/testnet/control.js +0 -32
- package/test/integration/chains/testnet/electrumx.js +0 -376
- package/test/integration/chains/testnet/rawtransaction.js +0 -296
- package/test/integration/chains/testnet/slp.js +0 -172
- package/test/integration/chains/testnet/test-free-tier.sh +0 -9
- package/test/integration/chains/testnet/util.js +0 -109
package/README.md
CHANGED
|
@@ -5,23 +5,21 @@
|
|
|
5
5
|
[](https://github.com/Permissionless-Software-Foundation/bch-js/blob/master/LICENSE.md)
|
|
6
6
|
[](https://github.com/feross/standard) [](https://gitter.im/Permissionless-Software-Foundation/bch-js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
7
7
|
|
|
8
|
-
[bch-js](https://www.npmjs.com/package/@psf/bch-js) is a JavaScript npm library for creating web and mobile apps that can interact with the Bitcoin Cash (BCH)
|
|
8
|
+
[bch-js](https://www.npmjs.com/package/@psf/bch-js) is a JavaScript npm library for creating web and mobile apps that can interact with the Bitcoin Cash (BCH) blockchain. bch-js contains a toolbox of handy tools, and an easy API for talking with [psf-bch-api REST API](https://github.com/Permissionless-Software-Foundation/psf-bch-api). [FullStack.cash](https://fullstack.cash) offers paid cloud access to psf-bch-api. You can run your own infrastructure by following documentation on [CashStack.info](https://cashstack.info).
|
|
9
9
|
|
|
10
10
|
### Quick Start Videos:
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
YouTube walk-through videos to help you get started:
|
|
13
13
|
|
|
14
14
|
- [Introduction to bch-js and the bch-js-examples repository](https://youtu.be/GD2i1ZUiyrk)
|
|
15
|
-
- [Working with the FullStack.cash JWT token](https://youtu.be/GD2i1ZUiyrk)
|
|
16
15
|
|
|
17
16
|
### Quick Links
|
|
18
17
|
|
|
19
18
|
- [npm Library](https://www.npmjs.com/package/@psf/bch-js)
|
|
20
19
|
- [Documentation](https://bchjs.fullstack.cash/)
|
|
21
20
|
- [Examples](https://github.com/Permissionless-Software-Foundation/bch-js-examples)
|
|
22
|
-
- [
|
|
21
|
+
- [x402-bch.fullstack.cash](https://x402-bch.fullstack.cash) - The REST API this library talks to by default.
|
|
23
22
|
- [FullStack.cash](https://fullstack.cash) - cloud-based infrastructure for application developers.
|
|
24
|
-
- [FullStack.cash Account](https://fullstack.cash/login) - Get your API key to unlock increased rate limits.
|
|
25
23
|
- [Permissionless Software Foundation](https://psfoundation.cash) - The organization that maintains this library.
|
|
26
24
|
- [CashStack.info](https://cashstack.info) - bch-js is part of the Cash Stack, a JavaScript framework for writing web 2 and web 3 business applications.
|
|
27
25
|
|
|
@@ -31,42 +29,26 @@ Here are two YouTube walk-through videos to help you get started:
|
|
|
31
29
|
|
|
32
30
|
- Instantiate the library in your code:
|
|
33
31
|
|
|
34
|
-
```
|
|
35
|
-
|
|
32
|
+
```javascript
|
|
33
|
+
import BCHJS from "@psf/bch-js"
|
|
36
34
|
let bchjs = new BCHJS() // Defaults to BCHN network.
|
|
37
35
|
```
|
|
38
36
|
|
|
39
37
|
This library is intended to be paired with
|
|
40
|
-
the [bch-api](https://github.com/Permissionless-Software-Foundation/bch-api) REST API, and the infrastructure provided by [FullStack.cash](https://fullstack.cash). The `restURL` property can be changed to work with different Bitcoin Cash networks:
|
|
38
|
+
the [psf-bch-api](https://github.com/Permissionless-Software-Foundation/psf-bch-api) REST API, and the infrastructure provided by [FullStack.cash](https://fullstack.cash). The `restURL` property can be changed to work with different Bitcoin Cash networks:
|
|
41
39
|
|
|
42
|
-
- BCHN Mainnet REST API server: https://
|
|
43
|
-
- ABC Mainnet REST API server: https://abc.fullstack.cash/v5/
|
|
40
|
+
- BCHN Mainnet REST API server: https://x402-bch.fullstack.cash/v7/
|
|
44
41
|
- Check server status: https://metrics.fullstack.cash
|
|
45
42
|
|
|
46
|
-
### API Key (JWT Token)
|
|
47
|
-
|
|
48
|
-
The [bch-api](https://github.com/Permissionless-Software-Foundation/bch-api) REST API hosted by [FullStack.cash](https://fullstack.cash) uses JWT tokens to pay for increased
|
|
49
|
-
rate limits when interacting with the back end server. See [this article](https://cashstack.info) if you want to understand the system-as-a-whole. The JWT token can be fed to bch-js _implicitly_ or _explicitly_.
|
|
50
|
-
|
|
51
|
-
- Implicitly: bch-js will detect your JWT token if you set the `BCHJSTOKEN` environment variable.
|
|
52
|
-
- Explicitly: You can directly feed in the JWT token with the `apiToken` property when instantiating the library. Here is an example:
|
|
53
|
-
|
|
54
|
-
```
|
|
55
|
-
const BCHJS = require("@psf/bch-js")
|
|
56
|
-
let bchjs = new BCHJS({
|
|
57
|
-
restURL: 'https://bchn.fullstack.cash/v5/',
|
|
58
|
-
apiToken: 'eyJhbGciO...' // Your JWT token here.
|
|
59
|
-
})
|
|
60
|
-
```
|
|
61
43
|
|
|
62
|
-
###
|
|
44
|
+
### Web Apps
|
|
63
45
|
|
|
64
46
|
[minimal-slp-wallet](https://www.npmjs.com/package/minimal-slp-wallet) is a minimal wallet 'engine' that incorporates bch-js. It's compiled with Browserify for front end apps.
|
|
65
47
|
|
|
66
|
-
[gatsby-theme-bch-wallet](https://github.com/Permissionless-Software-Foundation/gatsby-theme-bch-wallet) is a Gatsby Theme and [bch-wallet-starter](https://github.com/Permissionless-Software-Foundation/bch-wallet-starter) is a Gatsby Starter for building web wallets using minimal-slp-wallet.
|
|
67
|
-
|
|
68
48
|
[This gist](https://gist.github.com/christroutner/6cb9d1b615f3f9363af79723157bc434) shows how to include minimal-slp-wallet into a basic web page without using a framework.
|
|
69
49
|
|
|
50
|
+
[bch-wallet-web3-spa](https://github.com/Permissionless-Software-Foundation/bch-wallet-web3-spa) is a React web app template using bch-js and minimal-slp-wallet.
|
|
51
|
+
|
|
70
52
|
## Features
|
|
71
53
|
|
|
72
54
|
- [ECMAScript 2017 standard JavaScript](https://en.wikipedia.org/wiki/ECMAScript#8th_Edition_-_ECMAScript_2017) used instead of TypeScript. Works
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Script to improve contrast in auto-generated API documentation
|
|
4
|
+
# The code examples in api-doc use grey-on-grey colors that are hard to read.
|
|
5
|
+
# This fixes that issue by improving text contrast for better readability.
|
|
6
|
+
# Run this script *after* running 'npm run docs'
|
|
7
|
+
|
|
8
|
+
FILE="./docs/assets/prism.css"
|
|
9
|
+
|
|
10
|
+
# Check if file exists
|
|
11
|
+
if [ ! -f "$FILE" ]; then
|
|
12
|
+
echo "Error: $FILE not found. Make sure to run 'npm run docs' first."
|
|
13
|
+
exit 1
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
# Create a backup
|
|
17
|
+
#cp "$FILE" "$FILE.bak"
|
|
18
|
+
|
|
19
|
+
# Improve contrast:
|
|
20
|
+
# - Change default text color from #ccc to #e8e8e8 (brighter light gray)
|
|
21
|
+
# - Change comment color from #999 to #b5b5b5 (lighter for better visibility)
|
|
22
|
+
# - Change punctuation color from #ccc to #e8e8e8 (consistent with text)
|
|
23
|
+
|
|
24
|
+
# Replace default text color in code[class*="language-"] and pre[class*="language-"]
|
|
25
|
+
sed -i 's/color: #ccc;/color: #000000;/g' "$FILE"
|
|
26
|
+
|
|
27
|
+
# Replace comment color
|
|
28
|
+
sed -i 's/color: #999;/color: #b5b5b5;/g' "$FILE"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# Replace punctuation color (already handled by first sed, but explicit for clarity)
|
|
32
|
+
# The punctuation token also uses #ccc, so the first sed command handles it
|
|
33
|
+
|
|
34
|
+
echo "✓ Improved contrast in prism.css:"
|
|
35
|
+
echo " - Default text: #ccc → #e8e8e8"
|
|
36
|
+
echo " - Comments: #999 → #b5b5b5"
|
|
37
|
+
echo " - Punctuation: #ccc → #e8e8e8"
|
|
38
|
+
|