btc-wallet 0.5.98-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.
- package/dist/core/btcUtils.d.ts +7 -2
- package/dist/index.js +29 -20
- package/dist/index.js.map +3 -3
- package/esm/index.js +29 -20
- package/esm/index.js.map +3 -3
- package/package.json +1 -1
package/dist/core/btcUtils.d.ts
CHANGED
|
@@ -27,11 +27,16 @@ export declare function getBtcBalance(account?: string): Promise<{
|
|
|
27
27
|
availableBalance: number;
|
|
28
28
|
}>;
|
|
29
29
|
export declare function sendBitcoin(address: string, amount: number, feeRate: number): Promise<string>;
|
|
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
|
+
};
|
|
30
37
|
export declare function signMessage(message: string): Promise<{
|
|
31
38
|
signature: string;
|
|
32
39
|
publicKey: string;
|
|
33
|
-
signatureBase58: any;
|
|
34
|
-
publicKeyBase58: any;
|
|
35
40
|
}>;
|
|
36
41
|
/** estimate deposit receive amount, deduct protocol fee and repay amount */
|
|
37
42
|
export declare function estimateDepositAmount(amount: string, option?: {
|
package/dist/index.js
CHANGED
|
@@ -115,11 +115,13 @@ __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,
|
|
121
122
|
getCsnaAccountId: () => getCsnaAccountId,
|
|
122
123
|
getDepositAmount: () => getDepositAmount,
|
|
124
|
+
getPublicKeyBase58: () => getPublicKeyBase58,
|
|
123
125
|
getVersion: () => getVersion,
|
|
124
126
|
getWalletConfig: () => getWalletConfig,
|
|
125
127
|
getWithdrawTransaction: () => getWithdrawTransaction,
|
|
@@ -3975,21 +3977,10 @@ function sendBitcoin(address, amount, feeRate) {
|
|
|
3975
3977
|
return txHash;
|
|
3976
3978
|
});
|
|
3977
3979
|
}
|
|
3978
|
-
function
|
|
3980
|
+
function getPublicKeyBase58() {
|
|
3979
3981
|
return __async(this, null, function* () {
|
|
3980
|
-
const {
|
|
3982
|
+
const { getPublicKey } = getBtcProvider();
|
|
3981
3983
|
const publicKey = yield getPublicKey();
|
|
3982
|
-
const signature = yield signMessage2(message);
|
|
3983
|
-
const signatureBuffer = Buffer.from(signature, "base64");
|
|
3984
|
-
let signatureWithoutPrefix;
|
|
3985
|
-
if (signatureBuffer.length === 65) {
|
|
3986
|
-
signatureWithoutPrefix = signatureBuffer.subarray(1);
|
|
3987
|
-
} else if (signatureBuffer.length === 64) {
|
|
3988
|
-
signatureWithoutPrefix = signatureBuffer;
|
|
3989
|
-
} else {
|
|
3990
|
-
throw new Error(`Invalid signature length: ${signatureBuffer.length}`);
|
|
3991
|
-
}
|
|
3992
|
-
const signatureBase58 = import_bs582.default.encode(signatureWithoutPrefix);
|
|
3993
3984
|
const publicKeyBuffer = Buffer.from(publicKey, "hex");
|
|
3994
3985
|
let uncompressedPublicKey;
|
|
3995
3986
|
if (publicKeyBuffer.length === 33) {
|
|
@@ -4005,12 +3996,30 @@ function signMessage(message) {
|
|
|
4005
3996
|
}
|
|
4006
3997
|
const publicKeyWithoutPrefix = uncompressedPublicKey.subarray(1);
|
|
4007
3998
|
const publicKeyBase58 = import_bs582.default.encode(publicKeyWithoutPrefix);
|
|
4008
|
-
return
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
3999
|
+
return publicKeyBase58;
|
|
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
|
+
}
|
|
4017
|
+
function signMessage(message) {
|
|
4018
|
+
return __async(this, null, function* () {
|
|
4019
|
+
const { signMessage: signMessage2, getPublicKey } = getBtcProvider();
|
|
4020
|
+
const publicKey = yield getPublicKey();
|
|
4021
|
+
const signature = yield signMessage2(message);
|
|
4022
|
+
return { signature, publicKey };
|
|
4014
4023
|
});
|
|
4015
4024
|
}
|
|
4016
4025
|
function estimateDepositAmount(amount, option) {
|
|
@@ -5457,7 +5466,7 @@ function getGroup(state) {
|
|
|
5457
5466
|
|
|
5458
5467
|
// src/index.ts
|
|
5459
5468
|
var getVersion = () => {
|
|
5460
|
-
return "0.5.
|
|
5469
|
+
return "0.5.100-beta";
|
|
5461
5470
|
};
|
|
5462
5471
|
if (typeof window !== "undefined") {
|
|
5463
5472
|
window.__BTC_WALLET_VERSION = getVersion();
|