-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: npm package publish #3
Changes from 5 commits
04c276e
14e14d9
c2d0d1f
df45b3e
78eec34
e1c0890
bb0bb3b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ For a smooth and quick integration: | |
#### Table of Contents | ||
|
||
* [bippath](#bippath) | ||
* [Btc](#btc) | ||
* [Acre](#btc) | ||
* [Parameters](#parameters) | ||
* [Examples](#examples) | ||
* [getWalletXpub](#getwalletxpub) | ||
|
@@ -130,9 +130,9 @@ which are commonly used in hierarchical deterministic (HD) wallets. | |
It includes functions to convert BIP32 paths to and from different formats, | ||
extract components from extended public keys (xpubs), and manipulate path elements. | ||
|
||
### Btc | ||
### Acre | ||
|
||
Bitcoin API. | ||
Acre app API. | ||
|
||
#### Parameters | ||
|
||
|
@@ -143,8 +143,8 @@ Bitcoin API. | |
#### Examples | ||
|
||
```javascript | ||
import Btc from "@blooo/hw-app-acre:"; | ||
const btc = new Btc({ transport, currency: "bitcoin" }); | ||
import Acre from "@blooo/hw-app-acre:"; | ||
const btc = new Acre({ transport, currency: "bitcoin" }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here too |
||
``` | ||
|
||
#### getWalletXpub | ||
|
@@ -341,16 +341,14 @@ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G | |
### BtcNew | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is it BtcNew in Acre contexte? |
||
|
||
This class implements the same interface as BtcOld (formerly | ||
named Btc), but interacts with Bitcoin hardware app version 2.1.0+ | ||
which uses a totally new APDU protocol. This new | ||
protocol is documented at | ||
<https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md> | ||
named Btc), but interacts with Acre hardware app from version 1.0.0 | ||
which uses the same APDU protocol as the Bitcoin app version 2.1.0+. | ||
This protocol is documented at | ||
<https://github.com/blooo-io/app-acre/blob/develop/doc/acre.md> | ||
|
||
Since the interface must remain compatible with BtcOld, the methods | ||
of this class are quite clunky, because it needs to adapt legacy | ||
input data into the PSBT process. In the future, a new interface should | ||
be developed that exposes PSBT to the outer world, which would render | ||
a much cleaner implementation. | ||
input data into the PSBT process. | ||
|
||
#### getWalletXpub | ||
|
||
|
@@ -409,7 +407,7 @@ Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/ | |
|
||
#### createPaymentTransaction | ||
|
||
Build and sign a transaction. See Btc.createPaymentTransaction for | ||
Build and sign a transaction. See Acre.createPaymentTransaction for | ||
details on how to use this method. | ||
|
||
This method will convert the legacy arguments, CreateTransactionArg, into | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
import Btc from "./Btc"; | ||
export default Btc; | ||
import Acre from "./Acre"; | ||
export default Acre; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
import Transport from "@ledgerhq/hw-transport"; | ||
import SpeculosTransport from "@ledgerhq/hw-transport-node-speculos"; | ||
import { getXpubComponents } from "../src/bip32"; | ||
import Btc from "../src/Btc"; | ||
import Acre from "../src/Acre"; | ||
import BtcNew from "../src/BtcNew"; | ||
import { compressPublicKey } from "../src/compressPublicKey"; | ||
import { AppClient } from "../src/newops/appClient"; | ||
|
@@ -155,9 +155,9 @@ async function transport(): Promise<SpeculosTransport> { | |
async function impl( | ||
variant: "old" | "new", | ||
transport: Transport | ||
): Promise<Btc | BtcNew> { | ||
): Promise<Acre | BtcNew> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Btc |
||
if (variant === "old") { | ||
return new Btc(transport); | ||
return new Acre(transport); | ||
} | ||
const client = new AppClient(transport); | ||
const btc = new BtcNew(client); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import { | |
openTransportReplayer, | ||
RecordStore, | ||
} from "@ledgerhq/hw-transport-mocker"; | ||
import Btc from "../src/Btc"; | ||
import Acre from "../src/Acre"; | ||
|
||
test("btc.getWalletXpub", async () => { | ||
/* | ||
|
@@ -120,7 +120,7 @@ ascii(1NjiCsVBuKDT62LmaUd7WZZZBK2gPAkisb) | |
`) | ||
); | ||
// This test covers the old bitcoin Nano app 1.6 API, before the breaking changes that occurred in v2.1.0 of the app | ||
const btc = new Btc({ transport, currency: "oldbitcoin" }); | ||
const btc = new Acre({ transport, currency: "oldbitcoin" }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. btc |
||
const result = await btc.getWalletXpub({ | ||
path: "44'/0'/17'", | ||
xpubVersion: 0x043587cf, // mainnet | ||
|
@@ -138,7 +138,7 @@ test("btc.getWalletPublicKey", async () => { | |
`) | ||
); | ||
// This test covers the old bitcoin Nano app 1.6 API, before the breaking changes that occurred in v2.1.0 of the app | ||
const btc = new Btc({ transport, currency: "oldbitcoin" }); | ||
const btc = new Acre({ transport, currency: "oldbitcoin" }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. btc |
||
const result = await btc.getWalletPublicKey("44'/0'/0'/0"); | ||
expect(result).toEqual({ | ||
bitcoinAddress: "13KE6TffArLh4fVM6uoQzvsYq5vwetJcVM", | ||
|
@@ -187,7 +187,7 @@ test("btc 2", async () => { | |
`) | ||
); | ||
// This test covers the old bitcoin Nano app 1.6 API, before the breaking changes that occurred in v2.1.0 of the app | ||
const btc = new Btc({ transport, currency: "oldbitcoin" }); | ||
const btc = new Acre({ transport, currency: "oldbitcoin" }); | ||
const tx1 = btc.splitTransaction( | ||
"01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000" | ||
); | ||
|
@@ -241,7 +241,7 @@ test("btc 3", async () => { | |
<= 3045022100b5b1813992282b9a1fdd957b9751d79dc21018abc6586336e272212cc89cfe84022053765a1da0bdb5a0631a9866f1fd4c583589d5188b11cfa302fc20cd2611a71e019000 | ||
`) | ||
); | ||
const btc = new Btc({ transport }); | ||
const btc = new Acre({ transport }); | ||
const tx1 = btc.splitTransaction( | ||
"01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000" | ||
); | ||
|
@@ -272,7 +272,7 @@ test("btc 4", async () => { | |
<= 3045022100e32b32b8a6b4228155ba4d1a536d8fed9900606663fbbf4ea420ed8e944f9c18022053c97c74d2f6d8620d060584dc7886f5f3003684bb249508eb7066215172281a9000 | ||
`) | ||
); | ||
const btc = new Btc({ transport }); | ||
const btc = new Acre({ transport }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. btc |
||
const result = await btc.signMessage( | ||
"44'/0'/0'/0", | ||
Buffer.from("test").toString("hex") | ||
|
@@ -324,7 +324,7 @@ test("btc seg multi", async () => { | |
`) | ||
); | ||
// This test covers the old bitcoin Nano app 1.6 API, before the breaking changes that occurred in v2.1.0 of the app | ||
const btc = new Btc({ transport, currency: "oldbitcoin" }); | ||
const btc = new Acree({ transport, currency: "oldbitcoin" }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. btc |
||
const tx1 = btc.splitTransaction( | ||
"0100000000010130992c1559a43de1457f23380fefada09124d22594bbeb46ab6e9356e8407d39010000001716001417507f91a6594df7367a0561e4d3df376a829e1fffffffff02c03b47030000000017a9142397c9bb7a3b8a08368a72b3e58c7bb850555792875f810acf0900000017a914813a2e6c7538f0d0afbdeb5db38608804f5d76ab8702483045022100e09ca8a5357623438daee5b7804e73c9209de7c645efd405f13f83420157c48402207d3e4a30f362e062e361967c7afdd45e7f21878a067b661a6635669e620f99910121035606550fd51f6b063b69dc92bd182934a34463f773222743f300d3c7fd3ae47300000000", | ||
true | ||
|
@@ -373,7 +373,7 @@ test("btc sign p2sh seg", async () => { | |
<= 3045022100932934ee326c19c81b72fb03cec0fb79ff980a8076639f77c7edec35bd59da1e02205e4030e8e0fd2405f6db2fe044c49d3f191adbdc0e05ec7ed4dcc4c6fe7310e5019000 | ||
`) | ||
); | ||
const btc = new Btc({ transport }); | ||
const btc = new Acre({ transport }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. btc |
||
const tx1 = btc.splitTransaction( | ||
"0100000001d3a05cd6e15582f40e68bb8b1559dc9e5b3e4f9f34d92c1217dc8c3355bc844e010000008a47304402207ab1a4768cbb036d4bce3c4a294c13cc5ae6076fc7bedce88c62aa80ae366da702204f8fea6923f8df36315c0c26cb42d8d7ab52ca4736776816e10d6ce51906d0600141044289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34cec320a0565fb7caf11b1ca2f445f9b7b012dda5718b3cface369ee3a034ded6ffffffff02102700000000000017a9141188cc3c265fbc01a025fc8adec9823effd0cef187185f9265170100001976a9140ae1441568d0d293764a347b191025c51556cecd88ac00000000", | ||
true | ||
|
@@ -406,7 +406,7 @@ test("signMessage", async () => { | |
<= 314402205eac720be544d3959a760d9bfd6a0e7c86d128fd1030038f06d85822608804e20220385d83273c9d03c469596292fb354b07d193034f83c2633a4c1f057838e12a5b9000 | ||
`) | ||
); | ||
const btc = new Btc({ transport }); | ||
const btc = new Acre({ transport }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. btc |
||
const res = await btc.signMessage( | ||
"44'/0'/0'/0/0", | ||
Buffer.from("foobar").toString("hex") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btc ?