@dynamic-labs-wallet/btc 0.0.228 → 0.0.230
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/index.cjs.js +1135 -2
- package/index.esm.js +1117 -2
- package/package.json +8 -2
- package/src/client/client.d.ts +158 -0
- package/src/client/client.d.ts.map +1 -0
- package/src/index.d.ts +1 -1
- package/src/index.d.ts.map +1 -1
- package/src/types/index.d.ts +0 -21
- package/src/types/index.d.ts.map +1 -1
- package/src/utils/calculateBip322Hash/calculateBip322Hash.d.ts +16 -0
- package/src/utils/calculateBip322Hash/calculateBip322Hash.d.ts.map +1 -0
- package/src/utils/calculateBip322Hash/index.d.ts +2 -0
- package/src/utils/calculateBip322Hash/index.d.ts.map +1 -0
- package/src/utils/convertSignatureToDER/convertSignatureToDER.d.ts +9 -0
- package/src/utils/convertSignatureToDER/convertSignatureToDER.d.ts.map +1 -0
- package/src/utils/convertSignatureToDER/index.d.ts +2 -0
- package/src/utils/convertSignatureToDER/index.d.ts.map +1 -0
- package/src/utils/createLegacyAddress/createLegacyAddress.d.ts +10 -0
- package/src/utils/createLegacyAddress/createLegacyAddress.d.ts.map +1 -0
- package/src/utils/createLegacyAddress/index.d.ts +2 -0
- package/src/utils/createLegacyAddress/index.d.ts.map +1 -0
- package/src/utils/createNativeSegWitAddress/createNativeSegWitAddress.d.ts +10 -0
- package/src/utils/createNativeSegWitAddress/createNativeSegWitAddress.d.ts.map +1 -0
- package/src/utils/createNativeSegWitAddress/index.d.ts +2 -0
- package/src/utils/createNativeSegWitAddress/index.d.ts.map +1 -0
- package/src/utils/createSegWitAddress/createSegWitAddress.d.ts +10 -0
- package/src/utils/createSegWitAddress/createSegWitAddress.d.ts.map +1 -0
- package/src/utils/createSegWitAddress/index.d.ts +2 -0
- package/src/utils/createSegWitAddress/index.d.ts.map +1 -0
- package/src/utils/createTaprootAddress/createTaprootAddress.d.ts +10 -0
- package/src/utils/createTaprootAddress/createTaprootAddress.d.ts.map +1 -0
- package/src/utils/createTaprootAddress/index.d.ts +2 -0
- package/src/utils/createTaprootAddress/index.d.ts.map +1 -0
- package/src/utils/encodeBip322Signature/encodeBip322Signature.d.ts +13 -0
- package/src/utils/encodeBip322Signature/encodeBip322Signature.d.ts.map +1 -0
- package/src/utils/encodeBip322Signature/index.d.ts +2 -0
- package/src/utils/encodeBip322Signature/index.d.ts.map +1 -0
- package/src/utils/getAddressTypeFromDerivationPath/getAddressTypeFromDerivationPath.d.ts +9 -0
- package/src/utils/getAddressTypeFromDerivationPath/getAddressTypeFromDerivationPath.d.ts.map +1 -0
- package/src/utils/getAddressTypeFromDerivationPath/index.d.ts +2 -0
- package/src/utils/getAddressTypeFromDerivationPath/index.d.ts.map +1 -0
- package/src/utils/getBitcoinNetwork/getBitcoinNetwork.d.ts +10 -0
- package/src/utils/getBitcoinNetwork/getBitcoinNetwork.d.ts.map +1 -0
- package/src/utils/getBitcoinNetwork/index.d.ts +2 -0
- package/src/utils/getBitcoinNetwork/index.d.ts.map +1 -0
- package/src/utils/getDefaultRpcUrl/getDefaultRpcUrl.d.ts +9 -0
- package/src/utils/getDefaultRpcUrl/getDefaultRpcUrl.d.ts.map +1 -0
- package/src/utils/getDefaultRpcUrl/index.d.ts +2 -0
- package/src/utils/getDefaultRpcUrl/index.d.ts.map +1 -0
- package/src/utils/getFeeRates/getFeeRates.d.ts +18 -0
- package/src/utils/getFeeRates/getFeeRates.d.ts.map +1 -0
- package/src/utils/getFeeRates/index.d.ts +2 -0
- package/src/utils/getFeeRates/index.d.ts.map +1 -0
- package/src/utils/getUTXOs/getUTXOs.d.ts +15 -0
- package/src/utils/getUTXOs/getUTXOs.d.ts.map +1 -0
- package/src/utils/getUTXOs/index.d.ts +2 -0
- package/src/utils/getUTXOs/index.d.ts.map +1 -0
- package/src/utils/index.d.ts +12 -0
- package/src/utils/index.d.ts.map +1 -0
- package/src/utils/initEccLib/index.d.ts +2 -0
- package/src/utils/initEccLib/index.d.ts.map +1 -0
- package/src/utils/initEccLib/initEccLib.d.ts +5 -0
- package/src/utils/initEccLib/initEccLib.d.ts.map +1 -0
- package/src/utils/normalizeForCompressed/index.d.ts +2 -0
- package/src/utils/normalizeForCompressed/index.d.ts.map +1 -0
- package/src/utils/normalizeForCompressed/normalizeForCompressed.d.ts +9 -0
- package/src/utils/normalizeForCompressed/normalizeForCompressed.d.ts.map +1 -0
- package/src/utils/normalizeForTaproot/index.d.ts +2 -0
- package/src/utils/normalizeForTaproot/index.d.ts.map +1 -0
- package/src/utils/normalizeForTaproot/normalizeForTaproot.d.ts +9 -0
- package/src/utils/normalizeForTaproot/normalizeForTaproot.d.ts.map +1 -0
- package/src/utils/normalizePublicKey/index.d.ts +2 -0
- package/src/utils/normalizePublicKey/index.d.ts.map +1 -0
- package/src/utils/normalizePublicKey/normalizePublicKey.d.ts +14 -0
- package/src/utils/normalizePublicKey/normalizePublicKey.d.ts.map +1 -0
- package/src/utils/privateKeyToWIF/index.d.ts +2 -0
- package/src/utils/privateKeyToWIF/index.d.ts.map +1 -0
- package/src/utils/privateKeyToWIF/privateKeyToWIF.d.ts +24 -0
- package/src/utils/privateKeyToWIF/privateKeyToWIF.d.ts.map +1 -0
- package/src/utils/publicKeyToBitcoinAddress/index.d.ts +2 -0
- package/src/utils/publicKeyToBitcoinAddress/index.d.ts.map +1 -0
- package/src/utils/publicKeyToBitcoinAddress/publicKeyToBitcoinAddress.d.ts +12 -0
- package/src/utils/publicKeyToBitcoinAddress/publicKeyToBitcoinAddress.d.ts.map +1 -0
- package/src/utils/selectUTXOs/index.d.ts +2 -0
- package/src/utils/selectUTXOs/index.d.ts.map +1 -0
- package/src/utils/selectUTXOs/selectUTXOs.d.ts +19 -0
- package/src/utils/selectUTXOs/selectUTXOs.d.ts.map +1 -0
- package/src/utils/toBuffer/index.d.ts +2 -0
- package/src/utils/toBuffer/index.d.ts.map +1 -0
- package/src/utils/toBuffer/toBuffer.d.ts +8 -0
- package/src/utils/toBuffer/toBuffer.d.ts.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/normalizePublicKey/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EcdsaPublicKey } from '@dynamic-labs-wallet/browser';
|
|
2
|
+
import { BitcoinAddressType } from '@dynamic-labs-wallet/browser';
|
|
3
|
+
/**
|
|
4
|
+
* Normalizes a public key to a standard Buffer format
|
|
5
|
+
* Handles various input types (Uint8Array, Buffer, object with pubKeyAsHex, etc.)
|
|
6
|
+
* and formats (32-byte x-only, 33-byte compressed, 65-byte uncompressed)
|
|
7
|
+
* based on the target address type.
|
|
8
|
+
*
|
|
9
|
+
* @param pubkey - The raw public key input
|
|
10
|
+
* @param addressType - The target Bitcoin address type
|
|
11
|
+
* @returns The normalized public key as a Buffer
|
|
12
|
+
*/
|
|
13
|
+
export declare const normalizePublicKey: (pubkey: EcdsaPublicKey | Uint8Array | string | Buffer, addressType?: BitcoinAddressType) => Buffer;
|
|
14
|
+
//# sourceMappingURL=normalizePublicKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizePublicKey.d.ts","sourceRoot":"","sources":["../../../src/utils/normalizePublicKey/normalizePublicKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAKlE;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,WACrB,cAAc,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,gBACvC,kBAAkB,KAC/B,MAQF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/privateKeyToWIF/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BitcoinNetwork } from "../../types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Converts a private key (hex string) to Bitcoin WIF (Wallet Import Format)
|
|
4
|
+
* WIF is the standard format that Bitcoin wallets expect for importing private keys
|
|
5
|
+
*
|
|
6
|
+
* WIF encoding steps:
|
|
7
|
+
* 1. Add network prefix (0x80 for mainnet, 0xef for testnet/regtest)
|
|
8
|
+
* 2. Add compression flag (0x01) for compressed public keys (used for SegWit)
|
|
9
|
+
* 3. Calculate checksum (double SHA-256, take first 4 bytes)
|
|
10
|
+
* 4. Base58 encode the result
|
|
11
|
+
*
|
|
12
|
+
* @param privateKey - Private key as hex string (with or without 0x prefix)
|
|
13
|
+
* @param network - Bitcoin network (mainnet, testnet)
|
|
14
|
+
* @param options - Optional configuration
|
|
15
|
+
* @param options.compressed - Whether to use compressed format (default: true for SegWit compatibility)
|
|
16
|
+
* @param options.onWarning - Optional callback for warnings (e.g., unexpected key length)
|
|
17
|
+
* @returns WIF-encoded private key string
|
|
18
|
+
* @throws Error if conversion fails
|
|
19
|
+
*/
|
|
20
|
+
export declare const privateKeyToWIF: (privateKey: string, network?: BitcoinNetwork, options?: {
|
|
21
|
+
compressed?: boolean;
|
|
22
|
+
onWarning?: (message: string, data?: any) => void;
|
|
23
|
+
}) => string;
|
|
24
|
+
//# sourceMappingURL=privateKeyToWIF.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privateKeyToWIF.d.ts","sourceRoot":"","sources":["../../../src/utils/privateKeyToWIF/privateKeyToWIF.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAM3D;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,eAAe,eACd,MAAM,YACT,cAAc,YACb;IACR,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;CACnD,KACA,MAqDF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/publicKeyToBitcoinAddress/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BitcoinAddressType } from '@dynamic-labs-wallet/browser';
|
|
2
|
+
import type { BitcoinNetwork } from '../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Converts a public key to a Bitcoin address
|
|
5
|
+
*
|
|
6
|
+
* @param publicKey - The public key
|
|
7
|
+
* @param addressType - The address type (default: TAPROOT)
|
|
8
|
+
* @param network - The Bitcoin network (default: 'mainnet')
|
|
9
|
+
* @returns The Bitcoin address
|
|
10
|
+
*/
|
|
11
|
+
export declare const publicKeyToBitcoinAddress: (publicKey: Buffer | Uint8Array, addressType?: BitcoinAddressType, network?: BitcoinNetwork) => string;
|
|
12
|
+
//# sourceMappingURL=publicKeyToBitcoinAddress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publicKeyToBitcoinAddress.d.ts","sourceRoot":"","sources":["../../../src/utils/publicKeyToBitcoinAddress/publicKeyToBitcoinAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAM3D;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,cACzB,MAAM,GAAG,UAAU,gBACjB,kBAAkB,YACtB,cAAc,KACtB,MAeF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/selectUTXOs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { UTXO } from "../../types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Simple greedy coin selection
|
|
4
|
+
*
|
|
5
|
+
* @param utxos - The list of UTXOs to select from
|
|
6
|
+
* @param amount - The amount to spend
|
|
7
|
+
* @param feeRate - The fee rate in sat/vByte
|
|
8
|
+
* @returns The selected inputs, change amount, and fee
|
|
9
|
+
*/
|
|
10
|
+
export declare const selectUTXOs: ({ utxos, amount, feeRate, }: {
|
|
11
|
+
utxos: UTXO[];
|
|
12
|
+
amount: bigint;
|
|
13
|
+
feeRate: number;
|
|
14
|
+
}) => {
|
|
15
|
+
inputs: UTXO[];
|
|
16
|
+
change: bigint;
|
|
17
|
+
fee: bigint;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=selectUTXOs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectUTXOs.d.ts","sourceRoot":"","sources":["../../../src/utils/selectUTXOs/selectUTXOs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACjD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,gCAIrB;IACD,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,KAAG;IAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAiChD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/toBuffer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper to handle Buffer/Uint8Array compatibility issues
|
|
3
|
+
*
|
|
4
|
+
* @param data - The data to convert to a Buffer
|
|
5
|
+
* @returns The Buffer representation of the data
|
|
6
|
+
*/
|
|
7
|
+
export declare const toBuffer: (data: Uint8Array | Buffer) => Buffer;
|
|
8
|
+
//# sourceMappingURL=toBuffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toBuffer.d.ts","sourceRoot":"","sources":["../../../src/utils/toBuffer/toBuffer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,SAAU,UAAU,GAAG,MAAM,KAAG,MAGpD,CAAC"}
|