Skip to content
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

Expose signERC4361 in Acre.ts #7

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
25 changes: 25 additions & 0 deletions src/Acre.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions src/AcreBtcOld.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion tests/newops/AcreBtcNew.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading