Skip to content

Commit ebafaba

Browse files
authored
Merge pull request #4 from blooo-io/feat/publish-npm
2 parents 76b1fb3 + dcc4ed3 commit ebafaba

21 files changed

+293
-729
lines changed
File renamed without changes.
File renamed without changes.

README.md

+41-41
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ For a smooth and quick integration:
2828
#### Table of Contents
2929

3030
* [bippath](#bippath)
31-
* [Btc](#btc)
31+
* [Acre](#acre)
3232
* [Parameters](#parameters)
3333
* [Examples](#examples)
3434
* [getWalletXpub](#getwalletxpub)
@@ -55,7 +55,7 @@ For a smooth and quick integration:
5555
* [Parameters](#parameters-8)
5656
* [getTrustedInputBIP143](#gettrustedinputbip143)
5757
* [Parameters](#parameters-9)
58-
* [BtcNew](#btcnew)
58+
* [AcreBtcNew](#acrebtcnew)
5959
* [getWalletXpub](#getwalletxpub-1)
6060
* [Parameters](#parameters-10)
6161
* [getWalletPublicKey](#getwalletpublickey-1)
@@ -68,7 +68,7 @@ For a smooth and quick integration:
6868
* [Parameters](#parameters-14)
6969
* [descrTemplFrom](#descrtemplfrom)
7070
* [Parameters](#parameters-15)
71-
* [BtcOld](#btcold)
71+
* [AcreBtcOld](#acrebtcold)
7272
* [getWalletPublicKey](#getwalletpublickey-2)
7373
* [Parameters](#parameters-16)
7474
* [Examples](#examples-7)
@@ -130,9 +130,9 @@ which are commonly used in hierarchical deterministic (HD) wallets.
130130
It includes functions to convert BIP32 paths to and from different formats,
131131
extract components from extended public keys (xpubs), and manipulate path elements.
132132

133-
### Btc
133+
### Acre
134134

135-
Bitcoin API.
135+
Acre app API.
136136

137137
#### Parameters
138138

@@ -143,8 +143,8 @@ Bitcoin API.
143143
#### Examples
144144

145145
```javascript
146-
import Btc from "@blooo/hw-app-acre:";
147-
const btc = new Btc({ transport, currency: "bitcoin" });
146+
import Acre from "@blooo/hw-app-acre:";
147+
const acre = new Acre({ transport, currency: "bitcoin" });
148148
```
149149

150150
#### getWalletXpub
@@ -181,8 +181,8 @@ Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/
181181
##### Examples
182182

183183
```javascript
184-
btc.getWalletPublicKey("44'/0'/0'/0/0").then(o => o.bitcoinAddress)
185-
btc.getWalletPublicKey("49'/0'/0'/0/0", { format: "p2sh" }).then(o => o.bitcoinAddress)
184+
acre.getWalletPublicKey("44'/0'/0'/0/0").then(o => o.bitcoinAddress)
185+
acre.getWalletPublicKey("49'/0'/0'/0/0", { format: "p2sh" }).then(o => o.bitcoinAddress)
186186
```
187187

188188
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{publicKey: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), bitcoinAddress: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), chainCode: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>**&#x20;
@@ -199,7 +199,7 @@ You can sign a message according to the Bitcoin Signature format and retrieve v,
199199
##### Examples
200200

201201
```javascript
202-
btc.signMessage("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
202+
acre.signMessage("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
203203
var v = result['v'] + 27 + 4;
204204
var signature = Buffer.from(v.toString(16) + result['r'] + result['s'], 'hex').toString('base64');
205205
console.log("Signature : " + signature);
@@ -239,7 +239,7 @@ To sign a transaction involving standard (P2PKH) inputs, call createTransaction
239239
##### Examples
240240

241241
```javascript
242-
btc.createTransaction({
242+
acre.createTransaction({
243243
inputs: [ [tx1, 1] ],
244244
associatedKeysets: ["0'/0/0"],
245245
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
@@ -267,7 +267,7 @@ To obtain the signature of multisignature (P2SH) inputs, call signP2SHTransactio
267267
##### Examples
268268

269269
```javascript
270-
btc.signP2SHTransaction({
270+
acre.signP2SHTransaction({
271271
inputs: [ [tx, 1, "52210289b4a3ad52a919abd2bdd6920d8a6879b1e788c38aa76f0440a6f32a9f1996d02103a3393b1439d1693b063482c04bd40142db97bdf139eedd1b51ffb7070a37eac321030b9a409a1e476b0d5d17b804fcdb81cf30f9b99c6f3ae1178206e08bc500639853ae"] ],
272272
associatedKeysets: ["0'/0/0"],
273273
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
@@ -290,7 +290,7 @@ For each UTXO included in your transaction, create a transaction object from the
290290
##### Examples
291291

292292
```javascript
293-
const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
293+
const tx1 = acre.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
294294
```
295295

296296
Returns **[Transaction](#transaction)** the transaction object deserialized from the raw hexadecimal transaction
@@ -306,8 +306,8 @@ Serialize a transaction's outputs to hexadecimal
306306
##### Examples
307307

308308
```javascript
309-
const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
310-
const outputScript = btc.serializeTransactionOutputs(tx1).toString('hex');
309+
const tx1 = acre.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
310+
const outputScript = acre.serializeTransactionOutputs(tx1).toString('hex');
311311
```
312312

313313
Returns **[Buffer](https://nodejs.org/api/buffer.html)**&#x20;
@@ -338,25 +338,23 @@ Trusted input is the hash of a UTXO that needs to be signed. BIP143 is used for
338338

339339
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
340340

341-
### BtcNew
341+
### AcreBtcNew
342342

343-
This class implements the same interface as BtcOld (formerly
344-
named Btc), but interacts with Bitcoin hardware app version 2.1.0+
345-
which uses a totally new APDU protocol. This new
346-
protocol is documented at
347-
<https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md>
343+
This class implements the same interface as AcreBtcOld (formerly
344+
named Btc), but interacts with Acre hardware app from version 1.0.0
345+
which uses the same APDU protocol as the Bitcoin app version 2.1.0+.
346+
This protocol is documented at
347+
<https://github.com/blooo-io/app-acre/blob/develop/doc/acre.md>
348348

349-
Since the interface must remain compatible with BtcOld, the methods
349+
Since the interface must remain compatible with AcreBtcOld, the methods
350350
of this class are quite clunky, because it needs to adapt legacy
351-
input data into the PSBT process. In the future, a new interface should
352-
be developed that exposes PSBT to the outer world, which would render
353-
a much cleaner implementation.
351+
input data into the PSBT process.
354352

355353
#### getWalletXpub
356354

357355
This is a new method that allow users to get an xpub at a standard path.
358356
Standard paths are described at
359-
<https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md#description>
357+
<https://github.com/blooo-io/app-acre/blob/develop/doc/acre.md#description>
360358

361359
This boils down to paths (N=0 for Bitcoin, N=1 for Testnet):
362360
M/44'/N'/x'/\*\*
@@ -409,7 +407,7 @@ Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/
409407

410408
#### createPaymentTransaction
411409

412-
Build and sign a transaction. See Btc.createPaymentTransaction for
410+
Build and sign a transaction. See Acre.createPaymentTransaction for
413411
details on how to use this method.
414412

415413
This method will convert the legacy arguments, CreateTransactionArg, into
@@ -455,7 +453,7 @@ Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/
455453
### descrTemplFrom
456454

457455
This function returns a descriptor template based on the address format.
458-
See <https://github.com/LedgerHQ/app-bitcoin-new/blob/develop/doc/wallet.md> for details of
456+
See <https://github.com/blooo-io/app-acre/blob/develop/doc/wallet.md> for details of
459457
the bitcoin descriptor template.
460458

461459
#### Parameters
@@ -464,9 +462,11 @@ the bitcoin descriptor template.
464462

465463
Returns **DefaultDescriptorTemplate**&#x20;
466464

467-
### BtcOld
465+
### AcreBtcOld
468466

469-
This Bitcoin old API is compatible with versions of the Bitcoin nano app that are earlier than 2.1.0
467+
This old API is compatible with versions of the Bitcoin nano app that are earlier than 2.1.0 .
468+
It is never used by Acre, that is based on the latest Bitcoin nano app (2.1.0+).
469+
This class is kept for compatibility purposes.
470470

471471
#### getWalletPublicKey
472472

@@ -489,8 +489,8 @@ This Bitcoin old API is compatible with versions of the Bitcoin nano app that ar
489489
##### Examples
490490

491491
```javascript
492-
btc.getWalletPublicKey("44'/0'/0'/0/0").then(o => o.bitcoinAddress)
493-
btc.getWalletPublicKey("49'/0'/0'/0/0", { format: "p2sh" }).then(o => o.bitcoinAddress)
492+
acre.getWalletPublicKey("44'/0'/0'/0/0").then(o => o.bitcoinAddress)
493+
acre.getWalletPublicKey("49'/0'/0'/0/0", { format: "p2sh" }).then(o => o.bitcoinAddress)
494494
```
495495

496496
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{publicKey: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), bitcoinAddress: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), chainCode: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>**&#x20;
@@ -525,7 +525,7 @@ To sign a transaction involving standard (P2PKH) inputs, call createTransaction
525525
##### Examples
526526

527527
```javascript
528-
btc.createTransaction({
528+
acre.createTransaction({
529529
inputs: [ [tx1, 1] ],
530530
associatedKeysets: ["0'/0/0"],
531531
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
@@ -658,7 +658,7 @@ Returns **[Buffer](https://nodejs.org/api/buffer.html)** The output key
658658
### AppClient
659659

660660
This class encapsulates the APDU protocol documented at
661-
<https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md>
661+
<https://github.com/blooo-io/app-acre/blob/develop/doc/acre.md>
662662

663663
#### Parameters
664664

@@ -696,17 +696,17 @@ The reason for this is the limited amount of memory available to the app,
696696
so it can't always store the full psbt in memory.
697697

698698
The signing process is documented at
699-
<https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md#sign_psbt>
699+
<https://github.com/blooo-io/app-acre/blob/develop/doc/acre.md#sign_psbt>
700700

701701
#### Parameters
702702

703703
* `psbt` **[PsbtV2](#psbtv2)**&#x20;
704704

705705
### Merkle
706706

707-
This class implements the merkle tree used by Ledger Bitcoin app v2+,
707+
This class implements the merkle tree used by Ledger Acre app,
708708
which is documented at
709-
<https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/merkle.md>
709+
<https://github.com/blooo-io/app-acre/blob/develop/doc/merkle.md>
710710

711711
#### Parameters
712712

@@ -716,7 +716,7 @@ which is documented at
716716
### MerkleMap
717717

718718
This implements "Merkelized Maps", documented at
719-
<https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/merkle.md#merkleized-maps>
719+
<https://github.com/blooo-io/app-acre/blob/develop/doc/merkle.md#merkleized-maps>
720720

721721
A merkelized map consist of two merkle trees, one for the keys of
722722
a map and one for the values of the same map, thus the two merkle
@@ -736,7 +736,7 @@ how to construct output scripts from keys. A "Wallet Policy" consists
736736
of a "Descriptor Template" and a list of "keys". A key is basically
737737
a serialized BIP32 extended public key with some added derivation path
738738
information. This is documented at
739-
<https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/wallet.md>
739+
<https://github.com/blooo-io/app-acre/blob/develop/doc/wallet.md>
740740

741741
#### Parameters
742742

@@ -829,8 +829,8 @@ complemantary fields as needed in the future.
829829
#### Examples
830830

831831
```javascript
832-
const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
833-
const outputScript = btc.serializeTransactionOutputs(tx1).toString('hex');
832+
const tx1 = acre.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
833+
const outputScript = acre.serializeTransactionOutputs(tx1).toString('hex');
834834
```
835835

836836
Returns **[Buffer](https://nodejs.org/api/buffer.html)**&#x20;

jest.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
collectCoverage: true,
66
testPathIgnorePatterns: ["packages/*/lib-es", "packages/*/lib"],
77
coveragePathIgnorePatterns: ["packages/create-dapp"],
8-
testMatch: ["**/tests/newops/BtcNew.test.ts"],
8+
testMatch: ["**/tests/newops/AcreBtcNew.test.ts"],
99
passWithNoTests: true,
1010
// collectCoverageFrom: ["packages/**/src/*.ts"],
1111
rootDir: __dirname,

package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@blooo/hw-app-acre",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Ledger Hardware Wallet Acre Application API",
55
"keywords": [
66
"Ledger",
@@ -23,9 +23,9 @@
2323
"publishConfig": {
2424
"access": "public"
2525
},
26-
"main": "lib/Btc.js",
27-
"module": "lib-es/Btc.js",
28-
"types": "lib/Btc.d.ts",
26+
"main": "lib/Acre.js",
27+
"module": "lib-es/Acre.js",
28+
"types": "lib/Acre.d.ts",
2929
"typesVersions": {
3030
"*": {
3131
"lib/*": [
@@ -36,7 +36,7 @@
3636
],
3737
"*": [
3838
"lib/*",
39-
"lib/Btc.d.ts"
39+
"lib/Acre.d.ts"
4040
]
4141
}
4242
},
@@ -54,15 +54,15 @@
5454
"default": "./lib-es/*.js"
5555
},
5656
".": {
57-
"require": "./lib/Btc.js",
58-
"default": "./lib-es/Btc.js"
57+
"require": "./lib/Acre.js",
58+
"default": "./lib-es/Acre.js"
5959
},
6060
"./package.json": "./package.json"
6161
},
6262
"license": "Apache-2.0",
6363
"dependencies": {
64-
"@ledgerhq/hw-transport": "workspace:^",
65-
"@ledgerhq/logs": "workspace:^",
64+
"@ledgerhq/hw-transport": "6.31.3",
65+
"@ledgerhq/logs": "6.12.0",
6666
"bip32-path": "^0.4.2",
6767
"bitcoinjs-lib": "^5.2.0",
6868
"bs58": "^4.0.1",
@@ -76,8 +76,8 @@
7676
"varuint-bitcoin": "1.1.2"
7777
},
7878
"devDependencies": {
79-
"@ledgerhq/hw-transport-mocker": "workspace:^",
80-
"@ledgerhq/hw-transport-node-speculos": "workspace:^",
79+
"@ledgerhq/hw-transport-mocker": "6.29.3",
80+
"@ledgerhq/hw-transport-node-speculos": "6.29.3",
8181
"@types/jest": "^29.5.10",
8282
"@types/node": "^20.8.10",
8383
"axios": "^0.25.0",

0 commit comments

Comments
 (0)