btc-wallet 0.5.96-beta → 0.5.98-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/index.js CHANGED
@@ -3906,8 +3906,31 @@ function signMessage(message) {
3906
3906
  const { signMessage: signMessage2, getPublicKey } = getBtcProvider();
3907
3907
  const publicKey = yield getPublicKey();
3908
3908
  const signature = yield signMessage2(message);
3909
- const signatureBase58 = bs582.encode(Buffer.from(signature, "base64"));
3910
- const publicKeyBase58 = bs582.encode(Buffer.from(publicKey, "hex"));
3909
+ const signatureBuffer = Buffer.from(signature, "base64");
3910
+ let signatureWithoutPrefix;
3911
+ if (signatureBuffer.length === 65) {
3912
+ signatureWithoutPrefix = signatureBuffer.subarray(1);
3913
+ } else if (signatureBuffer.length === 64) {
3914
+ signatureWithoutPrefix = signatureBuffer;
3915
+ } else {
3916
+ throw new Error(`Invalid signature length: ${signatureBuffer.length}`);
3917
+ }
3918
+ const signatureBase58 = bs582.encode(signatureWithoutPrefix);
3919
+ const publicKeyBuffer = Buffer.from(publicKey, "hex");
3920
+ let uncompressedPublicKey;
3921
+ if (publicKeyBuffer.length === 33) {
3922
+ const decompressed = ecc.pointCompress(publicKeyBuffer, false);
3923
+ if (!decompressed) {
3924
+ throw new Error("Failed to decompress public key");
3925
+ }
3926
+ uncompressedPublicKey = decompressed;
3927
+ } else if (publicKeyBuffer.length === 65) {
3928
+ uncompressedPublicKey = publicKeyBuffer;
3929
+ } else {
3930
+ throw new Error(`Invalid public key length: ${publicKeyBuffer.length}`);
3931
+ }
3932
+ const publicKeyWithoutPrefix = uncompressedPublicKey.subarray(1);
3933
+ const publicKeyBase58 = bs582.encode(publicKeyWithoutPrefix);
3911
3934
  return {
3912
3935
  signature,
3913
3936
  publicKey,
@@ -5362,7 +5385,7 @@ function getGroup(state) {
5362
5385
 
5363
5386
  // src/index.ts
5364
5387
  var getVersion = () => {
5365
- return "0.5.96-beta";
5388
+ return "0.5.98-beta";
5366
5389
  };
5367
5390
  if (typeof window !== "undefined") {
5368
5391
  window.__BTC_WALLET_VERSION = getVersion();