-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from bucko13/caravan-descriptors
Caravan descriptors
- Loading branch information
Showing
37 changed files
with
3,750 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@caravan/descriptors": patch | ||
--- | ||
|
||
Add new package for encoding and decoding descriptors using bdk with wasm bindings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ jobs: | |
strategy: | ||
matrix: | ||
node-version: ["20.x"] | ||
# To use Turborepo Remote Caching | ||
# To use Turborepo Remote Caching, set the following environment variables for the job. | ||
env: | ||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | ||
TURBO_TEAM: ${{ vars.TURBO_TEAM }} | ||
|
@@ -22,8 +22,16 @@ jobs: | |
with: | ||
node-version: 20 | ||
|
||
- name: Install wasm-pack | ||
uses: jetli/[email protected] | ||
with: | ||
# Optional version of wasm-pack to install(eg. 'v0.9.1', 'latest') | ||
version: 'latest' | ||
|
||
- name: Install Dependencies | ||
run: npm install | ||
|
||
|
||
- name: Run tests | ||
run: npm run ci | ||
run: | | ||
npx turbo run ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,12 @@ jobs: | |
with: | ||
node-version: 20 | ||
|
||
- name: Install wasm-pack | ||
uses: jetli/[email protected] | ||
with: | ||
# Optional version of wasm-pack to install(eg. 'v0.9.1', 'latest') | ||
version: 'latest' | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,12 @@ jobs: | |
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Install wasm-pack | ||
uses: jetli/[email protected] | ||
with: | ||
# Optional version of wasm-pack to install(eg. 'v0.9.1', 'latest') | ||
version: 'latest' | ||
|
||
- name: Install Dependencies | ||
run: npm install | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,8 @@ yarn-error.log* | |
.DS_Store | ||
*.pem | ||
|
||
**/target | ||
.rustup | ||
.cargo | ||
|
||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
root: true, | ||
extends: [ | ||
"@caravan/eslint-config/library.js" | ||
], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
project: true, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"tabWidth": 2, | ||
"useTabs": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Caravan Descriptors | ||
|
||
## Installation | ||
|
||
1. clone | ||
2. install [rust toolchain](https://www.rust-lang.org/tools/install) and `cargo install wasm-pack` | ||
3. npm install in the main directory | ||
4. cd to the caravan-rs directory and `wasm-pack build -t nodejs` to build the `pkg/` directory (not clear yet if nodejs is the right target or how to make it more flexible) | ||
1. You might need to install llvm/clang | ||
2. Will also need to setup paths to build libsecp | ||
|
||
``` | ||
export PATH="/opt/homebrew/opt/llvm/bin:$PATH" | ||
# for older homebrew installs | ||
# export PATH="/usr/local/opt/llvm/bin:$PATH" | ||
export CC=/opt/homebrew/opt/llvm/bin/clang | ||
export AR=/opt/homebrew/opt/llvm/bin/llvm-ar | ||
``` | ||
|
||
## Usage | ||
You can use npm scripts from the main directory to do all building | ||
|
||
```shell | ||
$ npm run build | ||
``` | ||
This will cd into the rust directory, build packages for web and node | ||
targets, and then build the artifacts for the js library to be packaged | ||
and used. | ||
|
||
```shell | ||
$ npm run test | ||
``` | ||
This will run the TypeScript tests only. | ||
|
||
|
||
### Web | ||
You'll need to make sure that the web environment this is used in | ||
supports wasm. For example, if you're using in a vite.js project | ||
you'll need the `vite-plugin-wasm` plugin. | ||
|
||
Also note that all functions exported are async and need to be awaited | ||
since they will load up the wasm modules to be used (this way consumers | ||
of the library don't have to worry about loading up the modules themselves) | ||
|
||
|
||
## API | ||
NOTE: This is subject to change as this is still very much alpha | ||
|
||
The two main functions available for import are: | ||
|
||
### encodeDescriptors | ||
Takes a config for a multisig wallet and encodes it into | ||
the two corresponding descriptors | ||
|
||
### decodeDescriptors | ||
Take two descriptors and convert them into a multisig wallet | ||
config object. This will make it possible to determine and parse the wallet type | ||
(e.g. P2SH) and the key origins. |
Oops, something went wrong.