@dynamic-labs-wallet/node-btc 0.0.318 → 0.0.319-beta.1

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 CHANGED
@@ -158,7 +158,7 @@ class DynamicBtcWalletClient extends node.DynamicWalletClient {
158
158
  addressType,
159
159
  network
160
160
  }).accountAddress;
161
- await this.storeEncryptedBackupByWalletWithRetry({
161
+ const externalKeySharesWithBackupStatus = await this.storeEncryptedBackupByWalletWithRetry({
162
162
  accountAddress,
163
163
  externalServerKeyShares,
164
164
  password,
@@ -169,7 +169,8 @@ class DynamicBtcWalletClient extends node.DynamicWalletClient {
169
169
  accountAddress,
170
170
  rawPublicKey,
171
171
  publicKeyHex,
172
- externalServerKeyShares
172
+ externalServerKeyShares,
173
+ externalKeySharesWithBackupStatus
173
174
  };
174
175
  } catch (error) {
175
176
  logError({
@@ -569,7 +570,7 @@ class DynamicBtcWalletClient extends node.DynamicWalletClient {
569
570
  if (accountAddress !== expectedAddress) {
570
571
  throw new Error(`Public address mismatch: derived address ${accountAddress} !== expected address ${expectedAddress}`);
571
572
  }
572
- await this.storeEncryptedBackupByWalletWithRetry({
573
+ const externalKeySharesWithBackupStatus = await this.storeEncryptedBackupByWalletWithRetry({
573
574
  accountAddress,
574
575
  externalServerKeyShares,
575
576
  password,
@@ -580,7 +581,8 @@ class DynamicBtcWalletClient extends node.DynamicWalletClient {
580
581
  accountAddress,
581
582
  rawPublicKey,
582
583
  publicKeyHex,
583
- externalServerKeyShares
584
+ externalServerKeyShares,
585
+ externalKeySharesWithBackupStatus
584
586
  };
585
587
  } catch (error) {
586
588
  logError({
package/index.esm.js CHANGED
@@ -136,7 +136,7 @@ class DynamicBtcWalletClient extends DynamicWalletClient {
136
136
  addressType,
137
137
  network
138
138
  }).accountAddress;
139
- await this.storeEncryptedBackupByWalletWithRetry({
139
+ const externalKeySharesWithBackupStatus = await this.storeEncryptedBackupByWalletWithRetry({
140
140
  accountAddress,
141
141
  externalServerKeyShares,
142
142
  password,
@@ -147,7 +147,8 @@ class DynamicBtcWalletClient extends DynamicWalletClient {
147
147
  accountAddress,
148
148
  rawPublicKey,
149
149
  publicKeyHex,
150
- externalServerKeyShares
150
+ externalServerKeyShares,
151
+ externalKeySharesWithBackupStatus
151
152
  };
152
153
  } catch (error) {
153
154
  logError({
@@ -547,7 +548,7 @@ class DynamicBtcWalletClient extends DynamicWalletClient {
547
548
  if (accountAddress !== expectedAddress) {
548
549
  throw new Error(`Public address mismatch: derived address ${accountAddress} !== expected address ${expectedAddress}`);
549
550
  }
550
- await this.storeEncryptedBackupByWalletWithRetry({
551
+ const externalKeySharesWithBackupStatus = await this.storeEncryptedBackupByWalletWithRetry({
551
552
  accountAddress,
552
553
  externalServerKeyShares,
553
554
  password,
@@ -558,7 +559,8 @@ class DynamicBtcWalletClient extends DynamicWalletClient {
558
559
  accountAddress,
559
560
  rawPublicKey,
560
561
  publicKeyHex,
561
- externalServerKeyShares
562
+ externalServerKeyShares,
563
+ externalKeySharesWithBackupStatus
562
564
  };
563
565
  } catch (error) {
564
566
  logError({
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@dynamic-labs-wallet/node-btc",
3
- "version": "0.0.318",
3
+ "version": "0.0.319-beta.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "dependencies": {
7
- "@dynamic-labs-wallet/core": "0.0.318",
8
- "@dynamic-labs-wallet/node": "0.0.318",
9
- "@dynamic-labs-wallet/btc-utils": "0.0.318",
7
+ "@dynamic-labs-wallet/core": "0.0.319-beta.1",
8
+ "@dynamic-labs-wallet/node": "0.0.319-beta.1",
9
+ "@dynamic-labs-wallet/btc-utils": "0.0.319-beta.1",
10
10
  "@dynamic-labs/sdk-api-core": "^0.0.900",
11
11
  "bitcoinjs-lib": "^7.0.0",
12
12
  "tiny-secp256k1": "^2.2.3"
@@ -1,165 +0,0 @@
1
- import { DynamicWalletClient, type DynamicWalletClientProps, type ServerKeyShare, type ThresholdSignatureScheme, type EcdsaPublicKey, type BIP340KeygenResult, type EcdsaKeygenResult, type WalletProperties } from '@dynamic-labs-wallet/node';
2
- import type { SignMessageContext } from '@dynamic-labs/sdk-api-core';
3
- import { BitcoinAddressType, BitcoinNetwork, type BitcoinConfig } from '@dynamic-labs-wallet/core';
4
- export declare class DynamicBtcWalletClient extends DynamicWalletClient {
5
- readonly chainName = "BTC";
6
- constructor({ environmentId, baseApiUrl, baseMPCRelayApiUrl, enableMPCAccelerator, logger, debug, }: DynamicWalletClientProps);
7
- /**
8
- * Derives the Bitcoin account address
9
- * - BIP340 keys (32 bytes x-only): Only for Taproot addresses
10
- * - ECDSA keys (33/65 bytes): For all other address types (Legacy, SegWit, Native SegWit)
11
- * - Algorithm selection is automatic based on addressType
12
- * @param rawPublicKey - The raw public key to derive the account address from
13
- * @param addressType - The address type to derive the account address for
14
- * @param network - The network to derive the account address for
15
- * @returns The account address
16
- */
17
- deriveAccountAddress({ rawPublicKey, addressType, network, }: {
18
- rawPublicKey: any;
19
- addressType: BitcoinAddressType;
20
- network: BitcoinNetwork;
21
- }): {
22
- accountAddress: string;
23
- };
24
- /**
25
- * Gets wallet properties and derivation info for a given account address
26
- * @param accountAddress - The account address
27
- * @returns The wallet properties, derivation path, and address type
28
- */
29
- private getWalletDerivationInfo;
30
- /**
31
- * Verifies that the derived address matches the expected address
32
- * @param rawPublicKey - The raw public key
33
- * @param addressType - The address type
34
- * @param network - The network
35
- * @param expectedAddress - The expected address
36
- */
37
- private verifyWalletAddress;
38
- /**
39
- * Creates a new wallet account and stores the key shares in the wallet map.
40
- * @param thresholdSignatureScheme - The threshold signature scheme to use for the wallet.
41
- * @param password - The password to use for the wallet.
42
- * @param onError - The function to call if an error occurs.
43
- * @param backUpToClientShareService - Whether to back up the external server key shares to the client share service. By default, it is false.
44
- * @param bitcoinConfig - Bitcoin configuration (addressType, network)
45
- * @returns The account address, public key, raw public key, external server key shares, and wallet id.
46
- */
47
- createWalletAccount({ thresholdSignatureScheme, password, onError, backUpToClientShareService, bitcoinConfig, }: {
48
- thresholdSignatureScheme: ThresholdSignatureScheme;
49
- password?: string;
50
- onError?: (error: Error) => void;
51
- backUpToClientShareService?: boolean;
52
- bitcoinConfig: BitcoinConfig;
53
- }): Promise<{
54
- accountAddress: string;
55
- publicKeyHex: string;
56
- rawPublicKey: EcdsaPublicKey | Uint8Array | string | undefined;
57
- externalServerKeyShares: ServerKeyShare[];
58
- }>;
59
- /**
60
- * Signs a message for BTC using BIP-322 format
61
- *
62
- * The address type is automatically derived from the wallet's derivation path.
63
- * Supports both TAPROOT (BIP-86) and NATIVE_SEGWIT (BIP-84) address types.
64
- *
65
- * @param message - The message to sign
66
- * @param accountAddress - The account address
67
- * @param network - The Bitcoin network (MAINNET or TESTNET)
68
- * @param password - Optional password for encrypted backup shares
69
- * @param externalServerKeyShares - Optional external server key shares
70
- * @param context - Optional. Sign message context for API tracking
71
- * @param onError - Optional. Error callback function
72
- * @returns Promise resolving to the BIP-322 signature as a base64 string
73
- * @throws Error if required parameters are missing, derivation path is invalid, or signing fails
74
- */
75
- signMessage({ message, accountAddress, network, password, externalServerKeyShares, context, onError, }: {
76
- message: string;
77
- accountAddress: string;
78
- network: BitcoinNetwork;
79
- password?: string;
80
- externalServerKeyShares?: ServerKeyShare[];
81
- context?: SignMessageContext;
82
- onError?: (error: Error) => void;
83
- }): Promise<string>;
84
- /**
85
- * Signs a Bitcoin transaction (PSBT)
86
- *
87
- * The address type is automatically derived from the wallet's derivation path.
88
- * Only inputs belonging to the sender address are signed. Supports both TAPROOT
89
- * (BIP-341) and Native SegWit (BIP-143) signing methods.
90
- *
91
- * @param transaction - The PSBT to sign as a base64 string
92
- * @param senderAddress - The sender address (must match inputs to be signed)
93
- * @param network - The Bitcoin network (MAINNET or TESTNET)
94
- * @param password - Optional password for encrypted backup shares
95
- * @param externalServerKeyShares - Optional external server key shares
96
- * @param context - Optional. Sign message context for API tracking
97
- * @param onError - Optional. Error callback function
98
- * @returns Promise resolving to the signed PSBT as a base64 string
99
- * @throws Error if required parameters are missing, no inputs belong to sender address, or signing fails
100
- */
101
- signTransaction({ transaction, senderAddress, network, password, externalServerKeyShares, context, onError, }: {
102
- transaction: string;
103
- senderAddress: string;
104
- network: BitcoinNetwork;
105
- password?: string;
106
- externalServerKeyShares?: ServerKeyShare[];
107
- context?: SignMessageContext;
108
- onError?: (error: Error) => void;
109
- }): Promise<string>;
110
- /**
111
- * Exports the private key for a wallet
112
- * @param accountAddress - The account address to export the private key for
113
- * @param password - The password for encrypted backup shares
114
- * @param externalServerKeyShares - Optional external server key shares
115
- * @returns The private key in WIF format
116
- */
117
- exportPrivateKey({ accountAddress, password, externalServerKeyShares, }: {
118
- accountAddress: string;
119
- password?: string;
120
- externalServerKeyShares?: ServerKeyShare[];
121
- }): Promise<string>;
122
- /**
123
- * Exports the private key for a given account address offline using key shares
124
- * @param keyShares - The key shares to export the private key for
125
- * @param derivationPath - Optional derivation path
126
- * @param bitcoinConfig - Bitcoin configuration (address type, network)
127
- * @returns The private key in WIF format
128
- */
129
- offlineExportPrivateKey({ keyShares, derivationPath, bitcoinConfig, }: {
130
- keyShares: (EcdsaKeygenResult | BIP340KeygenResult)[];
131
- derivationPath?: string;
132
- bitcoinConfig?: BitcoinConfig;
133
- }): Promise<string>;
134
- /**
135
- * Imports a private key and stores the key shares in the wallet map.
136
- * @param privateKey - The private key to import (WIF format)
137
- * @param chainName - The chain name to use for the wallet
138
- * @param thresholdSignatureScheme - The threshold signature scheme to use for the wallet
139
- * @param password - The password to use for the wallet
140
- * @param onError - The function to call if an error occurs
141
- * @param backUpToClientShareService - Whether to back up the external server key shares to the client share service. By default, it is false.
142
- * @param bitcoinConfig - Bitcoin configuration (addressType, network)
143
- * @returns The account address, public key, raw public key, external server key shares
144
- */
145
- importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, backUpToClientShareService, onError, bitcoinConfig, }: {
146
- privateKey: string;
147
- chainName: string;
148
- thresholdSignatureScheme: ThresholdSignatureScheme;
149
- password?: string;
150
- backUpToClientShareService?: boolean;
151
- onError?: (error: Error) => void;
152
- bitcoinConfig: BitcoinConfig;
153
- }): Promise<{
154
- accountAddress: string;
155
- publicKeyHex: string;
156
- rawPublicKey: EcdsaPublicKey | Uint8Array | string | undefined;
157
- externalServerKeyShares: ServerKeyShare[];
158
- }>;
159
- /**
160
- * Gets the Bitcoin wallets
161
- * @returns The Bitcoin wallets
162
- */
163
- getBitcoinWallets(): Promise<WalletProperties[]>;
164
- }
165
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EAEnB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EAKtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAmCnG,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,QAAQ,CAAC,SAAS,SAAS;gBAEf,EACV,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,MAAM,EACN,KAAK,GACN,EAAE,wBAAwB;IAW3B;;;;;;;;;OASG;IACH,oBAAoB,CAAC,EACnB,YAAY,EACZ,WAAW,EACX,OAAO,GACR,EAAE;QACD,YAAY,EAAE,GAAG,CAAC;QAClB,WAAW,EAAE,kBAAkB,CAAC;QAChC,OAAO,EAAE,cAAc,CAAC;KACzB,GAAG;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE;IAQ9B;;;;OAIG;IACH,OAAO,CAAC,uBAAuB;IAsB/B;;;;;;OA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AAY,EAAE,cAAc,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;QAC/D,uBAAuB,EAAE,cAAc,EAAE,CAAC;KAC3C,CAAC;IAgHF;;;OAGG;IACG,iBAAiB,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;CAQvD"}
@@ -1,7 +0,0 @@
1
- export declare const ERROR_CREATE_WALLET_ACCOUNT = "Error creating wallet account";
2
- export declare const ERROR_ACCOUNT_ADDRESS_REQUIRED = "Account address is required";
3
- export declare const ERROR_SIGN_MESSAGE = "Error signing message";
4
- export declare const ERROR_SIGN_TRANSACTION = "Error signing transaction";
5
- export declare const ERROR_IMPORT_PRIVATE_KEY = "Error importing private key";
6
- export declare const ERROR_KEYGEN_FAILED = "Error with keygen";
7
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/client/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,kCAAkC,CAAC;AAC3E,eAAO,MAAM,8BAA8B,gCAAgC,CAAC;AAC5E,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAC1D,eAAO,MAAM,sBAAsB,8BAA8B,CAAC;AAClE,eAAO,MAAM,wBAAwB,gCAAgC,CAAC;AACtE,eAAO,MAAM,mBAAmB,sBAAsB,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from './client.js';
2
- export * from './constants.js';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
package/src/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './client/index.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}