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/esm/index.js
CHANGED
|
@@ -3901,21 +3901,10 @@ function sendBitcoin(address, amount, feeRate) {
|
|
|
3901
3901
|
return txHash;
|
|
3902
3902
|
});
|
|
3903
3903
|
}
|
|
3904
|
-
function
|
|
3904
|
+
function getPublicKeyBase58() {
|
|
3905
3905
|
return __async(this, null, function* () {
|
|
3906
|
-
const {
|
|
3906
|
+
const { getPublicKey } = getBtcProvider();
|
|
3907
3907
|
const publicKey = yield getPublicKey();
|
|
3908
|
-
const signature = yield signMessage2(message);
|
|
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
3908
|
const publicKeyBuffer = Buffer.from(publicKey, "hex");
|
|
3920
3909
|
let uncompressedPublicKey;
|
|
3921
3910
|
if (publicKeyBuffer.length === 33) {
|
|
@@ -3931,12 +3920,30 @@ function signMessage(message) {
|
|
|
3931
3920
|
}
|
|
3932
3921
|
const publicKeyWithoutPrefix = uncompressedPublicKey.subarray(1);
|
|
3933
3922
|
const publicKeyBase58 = bs582.encode(publicKeyWithoutPrefix);
|
|
3934
|
-
return
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3923
|
+
return publicKeyBase58;
|
|
3924
|
+
});
|
|
3925
|
+
}
|
|
3926
|
+
function getAddressByPublicKeyBase58(btcPublicKeyBase58) {
|
|
3927
|
+
const publicKey = bs582.decode(btcPublicKeyBase58);
|
|
3928
|
+
const uncompressedPublicKey = Buffer.concat([Buffer.from([4]), publicKey]);
|
|
3929
|
+
const compressedPublicKeyUint8 = ecc.pointCompress(uncompressedPublicKey, true);
|
|
3930
|
+
const compressedPublicKey = Buffer.from(compressedPublicKeyUint8);
|
|
3931
|
+
const p2pkh = bitcoin.payments.p2pkh({ pubkey: uncompressedPublicKey }).address;
|
|
3932
|
+
const p2sh = bitcoin.payments.p2sh({
|
|
3933
|
+
redeem: bitcoin.payments.p2pkh({ pubkey: uncompressedPublicKey })
|
|
3934
|
+
}).address;
|
|
3935
|
+
const p2wpkh = bitcoin.payments.p2wpkh({ pubkey: compressedPublicKey }).address;
|
|
3936
|
+
const p2wsh = bitcoin.payments.p2wsh({
|
|
3937
|
+
redeem: bitcoin.payments.p2pkh({ pubkey: compressedPublicKey })
|
|
3938
|
+
}).address;
|
|
3939
|
+
return { p2pkh, p2sh, p2wpkh, p2wsh };
|
|
3940
|
+
}
|
|
3941
|
+
function signMessage(message) {
|
|
3942
|
+
return __async(this, null, function* () {
|
|
3943
|
+
const { signMessage: signMessage2, getPublicKey } = getBtcProvider();
|
|
3944
|
+
const publicKey = yield getPublicKey();
|
|
3945
|
+
const signature = yield signMessage2(message);
|
|
3946
|
+
return { signature, publicKey };
|
|
3940
3947
|
});
|
|
3941
3948
|
}
|
|
3942
3949
|
function estimateDepositAmount(amount, option) {
|
|
@@ -5385,7 +5392,7 @@ function getGroup(state) {
|
|
|
5385
5392
|
|
|
5386
5393
|
// src/index.ts
|
|
5387
5394
|
var getVersion = () => {
|
|
5388
|
-
return "0.5.
|
|
5395
|
+
return "0.5.100-beta";
|
|
5389
5396
|
};
|
|
5390
5397
|
if (typeof window !== "undefined") {
|
|
5391
5398
|
window.__BTC_WALLET_VERSION = getVersion();
|
|
@@ -5416,11 +5423,13 @@ export {
|
|
|
5416
5423
|
checkSatoshiWhitelist,
|
|
5417
5424
|
estimateDepositAmount,
|
|
5418
5425
|
executeBTCDepositAndAction,
|
|
5426
|
+
getAddressByPublicKeyBase58,
|
|
5419
5427
|
getBtcBalance,
|
|
5420
5428
|
getBtcGasPrice,
|
|
5421
5429
|
getBtcUtxos,
|
|
5422
5430
|
getCsnaAccountId,
|
|
5423
5431
|
getDepositAmount,
|
|
5432
|
+
getPublicKeyBase58,
|
|
5424
5433
|
getVersion,
|
|
5425
5434
|
getWalletConfig,
|
|
5426
5435
|
getWithdrawTransaction,
|