btc-wallet 0.5.99-beta → 0.5.100-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.
@@ -28,6 +28,12 @@ export declare function getBtcBalance(account?: string): Promise<{
28
28
  }>;
29
29
  export declare function sendBitcoin(address: string, amount: number, feeRate: number): Promise<string>;
30
30
  export declare function getPublicKeyBase58(): Promise<any>;
31
+ export declare function getAddressByPublicKeyBase58(btcPublicKeyBase58: string): {
32
+ p2pkh: string | undefined;
33
+ p2sh: string | undefined;
34
+ p2wpkh: string | undefined;
35
+ p2wsh: string | undefined;
36
+ };
31
37
  export declare function signMessage(message: string): Promise<{
32
38
  signature: string;
33
39
  publicKey: string;
package/dist/index.js CHANGED
@@ -115,6 +115,7 @@ __export(src_exports, {
115
115
  checkSatoshiWhitelist: () => checkSatoshiWhitelist,
116
116
  estimateDepositAmount: () => estimateDepositAmount,
117
117
  executeBTCDepositAndAction: () => executeBTCDepositAndAction,
118
+ getAddressByPublicKeyBase58: () => getAddressByPublicKeyBase58,
118
119
  getBtcBalance: () => getBtcBalance,
119
120
  getBtcGasPrice: () => getBtcGasPrice,
120
121
  getBtcUtxos: () => getBtcUtxos,
@@ -3998,6 +3999,21 @@ function getPublicKeyBase58() {
3998
3999
  return publicKeyBase58;
3999
4000
  });
4000
4001
  }
4002
+ function getAddressByPublicKeyBase58(btcPublicKeyBase58) {
4003
+ const publicKey = import_bs582.default.decode(btcPublicKeyBase58);
4004
+ const uncompressedPublicKey = Buffer.concat([Buffer.from([4]), publicKey]);
4005
+ const compressedPublicKeyUint8 = ecc.pointCompress(uncompressedPublicKey, true);
4006
+ const compressedPublicKey = Buffer.from(compressedPublicKeyUint8);
4007
+ const p2pkh = bitcoin.payments.p2pkh({ pubkey: uncompressedPublicKey }).address;
4008
+ const p2sh = bitcoin.payments.p2sh({
4009
+ redeem: bitcoin.payments.p2pkh({ pubkey: uncompressedPublicKey })
4010
+ }).address;
4011
+ const p2wpkh = bitcoin.payments.p2wpkh({ pubkey: compressedPublicKey }).address;
4012
+ const p2wsh = bitcoin.payments.p2wsh({
4013
+ redeem: bitcoin.payments.p2pkh({ pubkey: compressedPublicKey })
4014
+ }).address;
4015
+ return { p2pkh, p2sh, p2wpkh, p2wsh };
4016
+ }
4001
4017
  function signMessage(message) {
4002
4018
  return __async(this, null, function* () {
4003
4019
  const { signMessage: signMessage2, getPublicKey } = getBtcProvider();
@@ -5450,7 +5466,7 @@ function getGroup(state) {
5450
5466
 
5451
5467
  // src/index.ts
5452
5468
  var getVersion = () => {
5453
- return "0.5.99-beta";
5469
+ return "0.5.100-beta";
5454
5470
  };
5455
5471
  if (typeof window !== "undefined") {
5456
5472
  window.__BTC_WALLET_VERSION = getVersion();