diff --git a/package.json b/package.json index 81b4cb2..7692e08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@blooo/hw-app-acre", - "version": "1.1.0", + "version": "1.1.1", "description": "Ledger Hardware Wallet Acre Application API", "keywords": [ "Ledger", diff --git a/src/Acre.ts b/src/Acre.ts index 3b785f7..59d38ae 100644 --- a/src/Acre.ts +++ b/src/Acre.ts @@ -197,6 +197,31 @@ export default class Acre { }); } + /** + * Signs a ERC4361 hex-formatted message with the private key at + * the provided derivation path according to the Bitcoin Signature format + * and returns v, r, s. + * @example + * const path = "m/44'/0'/0'/0/0"; + * const messageHex = "48656c6c6f20576f726c64"; // "Hello World" in hex + * const result = await acre.signERC4361Message({path: path, messageHex: messageHex}); + */ + signERC4361Message( + path: string, + messageHex: string, + ): Promise<{ + v: number; + r: string; + s: string; + }> { + return this.changeImplIfNecessary().then(impl => { + return impl.signERC4361Message({ + path, + messageHex, + }); + }); + } + /** * To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters * @param inputs is an array of [ transaction, output_index, optional redeem script, optional sequence ] where diff --git a/src/AcreBtcOld.ts b/src/AcreBtcOld.ts index a7f6f33..cef5d58 100644 --- a/src/AcreBtcOld.ts +++ b/src/AcreBtcOld.ts @@ -163,6 +163,20 @@ export default class AcreBtcOld { "@blooo/hw-app-acre: Acre Withdrawal transaction is not compatible with the legacy AcreBtcOld client. Please use the AcreBtcNew client", ); } + + /** + * This function will never be called from a AcreBtcOld context, it is only declared here for compatibility with + * the current framework, throwing an error in case it is ever reached. + */ + async signERC4361Message({ path, messageHex }: { path: string; messageHex: string }): Promise<{ + v: number; + r: string; + s: string; + }> { + throw new Error( + "@blooo/hw-app-acre: ERC4361 message signing is not compatible with the legacy AcreBtcOld client. Please use the AcreBtcNew client" + ); + } } function makeFingerprint(compressedPubKey) { diff --git a/tests/newops/AcreBtcNew.test.ts b/tests/newops/AcreBtcNew.test.ts index 45f296b..d8f9845 100644 --- a/tests/newops/AcreBtcNew.test.ts +++ b/tests/newops/AcreBtcNew.test.ts @@ -183,7 +183,6 @@ async function testGetWalletPublicKey( const result = await acreBtcNew.getWalletPublicKey(path, { format: addressFormat }); log('address', result.bitcoinAddress) verifyGetWalletPublicKeyResult(result, keyXpub, "testaddress"); - console.log('notworkingforsure') const resultAccount = await acreBtcNew.getWalletPublicKey(accountPath); verifyGetWalletPublicKeyResult(resultAccount, accountXpub); }