Skip to content

Commit

Permalink
fix: btc signMessage [LIVE-12360]
Browse files Browse the repository at this point in the history
  • Loading branch information
Justkant committed May 16, 2024
1 parent 0d0564e commit 6c5106b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/many-pigs-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/live-common": patch
---

fix: btc signMessage
20 changes: 14 additions & 6 deletions libs/ledger-live-common/src/families/bitcoin/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ import { startSpan } from "../../performance";
import { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
import { getCurrencyConfiguration } from "../../config";
import { BitcoinConfigInfo } from "@ledgerhq/coin-bitcoin/lib/config";
import { SignMessage } from "../../hw/signMessage/types";

const createSigner = (transport: Transport, currency: CryptoCurrency) => {
return new Btc({ transport, currency: currency.id });
};

const signerContext: SignerContext = <T>(
deviceId: string,
Expand All @@ -25,14 +30,10 @@ const signerContext: SignerContext = <T>(
): Promise<T> =>
firstValueFrom(
withDevice(deviceId)((transport: Transport) =>
from(fn(new Btc({ transport, currency: crypto.id }))),
from(fn(createSigner(transport, crypto))),
),
);

const createSigner = (transport: Transport, currency: CryptoCurrency) => {
return new Btc({ transport, currency: currency.id });
};

const getCurrencyConfig = (currency: CryptoCurrency) => {
return { info: getCurrencyConfiguration<BitcoinConfigInfo>(currency) };
};
Expand All @@ -43,8 +44,15 @@ const perfLogger = {

const bridge: Bridge<Transaction> = createBridges(signerContext, perfLogger, getCurrencyConfig);

export function createMessageSigner(): SignMessage {
return (transport, account, messageData) => {
const signerContext: SignerContext = (_, crypto, fn) => fn(createSigner(transport, crypto));
return signMessage(signerContext)("", account, messageData);
};
}

const messageSigner = {
signMessage: signMessage(signerContext),
signMessage: createMessageSigner(),
};

const resolver: Resolver = (
Expand Down

0 comments on commit 6c5106b

Please sign in to comment.