Skip to content

Commit c38357f

Browse files
authored
Merge pull request #64 from swan-bitcoin/jb/publish-package
Update build pipeline and add publish workflow
2 parents 727024a + bc3650b commit c38357f

File tree

8 files changed

+137
-4612
lines changed

8 files changed

+137
-4612
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CI
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
name: Build & Test
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Setup Node
12+
uses: actions/setup-node@v4
13+
with:
14+
node-version-file: '.nvmrc'
15+
registry-url: 'https://npm.pkg.github.com'
16+
scope: '@swan-bitcoin'
17+
- name: Install dependencies
18+
run: yarn install --frozen-lockfile
19+
- name: Build
20+
run: yarn workspaces run compile
21+
- name: Run tests
22+
run: yarn workspaces run test

.github/workflows/lerna.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.github/workflows/publish.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Publish Package to Github Packages
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
environment: publish
9+
permissions:
10+
contents: read
11+
packages: write
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-node@v4
15+
with:
16+
node-version-file: '.nvmrc'
17+
registry-url: 'https://npm.pkg.github.com'
18+
scope: '@swan-bitcoin'
19+
- run: yarn install --frozen-lockfile
20+
- run: yarn workspaces run compile
21+
# publish xpub-lib
22+
- run: yarn publish packages/xpub-lib --access public
23+
env:
24+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
# publish xpub-cli
26+
- run: yarn publish packages/xpub-cli --access public
27+
env:
28+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Swan's Address Derivation Tool
22

3-
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
4-
5-
A small JavaScript library and accompanying tool that derives bitcoin addresses from extended public keys. Built upon
6-
[caravan](https://github.com/caravan-bitcoin/caravan)
7-
and [bitcoinjs-lib](https://github.com/bitcoinjs/bitcoinjs-lib).
3+
A small JavaScript library and accompanying cli tool that derives bitcoin addresses from extended public keys. Built upon [caravan](https://github.com/caravan-bitcoin/caravan) and [bitcoinjs-lib](https://github.com/bitcoinjs/bitcoinjs-lib).
84

95
For more details refer to the individual packages:
106

@@ -19,6 +15,15 @@ For more details refer to the individual packages:
1915
- [BIP 84](https://github.com/bitcoin/bips/blob/master/bip-0084.mediawiki) - Derivation scheme for P2WPKH based accounts
2016
- [BIP 86](https://github.com/bitcoin/bips/blob/master/bip-0086.mediawiki) - Key Derivation for Single Key P2TR Outputs
2117

22-
Samourai Wallet wrote a short summary on the differences between [BIP 44, BIP 49, BIP 84](https://samourai.kayako.com/article/65-bip-44-bip-49-and-bip84) and [XPUB's, YPUB's, ZPUB's](https://samourai.kayako.com/article/49-xpub-s-ypub-s-zpub-s). For a detailed explanation on derivation paths refer to [learn me a bitcoin](https://learnmeabitcoin.com/technical/derivation-paths).
18+
For a detailed explanation on derivation paths refer to [learn me a bitcoin](https://learnmeabitcoin.com/technical/derivation-paths).
19+
20+
## Publishing
21+
22+
The `xpub-lib` and `xpub-cli` can be published to GitHub Packages by:
23+
1. Incrementing the version field within the package.json file within each package you want to publish.
24+
2. Creating a new tag with SemVer sytax (i.e. v0.0.1). Needs to match `v*`.
25+
3. Creating a new GitHub release using this tag. This will start the publish workflow.
26+
27+
The workflow will need to be approved by another user with write access before its executed. If published successfully, the packages will be published [here](https://github.com/orgs/swan-bitcoin/packages).
2328

2429
## License: [MIT](./LICENSE.md)

lerna.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,5 @@
33
"private": true,
44
"workspaces": [
55
"packages/*"
6-
],
7-
"devDependencies": {
8-
"lerna": "^3.22.1"
9-
}
6+
]
107
}

packages/xpub-lib/README.md

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
11
# Swan's Address Derivation Library
22

3-
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
3+
A small JavaScript library that derives bitcoin addresses from extended public keys. Built upon [caravan](https://github.com/caravan-bitcoin/caravan) and [bitcoinjs-lib](https://github.com/bitcoinjs/bitcoinjs-lib).
44

5-
A small JavaScript library that derives bitcoin addresses from extended public keys. Built upon
6-
[caravan](https://github.com/caravan-bitcoin/caravan)
7-
and [bitcoinjs-lib](https://github.com/bitcoinjs/bitcoinjs-lib).
5+
The library supports derivation from `xpub`s, `zpub`s, and `ypub`s, as well as legacy, SegWit, native SegWit (bech32) and Taproot (P2TR) address formats. Both Bitcoin mainnet and testnet are supported. If no network is specified the library defaults to testnet.
86

9-
The library supports derivation from `xpub`s, `zpub`s, and `ypub`s, as well as
10-
legacy, SegWit, and native SegWit (bech32) address formats. Both Bitcoin
11-
mainnet and testnet are supported. If no network is specified the library
12-
defaults to testnet.
13-
14-
| BIP | Extended Public Key | Address Type | Address Format | Address Name |
7+
| BIP | Derivation Path | Address Type | Address Format | Address Name |
158
| --- | ------------------- | ------------ | -------------- | ---------------------- |
16-
| 44 | `xpub...` | P2PKH | `1...` | Legacy |
17-
| 49 | `ypub...` | P2WPKH-P2SH | `3...` | SegWit |
18-
| 84 | `zpub...` | P2WPKH | `bc1...` | Bech32 (Native SegWit) |
9+
| 44 | `m/44'/0'/0'` | P2PKH | `1...` | Legacy |
10+
| 49 | `m/49'/0'/0'` | P2WPKH-P2SH | `3...` | SegWit (Nested SegWit) |
11+
| 84 | `m/84'/0'/0'` | P2WPKH | `bc1q...` | Bech32 (Native SegWit) |
12+
| 86 | `m/86'/0'/0'` | P2TR | `bc1p...` | Taproot |
1913

20-
Note that the different extended public key formats are interchangeable and
14+
Note that the different extended public key formats (i.e. xpub, ypub, zpub) are interchangeable and
2115
not bound to address formats. Every address type can be generated from every
22-
extended public key. The use of [output descriptors](https://bitcoin.stackexchange.com/questions/89261/why-does-importmulti-not-support-zpub-and-ypub/89281#89281)
23-
should make this less confusing in the future.
16+
extended public key.
2417

2518
The testnet equivalents are extended public keys starting with `tpub`, `upub`, and `vpub`.
2619

2720
## Example Usage
2821

29-
Use `addressFromExtPubKey` to derive single addresses. The following example
30-
derives the first address of the first account from an `xpub` on mainnet.
22+
```
23+
yarn add @swan-bitcoin/xpub-lib
24+
```
25+
26+
Use `addressFromExtPubKey` to derive a single addresses. The following example
27+
derives the first address of the first account from an `xpub` on mainnet. If no purpose is given, it will default to P2WPKH (Native SegWit).
3128

3229
```
3330
const key = "xpub6EuV33a2DXxAhoJTRTnr8qnysu81AA4YHpLY6o8NiGkEJ8KADJ35T64eJsStWsmRf1xXkEANVjXFXnaUKbRtFwuSPCLfDdZwYNZToh4LBCd"
@@ -68,8 +65,7 @@ addressesFromExtPubKey({
6865
// ]
6966
```
7067

71-
Address derivation will default to bech32 (native SegWit) unless a different
72-
`purpose` is specified. For example: to derive wrapped SegWit addresses
68+
To derive wrapped SegWit addresses
7369
(starting with `3...`) specify the appropriate purpose with `purpose: Purpose.P2SH`.
7470

7571
For more examples refer to the tests of this library.
@@ -80,7 +76,8 @@ For more examples refer to the tests of this library.
8076
- [BIP 44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) - Multi-Account Hierarchy for Deterministic Wallets
8177
- [BIP 49](https://github.com/bitcoin/bips/blob/master/bip-0049.mediawiki) - Derivation scheme for P2WPKH-nested-in-P2SH based accounts
8278
- [BIP 84](https://github.com/bitcoin/bips/blob/master/bip-0084.mediawiki) - Derivation scheme for P2WPKH based accounts
79+
- [BIP 86](https://github.com/bitcoin/bips/blob/master/bip-0086.mediawiki) - Key Derivation for Single Key P2TR Outputs
8380

84-
Samourai Wallet wrote a short summary on the differences between [BIP 44, BIP 49, BIP 84](https://support.samourai.io/article/65-bip-44-bip-49-and-bip84) and [XPUB's, YPUB's, ZPUB's](https://support.samourai.io/article/49-xpub-s-ypub-s-zpub-s). For a detailed explanation on derivation paths refer to [learn me a bitcoin](https://learnmeabitcoin.com/technical/derivation-paths).
81+
For a detailed explanation on derivation paths refer to [learn me a bitcoin](https://learnmeabitcoin.com/technical/derivation-paths).
8582

8683
## License: [MIT](./LICENSE.md)

0 commit comments

Comments
 (0)