@utexo/rgb-lib 0.3.0-beta.10
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/LICENSE +21 -0
- package/README.md +49 -0
- package/index.js +24 -0
- package/package.json +31 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2025 RGB-Tools developers
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# RGB Lib Node.js bindings
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/rgb-lib)
|
|
4
|
+
|
|
5
|
+
This project builds Node.js packages for the [rgb-lib] Rust library, which is
|
|
6
|
+
included as a git submodule. The bindings are created using the [rgb-lib C++
|
|
7
|
+
bindings], which are located inside the rgb-lib submodule, and [Swig].
|
|
8
|
+
|
|
9
|
+
## Platform-specific packages
|
|
10
|
+
|
|
11
|
+
Bindings are platform-specific and are published into dedicated packages (under
|
|
12
|
+
the @rgb-tools namespace). The main package is a thin layer that depends on the
|
|
13
|
+
correct platform-specific package for the platform where it's being installed.
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
- Python 3
|
|
18
|
+
- development tools (e.g. make, g++)
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
Install the package with npm:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npm install rgb-lib
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
Import the package with:
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
const rgblib = require("rgb-lib");
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Then call its exported functions. As an example:
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
let keys = rgblib.generateKeys(rgblib.BitcoinNetwork.Regtest);
|
|
40
|
+
console.log(keys);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
> :warning: **Warning: memory will be leaked if not taken care of manually**
|
|
44
|
+
>
|
|
45
|
+
> Check the example to see how you can manually avoid memory leaks
|
|
46
|
+
|
|
47
|
+
[Swig]: https://github.com/swig/swig
|
|
48
|
+
[rgb-lib C++ bindings]: https://github.com/RGB-Tools/rgb-lib/tree/master/bindings/c-ffi
|
|
49
|
+
[rgb-lib]: https://github.com/RGB-Tools/rgb-lib
|
package/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const os = require("os");
|
|
2
|
+
|
|
3
|
+
// Currently supported platforms
|
|
4
|
+
const supportedCombinations = [
|
|
5
|
+
{ platform: "linux", arch: "x64" },
|
|
6
|
+
{ platform: "linux", arch: "arm64" },
|
|
7
|
+
{ platform: "darwin", arch: "arm64" },
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
const platform = os.platform();
|
|
11
|
+
const arch = os.arch();
|
|
12
|
+
|
|
13
|
+
const isSupported = supportedCombinations.some(
|
|
14
|
+
(combo) => combo.platform === platform && combo.arch === arch
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
if (!isSupported) {
|
|
18
|
+
console.error(`Unsupported platform-arch: ${platform}-${arch}`);
|
|
19
|
+
console.error("Supported combinations: linux-x64, linux-arm64, darwin-arm64");
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let nativePackageName = `@utexo/rgb-lib-${platform}-${arch}`;
|
|
24
|
+
module.exports = require(nativePackageName);
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@utexo/rgb-lib",
|
|
3
|
+
"version": "0.3.0-beta.10",
|
|
4
|
+
"description": "Node.js bindings for rgb-lib",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"index.js"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"No tests available\" && exit 1"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/UTEXO-Protocol/rgb-lib-nodejs.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"rgb",
|
|
18
|
+
"bitcoin"
|
|
19
|
+
],
|
|
20
|
+
"author": "UTEXO Protocol",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/UTEXO-Protocol/rgb-lib-nodejs/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/UTEXO-Protocol/rgb-lib-nodejs#readme",
|
|
26
|
+
"optionalDependencies": {
|
|
27
|
+
"@utexo/rgb-lib-linux-x64": "0.3.0-beta.10",
|
|
28
|
+
"@utexo/rgb-lib-linux-arm64": "0.3.0-beta.10",
|
|
29
|
+
"@utexo/rgb-lib-darwin-arm64": "0.3.0-beta.10"
|
|
30
|
+
}
|
|
31
|
+
}
|