@dynamic-labs-wallet/btc-utils 0.0.353 → 0.1.0-request-signing
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 +681 -136
- package/index.esm.js +672 -138
- package/internal/core/ed_bls12_377.cjs +1 -1
- package/internal/core/ed_bls12_377.d.ts +1 -0
- package/internal/core/ed_bls12_377.js +1 -1
- package/internal/core/native.d.ts +1 -0
- package/package.json +5 -4
- package/src/assertSighashAllowed/assertSighashAllowed.d.ts +21 -0
- package/src/assertSighashAllowed/assertSighashAllowed.d.ts.map +1 -0
- package/src/assertSighashAllowed/index.d.ts +2 -0
- package/src/assertSighashAllowed/index.d.ts.map +1 -0
- package/src/buildToSpendTx/buildToSpendTx.d.ts +12 -0
- package/src/buildToSpendTx/buildToSpendTx.d.ts.map +1 -0
- package/src/buildToSpendTx/index.d.ts +2 -0
- package/src/buildToSpendTx/index.d.ts.map +1 -0
- package/src/bytesEqual/bytesEqual.d.ts +10 -0
- package/src/bytesEqual/bytesEqual.d.ts.map +1 -0
- package/src/bytesEqual/index.d.ts +2 -0
- package/src/bytesEqual/index.d.ts.map +1 -0
- package/src/calculateBip322Hash/calculateBip322Hash.d.ts.map +1 -1
- package/src/computeBip322HashHex/computeBip322HashHex.d.ts +2 -4
- package/src/computeBip322HashHex/computeBip322HashHex.d.ts.map +1 -1
- package/src/convertSignatureToDER/convertSignatureToDER.d.ts +4 -1
- package/src/convertSignatureToDER/convertSignatureToDER.d.ts.map +1 -1
- package/src/convertSignatureToTaprootBuffer/convertSignatureToTaprootBuffer.d.ts +5 -2
- package/src/convertSignatureToTaprootBuffer/convertSignatureToTaprootBuffer.d.ts.map +1 -1
- package/src/doesInputBelongToAddress/doesInputBelongToAddress.d.ts +15 -4
- package/src/doesInputBelongToAddress/doesInputBelongToAddress.d.ts.map +1 -1
- package/src/extractPsbtIntentOperation/extractPsbtIntentOperation.d.ts +36 -0
- package/src/extractPsbtIntentOperation/extractPsbtIntentOperation.d.ts.map +1 -0
- package/src/extractPsbtIntentOperation/index.d.ts +3 -0
- package/src/extractPsbtIntentOperation/index.d.ts.map +1 -0
- package/src/extractPsbtSighashes/extractPsbtSighashes.d.ts +6 -2
- package/src/extractPsbtSighashes/extractPsbtSighashes.d.ts.map +1 -1
- package/src/filterInputsBySigningIndexes/filterInputsBySigningIndexes.d.ts +12 -0
- package/src/filterInputsBySigningIndexes/filterInputsBySigningIndexes.d.ts.map +1 -0
- package/src/filterInputsBySigningIndexes/index.d.ts +2 -0
- package/src/filterInputsBySigningIndexes/index.d.ts.map +1 -0
- package/src/getBtcChainId/getBtcChainId.d.ts +13 -0
- package/src/getBtcChainId/getBtcChainId.d.ts.map +1 -0
- package/src/getBtcChainId/index.d.ts +2 -0
- package/src/getBtcChainId/index.d.ts.map +1 -0
- package/src/getFeeRates/getFeeRates.d.ts +12 -8
- package/src/getFeeRates/getFeeRates.d.ts.map +1 -1
- package/src/getSegwitV0ScriptCode/getSegwitV0ScriptCode.d.ts +20 -0
- package/src/getSegwitV0ScriptCode/getSegwitV0ScriptCode.d.ts.map +1 -0
- package/src/getSegwitV0ScriptCode/index.d.ts +2 -0
- package/src/getSegwitV0ScriptCode/index.d.ts.map +1 -0
- package/src/getSigHashType/getSigHashType.d.ts +21 -0
- package/src/getSigHashType/getSigHashType.d.ts.map +1 -0
- package/src/getSigHashType/index.d.ts +2 -0
- package/src/getSigHashType/index.d.ts.map +1 -0
- package/src/getUTXOs/getUTXOs.d.ts +2 -2
- package/src/getUTXOs/getUTXOs.d.ts.map +1 -1
- package/src/index.d.ts +11 -0
- package/src/index.d.ts.map +1 -1
- package/src/isP2wshOutputScript/index.d.ts +2 -0
- package/src/isP2wshOutputScript/index.d.ts.map +1 -0
- package/src/isP2wshOutputScript/isP2wshOutputScript.d.ts +10 -0
- package/src/isP2wshOutputScript/isP2wshOutputScript.d.ts.map +1 -0
- package/src/resolveBitcoinAddressType/index.d.ts +2 -0
- package/src/resolveBitcoinAddressType/index.d.ts.map +1 -0
- package/src/resolveBitcoinAddressType/resolveBitcoinAddressType.d.ts +34 -0
- package/src/resolveBitcoinAddressType/resolveBitcoinAddressType.d.ts.map +1 -0
- package/src/resolveRpcUrl/index.d.ts +2 -0
- package/src/resolveRpcUrl/index.d.ts.map +1 -0
- package/src/resolveRpcUrl/resolveRpcUrl.d.ts +14 -0
- package/src/resolveRpcUrl/resolveRpcUrl.d.ts.map +1 -0
- package/src/rpcFetch/index.d.ts +2 -0
- package/src/rpcFetch/index.d.ts.map +1 -0
- package/src/rpcFetch/rpcFetch.d.ts +9 -0
- package/src/rpcFetch/rpcFetch.d.ts.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/isP2wshOutputScript/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if an output script (scriptPubKey) is P2WSH: OP_0 <32-byte sha256(witnessScript)>
|
|
3
|
+
*
|
|
4
|
+
* ArrayLike keeps this callable with Buffer or Uint8Array — the iframe build
|
|
5
|
+
* compiles with browser typings where Buffer is not assignable to Uint8Array.
|
|
6
|
+
* @param script - The output script to check
|
|
7
|
+
* @returns True if the script has the P2WSH shape
|
|
8
|
+
*/
|
|
9
|
+
export declare const isP2wshOutputScript: (script: ArrayLike<number>) => boolean;
|
|
10
|
+
//# sourceMappingURL=isP2wshOutputScript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isP2wshOutputScript.d.ts","sourceRoot":"","sources":["../../src/isP2wshOutputScript/isP2wshOutputScript.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,WAAY,SAAS,CAAC,MAAM,CAAC,KAAG,OACE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resolveBitcoinAddressType/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BitcoinAddressType } from '@dynamic-labs-wallet/core';
|
|
2
|
+
/**
|
|
3
|
+
* Infers the Bitcoin address type from a bech32/bech32m account address.
|
|
4
|
+
*
|
|
5
|
+
* The character immediately after the '1' separator encodes the witness
|
|
6
|
+
* version: 'q' => v0 (P2WPKH, native segwit), 'p' => v1 (P2TR, taproot). The
|
|
7
|
+
* type is intrinsic to the address, so this works regardless of wallet
|
|
8
|
+
* metadata and for every network prefix (`bc1…`, `tb1…`, `bcrt1…`). Legacy
|
|
9
|
+
* (`1…`/`3…`) addresses are not supported and return undefined.
|
|
10
|
+
*
|
|
11
|
+
* @param address - The Bitcoin account address
|
|
12
|
+
* @returns The inferred BitcoinAddressType, or undefined if it cannot be determined
|
|
13
|
+
*/
|
|
14
|
+
export declare const getAddressTypeFromAddress: (address: string) => BitcoinAddressType | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the address type a BTC signing operation must use.
|
|
17
|
+
*
|
|
18
|
+
* Imported wallets are non-HD: the MPC server derives them with an empty path
|
|
19
|
+
* and persists `"[]"`, so a derivation path cannot be relied on to carry the
|
|
20
|
+
* address type. The account address always can — the witness version is part
|
|
21
|
+
* of the address — so it backs the path up rather than the other way around.
|
|
22
|
+
*
|
|
23
|
+
* @param addressType - Address type already recorded against the wallet, if any
|
|
24
|
+
* @param derivationPath - Serialized derivation path, `"[]"` for imported wallets
|
|
25
|
+
* @param accountAddress - The wallet's account address
|
|
26
|
+
* @returns The resolved BitcoinAddressType
|
|
27
|
+
* @throws If none of the three inputs can determine the address type
|
|
28
|
+
*/
|
|
29
|
+
export declare const resolveBitcoinAddressType: ({ addressType, derivationPath, accountAddress, }: {
|
|
30
|
+
accountAddress?: string;
|
|
31
|
+
addressType?: BitcoinAddressType;
|
|
32
|
+
derivationPath?: string | null;
|
|
33
|
+
}) => BitcoinAddressType;
|
|
34
|
+
//# sourceMappingURL=resolveBitcoinAddressType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveBitcoinAddressType.d.ts","sourceRoot":"","sources":["../../src/resolveBitcoinAddressType/resolveBitcoinAddressType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAI/D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB,YAAa,MAAM,KAAG,kBAAkB,GAAG,SAkBhF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB,qDAInC;IACD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,KAAG,kBAmBH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resolveRpcUrl/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BitcoinNetwork } from '@dynamic-labs-wallet/core';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the Esplora-compatible base URL to use for a network.
|
|
4
|
+
* Falls back to the default (mempool.space) when no custom URL is given.
|
|
5
|
+
*
|
|
6
|
+
* @param network - The Bitcoin network
|
|
7
|
+
* @param rpcUrl - Optional custom Esplora-compatible base URL
|
|
8
|
+
* @returns The base URL without a trailing slash
|
|
9
|
+
*/
|
|
10
|
+
export declare const resolveRpcUrl: ({ network, rpcUrl }: {
|
|
11
|
+
network: BitcoinNetwork;
|
|
12
|
+
rpcUrl?: string;
|
|
13
|
+
}) => string;
|
|
14
|
+
//# sourceMappingURL=resolveRpcUrl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveRpcUrl.d.ts","sourceRoot":"","sources":["../../src/resolveRpcUrl/resolveRpcUrl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAKhE;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,wBAAyB;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,KAAG,MAwBjG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rpcFetch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fetch wrapper for Esplora requests. Requests to a custom `rpcUrl` do not follow
|
|
3
|
+
* redirects, so they cannot be bounced to a host other than the configured backend.
|
|
4
|
+
*
|
|
5
|
+
* @param url - The full request URL
|
|
6
|
+
* @param rpcUrl - The custom RPC URL the request was built from, if any
|
|
7
|
+
*/
|
|
8
|
+
export declare const rpcFetch: (url: string, rpcUrl?: string) => Promise<Response>;
|
|
9
|
+
//# sourceMappingURL=rpcFetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpcFetch.d.ts","sourceRoot":"","sources":["../../src/rpcFetch/rpcFetch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,QAAS,MAAM,WAAW,MAAM,KAAG,OAAO,CAAC,QAAQ,CACf,CAAC"}
|