@dynamic-labs/bitcoin 5.3.2 → 5.4.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/CHANGELOG.md +34 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/connectors/DynamicWaasBitcoinConnector/DynamicWaasBitcoinConnector.cjs +49 -25
- package/src/connectors/DynamicWaasBitcoinConnector/DynamicWaasBitcoinConnector.d.ts +34 -61
- package/src/connectors/DynamicWaasBitcoinConnector/DynamicWaasBitcoinConnector.js +50 -26
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,38 @@
|
|
|
1
1
|
|
|
2
|
+
### [5.4.1](https://github.com/dynamic-labs/dynamic-auth/compare/v5.4.0...v5.4.1) (2026-08-26)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* **webview-controller:** resolve which keychain key a session belongs to ([#12246](https://github.com/dynamic-labs/dynamic-auth/issues/12246)) ([3d110db](https://github.com/dynamic-labs/dynamic-auth/commit/3d110db831c6e9d82d07d86841f5c7733924b17e))
|
|
8
|
+
* **bitcoin:** forward the password through the BTC importPrivateKey override ([#12278](https://github.com/dynamic-labs/dynamic-auth/issues/12278)) ([21e1df3](https://github.com/dynamic-labs/dynamic-auth/commit/21e1df3e33e96e2efdb15ffa0fd29a441056202e))
|
|
9
|
+
* **react-native-extension:** recover 4.x expo-secure-store sessions on keychain miss ([#12254](https://github.com/dynamic-labs/dynamic-auth/issues/12254)) ([217e991](https://github.com/dynamic-labs/dynamic-auth/commit/217e991838f3073c12e2d2fab7a2e12830faad9e)), closes [#12092](https://github.com/dynamic-labs/dynamic-auth/issues/12092) [#12092](https://github.com/dynamic-labs/dynamic-auth/issues/12092) [#12092](https://github.com/dynamic-labs/dynamic-auth/issues/12092) [#12092](https://github.com/dynamic-labs/dynamic-auth/issues/12092) [#12242](https://github.com/dynamic-labs/dynamic-auth/issues/12242) [#12242](https://github.com/dynamic-labs/dynamic-auth/issues/12242)
|
|
10
|
+
* **transaction-card:** use walletConnector prop for network/fee instead of primaryWallet ([#12063](https://github.com/dynamic-labs/dynamic-auth/issues/12063)) ([81314d2](https://github.com/dynamic-labs/dynamic-auth/commit/81314d25fba4b20ab89631bc2d9ceeb9e2b6b2ac))
|
|
11
|
+
* **waas-svm:** instrument sponsorship retry attempts ([#12281](https://github.com/dynamic-labs/dynamic-auth/issues/12281)) ([7273a4b](https://github.com/dynamic-labs/dynamic-auth/commit/7273a4bc456cad512c0e9fbcd2abd66532a2f7df))
|
|
12
|
+
* **webview-controller:** recover 4.x secure-storage sessions and surface init failures ([#12242](https://github.com/dynamic-labs/dynamic-auth/issues/12242)) ([b51605c](https://github.com/dynamic-labs/dynamic-auth/commit/b51605cc9bdbb5d695173192c502a58d899bbbdd)), closes [#12094](https://github.com/dynamic-labs/dynamic-auth/issues/12094) [#12095](https://github.com/dynamic-labs/dynamic-auth/issues/12095) [#12098](https://github.com/dynamic-labs/dynamic-auth/issues/12098) [dynamic-labs/flutter-sdk#256](https://github.com/dynamic-labs/flutter-sdk/issues/256)
|
|
13
|
+
|
|
14
|
+
## [5.4.0](https://github.com/dynamic-labs/dynamic-auth/compare/v5.3.2...v5.4.0) (2026-08-25)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **aleo:** wire up signMessage on the WaaS Aleo connector ([#12235](https://github.com/dynamic-labs/dynamic-auth/issues/12235)) ([e56cbf5](https://github.com/dynamic-labs/dynamic-auth/commit/e56cbf5546bdcc21ce916dece43ae36dcea9b808))
|
|
20
|
+
* **waas:** thread isRawScalarImport through importPrivateKey for ed25519 chains ([#12220](https://github.com/dynamic-labs/dynamic-auth/issues/12220)) ([ced9efa](https://github.com/dynamic-labs/dynamic-auth/commit/ced9efac5fa5a4a1280383419f56fe22733722cd))
|
|
21
|
+
* **webview:** add policies message contract and controller ([#12248](https://github.com/dynamic-labs/dynamic-auth/issues/12248)) ([8557c1e](https://github.com/dynamic-labs/dynamic-auth/commit/8557c1ed3861e12f1f06b2bb610184813b577daa))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* **bitcoin:** pass the wallet's address type when signing ([#12265](https://github.com/dynamic-labs/dynamic-auth/issues/12265)) ([b8a8eab](https://github.com/dynamic-labs/dynamic-auth/commit/b8a8eab7e4cc294cc307fb10ea6814e76111a274))
|
|
27
|
+
* remediate high-severity tar vulnerability and prune a dead override ([#12268](https://github.com/dynamic-labs/dynamic-auth/issues/12268)) ([6b1b343](https://github.com/dynamic-labs/dynamic-auth/commit/6b1b343e7947e8da30012446677e342ae9bfe14a))
|
|
28
|
+
* **waas-svm:** fix retry-classification and environmentId gaps in [#12240](https://github.com/dynamic-labs/dynamic-auth/issues/12240) ([#12247](https://github.com/dynamic-labs/dynamic-auth/issues/12247)) ([e79cecc](https://github.com/dynamic-labs/dynamic-auth/commit/e79ceccd424c48c3a7f45fdd6ea288c269ac0171))
|
|
29
|
+
* **wallet-connect:** reopen WalletConnect IndexedDB when the browser closes the connection ([#12262](https://github.com/dynamic-labs/dynamic-auth/issues/12262)) ([1a20dde](https://github.com/dynamic-labs/dynamic-auth/commit/1a20ddeaeec590ae3390c9e47ef3c14738379b83))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Performance Improvements
|
|
33
|
+
|
|
34
|
+
* **ethereum-gasless-core:** parallel 7702 auth signing and long-poll sponsored-tx status ([#12225](https://github.com/dynamic-labs/dynamic-auth/issues/12225)) ([53ca916](https://github.com/dynamic-labs/dynamic-auth/commit/53ca91668f8dd839c52d55a0e5d7bb5257f7f415))
|
|
35
|
+
|
|
2
36
|
### [5.3.2](https://github.com/dynamic-labs/dynamic-auth/compare/v5.3.1...v5.3.2) (2026-08-19)
|
|
3
37
|
|
|
4
38
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/bitcoin",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.1",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"ecpair": "2.1.0",
|
|
30
30
|
"sats-connect": "4.2.1",
|
|
31
31
|
"jsontokens": "4.0.1",
|
|
32
|
-
"@dynamic-labs/assert-package-version": "5.
|
|
33
|
-
"@dynamic-labs/logger": "5.
|
|
34
|
-
"@dynamic-labs/types": "5.
|
|
35
|
-
"@dynamic-labs/utils": "5.
|
|
36
|
-
"@dynamic-labs/waas": "5.
|
|
37
|
-
"@dynamic-labs/wallet-book": "5.
|
|
38
|
-
"@dynamic-labs/wallet-connector-core": "5.
|
|
32
|
+
"@dynamic-labs/assert-package-version": "5.4.1",
|
|
33
|
+
"@dynamic-labs/logger": "5.4.1",
|
|
34
|
+
"@dynamic-labs/types": "5.4.1",
|
|
35
|
+
"@dynamic-labs/utils": "5.4.1",
|
|
36
|
+
"@dynamic-labs/waas": "5.4.1",
|
|
37
|
+
"@dynamic-labs/wallet-book": "5.4.1",
|
|
38
|
+
"@dynamic-labs/wallet-connector-core": "5.4.1",
|
|
39
39
|
"eventemitter3": "5.0.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {}
|
|
@@ -136,6 +136,32 @@ class DynamicWaasBitcoinConnector extends waas.withDynamicWaas(BitcoinWalletConn
|
|
|
136
136
|
: 'mainnet');
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* The address type the wallet's key was derived under, read back from the
|
|
141
|
+
* address itself.
|
|
142
|
+
*
|
|
143
|
+
* `bitcoinConfig.addressType` is the only thing that selects a BTC
|
|
144
|
+
* derivation path downstream (`getMPCChainConfig` throws without it), and a
|
|
145
|
+
* wallet created by an import carries no server-side derivation metadata to
|
|
146
|
+
* fall back on — so signing an imported wallet failed while a
|
|
147
|
+
* Dynamic-created one signed fine. The address already encodes the answer:
|
|
148
|
+
* witness v0 is P2WPKH (native segwit), v1 is P2TR (taproot), which are
|
|
149
|
+
* exactly the two types `importPrivateKey` accepts.
|
|
150
|
+
*
|
|
151
|
+
* Falls back to native segwit for an address that is not bech32 (a legacy
|
|
152
|
+
* P2PKH/P2SH encoding cannot come from this connector's own import or
|
|
153
|
+
* create paths) so a decode failure can never make signing impossible.
|
|
154
|
+
*/
|
|
155
|
+
getAddressTypeForSigning(walletAddress) {
|
|
156
|
+
try {
|
|
157
|
+
const { version } = bitcoinjsLib.address.fromBech32(walletAddress);
|
|
158
|
+
return (version === 1 ? 'taproot' : 'native_segwit');
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
this.logger.warn('Could not read the address type from the wallet address; assuming native segwit', { error, walletAddress });
|
|
162
|
+
return 'native_segwit';
|
|
163
|
+
}
|
|
164
|
+
}
|
|
139
165
|
supportsNetworkSwitching() {
|
|
140
166
|
return true;
|
|
141
167
|
}
|
|
@@ -474,33 +500,29 @@ class DynamicWaasBitcoinConnector extends waas.withDynamicWaas(BitcoinWalletConn
|
|
|
474
500
|
const _super = Object.create(null, {
|
|
475
501
|
createWalletAccount: { get: () => super.createWalletAccount }
|
|
476
502
|
});
|
|
477
|
-
return _tslib.__awaiter(this, arguments, void 0, function* (
|
|
478
|
-
var _a;
|
|
503
|
+
return _tslib.__awaiter(this, arguments, void 0, function* (params = {}) {
|
|
504
|
+
var _a, _b;
|
|
479
505
|
const finalBitcoinConfig = {
|
|
480
|
-
addressType: ((_a = bitcoinConfig === null ||
|
|
506
|
+
addressType: ((_b = (_a = params.bitcoinConfig) === null || _a === void 0 ? void 0 : _a.addressType) !== null && _b !== void 0 ? _b : 'native_segwit'),
|
|
481
507
|
network: yield this.getBitcoinNetworkEnum(),
|
|
482
508
|
};
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
thresholdSignatureScheme,
|
|
487
|
-
});
|
|
509
|
+
// Spread, so a field added to CreateWalletAccountParams later still
|
|
510
|
+
// reaches the base instead of being silently dropped here.
|
|
511
|
+
return _super.createWalletAccount.call(this, Object.assign(Object.assign({}, params), { bitcoinConfig: finalBitcoinConfig }));
|
|
488
512
|
});
|
|
489
513
|
}
|
|
490
514
|
/**
|
|
491
|
-
*
|
|
492
|
-
* @param
|
|
493
|
-
*
|
|
494
|
-
* @param publicAddressCheck - Optional public address to verify against
|
|
495
|
-
* @param addressType - Required address type for Bitcoin ('native_segwit' or 'taproot')
|
|
496
|
-
* @param legacyWalletId - Optional ID of the legacy wallet being upgraded
|
|
515
|
+
* Requires and validates `addressType` for Bitcoin, then delegates.
|
|
516
|
+
* @param params - See ImportPrivateKeyParams. `addressType` is mandatory
|
|
517
|
+
* here ('native_segwit' or 'taproot') and `privateKey` is WIF.
|
|
497
518
|
* @throws {DynamicError} If addressType is missing or invalid for BTC
|
|
498
519
|
*/
|
|
499
|
-
importPrivateKey(
|
|
520
|
+
importPrivateKey(params) {
|
|
500
521
|
const _super = Object.create(null, {
|
|
501
522
|
importPrivateKey: { get: () => super.importPrivateKey }
|
|
502
523
|
});
|
|
503
|
-
return _tslib.__awaiter(this,
|
|
524
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
525
|
+
const { addressType } = params;
|
|
504
526
|
if (!addressType) {
|
|
505
527
|
throw new utils.DynamicError('addressType is required for BTC importPrivateKey', 'addresstype_is_required_for_btc_importprivatekey');
|
|
506
528
|
}
|
|
@@ -508,13 +530,10 @@ class DynamicWaasBitcoinConnector extends waas.withDynamicWaas(BitcoinWalletConn
|
|
|
508
530
|
if (!validAddressTypes.includes(addressType)) {
|
|
509
531
|
throw new utils.DynamicError(`Invalid addressType: ${addressType}. Must be one of: ${validAddressTypes.join(', ')}`, 'invalid_addresstype_must_be_one_of');
|
|
510
532
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
publicAddressCheck,
|
|
516
|
-
thresholdSignatureScheme,
|
|
517
|
-
});
|
|
533
|
+
// Forwarded whole, never field-by-field: a re-declared parameter list is
|
|
534
|
+
// how `password` silently stopped reaching the base (see
|
|
535
|
+
// ImportPrivateKeyParams).
|
|
536
|
+
return _super.importPrivateKey.call(this, params);
|
|
518
537
|
});
|
|
519
538
|
}
|
|
520
539
|
/**
|
|
@@ -603,10 +622,14 @@ class DynamicWaasBitcoinConnector extends waas.withDynamicWaas(BitcoinWalletConn
|
|
|
603
622
|
accountAddress: this.getWalletIdentityAddress(),
|
|
604
623
|
});
|
|
605
624
|
const messageString = typeof message === 'string' ? message : message.raw;
|
|
625
|
+
const walletIdentityAddress = this.getWalletIdentityAddress();
|
|
606
626
|
return walletClient.signMessage({
|
|
607
|
-
accountAddress:
|
|
627
|
+
accountAddress: walletIdentityAddress,
|
|
608
628
|
authToken: (_e = this.getAuthToken) === null || _e === void 0 ? void 0 : _e.call(this),
|
|
609
|
-
bitcoinConfig: {
|
|
629
|
+
bitcoinConfig: {
|
|
630
|
+
addressType: this.getAddressTypeForSigning(walletIdentityAddress),
|
|
631
|
+
network: yield this.getBitcoinNetworkEnum(),
|
|
632
|
+
},
|
|
610
633
|
context,
|
|
611
634
|
elevatedAccessToken,
|
|
612
635
|
message: messageString,
|
|
@@ -838,6 +861,7 @@ class DynamicWaasBitcoinConnector extends waas.withDynamicWaas(BitcoinWalletConn
|
|
|
838
861
|
accountAddress: this.getWalletIdentityAddress(),
|
|
839
862
|
authToken: (_d = this.getAuthToken) === null || _d === void 0 ? void 0 : _d.call(this),
|
|
840
863
|
bitcoinConfig: {
|
|
864
|
+
addressType: this.getAddressTypeForSigning(this.getWalletIdentityAddress()),
|
|
841
865
|
network: yield this.getBitcoinNetworkEnum(),
|
|
842
866
|
},
|
|
843
867
|
elevatedAccessToken,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { BitcoinConfig } from '@dynamic-labs-wallet/browser-wallet-client';
|
|
2
1
|
import { Logger } from '@dynamic-labs/logger';
|
|
3
2
|
import { JwtVerifiedCredential, MFAAction, SignMessageContext, TokenScope } from '@dynamic-labs/sdk-api-core';
|
|
4
3
|
import { GenericNetwork, IUITransaction, WalletUiUtils } from '@dynamic-labs/types';
|
|
5
|
-
import { BitcoinSignPsbtResponse, Chain, IDynamicWaasConnector, ISendBalanceWalletConnector, InternalWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import { BitcoinSignPsbtResponse, Chain, CreateWalletAccountParams, IDynamicWaasConnector, ISendBalanceWalletConnector, ImportPrivateKeyParams, InternalWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
6
5
|
import type { DynamicWaasBitcoinConnectorProps, ParsedTransaction } from '../../types';
|
|
7
6
|
import { BitcoinTransaction, EmbeddedWalletSignPsbtRequest } from '../../types';
|
|
8
7
|
import { BitcoinWalletConnector } from '../BitcoinWalletConnector';
|
|
@@ -67,12 +66,7 @@ declare const DynamicWaasBitcoinConnector_base: (abstract new (...args: any[]) =
|
|
|
67
66
|
getWaasWalletClient(traceContext?: import("dist/packages/waas/utils/instrumentation").TraceContext | undefined, { forceRebuild }?: {
|
|
68
67
|
forceRebuild?: boolean | undefined;
|
|
69
68
|
} | undefined): Promise<import("@dynamic-labs-wallet/browser-wallet-client").DynamicWalletClient>;
|
|
70
|
-
createWalletAccount({ thresholdSignatureScheme, password, bitcoinConfig, businessAccountId, }?: {
|
|
71
|
-
thresholdSignatureScheme?: string | undefined;
|
|
72
|
-
password?: string | undefined;
|
|
73
|
-
bitcoinConfig?: BitcoinConfig | undefined;
|
|
74
|
-
businessAccountId?: string | undefined;
|
|
75
|
-
} | undefined): Promise<{
|
|
69
|
+
createWalletAccount({ thresholdSignatureScheme, password, bitcoinConfig, businessAccountId, }?: CreateWalletAccountParams | undefined): Promise<{
|
|
76
70
|
chainName: string;
|
|
77
71
|
accountAddress: string;
|
|
78
72
|
publicKeyHex: string;
|
|
@@ -92,25 +86,18 @@ declare const DynamicWaasBitcoinConnector_base: (abstract new (...args: any[]) =
|
|
|
92
86
|
}): Promise<{
|
|
93
87
|
shareSetId: string;
|
|
94
88
|
}>;
|
|
95
|
-
importPrivateKey({ privateKey, thresholdSignatureScheme, publicAddressCheck, addressType, legacyWalletId, password, }:
|
|
96
|
-
privateKey: string;
|
|
97
|
-
thresholdSignatureScheme?: string | undefined;
|
|
98
|
-
publicAddressCheck?: string | undefined;
|
|
99
|
-
addressType?: string | undefined;
|
|
100
|
-
legacyWalletId?: string | undefined;
|
|
101
|
-
password?: string | undefined;
|
|
102
|
-
}): Promise<void>;
|
|
89
|
+
importPrivateKey({ privateKey, thresholdSignatureScheme, publicAddressCheck, addressType, legacyWalletId, password, isRawScalarImport, }: ImportPrivateKeyParams): Promise<void>;
|
|
103
90
|
migrateFromFireblocks({ deviceId, jwt, walletPassword, ncwStorage, expectedAddresses, coinTypes, password, }: {
|
|
104
91
|
deviceId: string;
|
|
105
92
|
jwt: string;
|
|
106
93
|
walletPassword: string;
|
|
107
|
-
ncwStorage: Record<string, string>;
|
|
108
|
-
* Gets the current Bitcoin network id (1 mainnet, 2 testnet)
|
|
109
|
-
*/
|
|
94
|
+
ncwStorage: Record<string, string>;
|
|
110
95
|
expectedAddresses: Record<string, string>;
|
|
111
96
|
coinTypes?: Record<string, number> | undefined;
|
|
112
97
|
password?: string | undefined;
|
|
113
|
-
}): Promise<Record<string, unknown>>;
|
|
98
|
+
}): Promise<Record<string, unknown>>; /**
|
|
99
|
+
* Gets the current Bitcoin network id (1 mainnet, 2 testnet)
|
|
100
|
+
*/
|
|
114
101
|
exportPrivateKey({ accountAddress, displayContainer, password, }?: {
|
|
115
102
|
accountAddress?: string | undefined;
|
|
116
103
|
displayContainer?: HTMLIFrameElement | undefined;
|
|
@@ -119,10 +106,7 @@ declare const DynamicWaasBitcoinConnector_base: (abstract new (...args: any[]) =
|
|
|
119
106
|
getExportHandler(): {
|
|
120
107
|
clear: () => void;
|
|
121
108
|
};
|
|
122
|
-
exportClientKeyshares({ accountAddress, password, }:
|
|
123
|
-
accountAddress: string;
|
|
124
|
-
password?: string | undefined;
|
|
125
|
-
}): Promise<void>;
|
|
109
|
+
exportClientKeyshares({ accountAddress, password, }: import("@dynamic-labs/wallet-connector-core").ExportClientKeysharesParams): Promise<void>;
|
|
126
110
|
runBackupLifecycle({ provider, accountAddress, password, performBackup, }: {
|
|
127
111
|
provider: string;
|
|
128
112
|
accountAddress: string;
|
|
@@ -138,11 +122,7 @@ declare const DynamicWaasBitcoinConnector_base: (abstract new (...args: any[]) =
|
|
|
138
122
|
};
|
|
139
123
|
}) => Promise<void>;
|
|
140
124
|
}): Promise<void>;
|
|
141
|
-
backupKeySharesToGoogleDrive({ accountAddress, password, googleDriveAccessToken, }:
|
|
142
|
-
accountAddress: string;
|
|
143
|
-
password?: string | undefined;
|
|
144
|
-
googleDriveAccessToken?: string | undefined;
|
|
145
|
-
}): Promise<void>;
|
|
125
|
+
backupKeySharesToGoogleDrive({ accountAddress, password, googleDriveAccessToken, }: import("@dynamic-labs/wallet-connector-core").BackupKeySharesToGoogleDriveParams): Promise<void>;
|
|
146
126
|
exportClientKeysharesFromGoogleDrive({ accountAddress, password, }: {
|
|
147
127
|
accountAddress: string;
|
|
148
128
|
password?: string | undefined;
|
|
@@ -156,24 +136,13 @@ declare const DynamicWaasBitcoinConnector_base: (abstract new (...args: any[]) =
|
|
|
156
136
|
}): Promise<void>;
|
|
157
137
|
hideICloudSignIn(): Promise<void>;
|
|
158
138
|
isICloudAuthenticated(): Promise<boolean>;
|
|
159
|
-
refreshWalletAccountShares({ accountAddress, password, }:
|
|
160
|
-
|
|
161
|
-
password?: string | undefined;
|
|
162
|
-
}): Promise<void>;
|
|
163
|
-
reshareWalletAccountShares({ accountAddress, thresholdSignatureScheme, password, }: {
|
|
164
|
-
accountAddress: string;
|
|
165
|
-
thresholdSignatureScheme: string;
|
|
166
|
-
password?: string | undefined;
|
|
167
|
-
}): Promise<void>;
|
|
139
|
+
refreshWalletAccountShares({ accountAddress, password, }: import("@dynamic-labs/wallet-connector-core").RefreshWalletAccountSharesParams): Promise<void>;
|
|
140
|
+
reshareWalletAccountShares({ accountAddress, thresholdSignatureScheme, password, }: import("@dynamic-labs/wallet-connector-core").ReshareWalletAccountSharesParams): Promise<void>;
|
|
168
141
|
revokeDelegation({ accountAddress, password, }: {
|
|
169
142
|
accountAddress: string;
|
|
170
143
|
password?: string | undefined;
|
|
171
144
|
}): Promise<void>;
|
|
172
|
-
updatePassword({ accountAddress, existingPassword, newPassword, }:
|
|
173
|
-
accountAddress: string;
|
|
174
|
-
existingPassword?: string | undefined;
|
|
175
|
-
newPassword: string;
|
|
176
|
-
}): Promise<void>;
|
|
145
|
+
updatePassword({ accountAddress, existingPassword, newPassword, }: import("@dynamic-labs/wallet-connector-core").UpdatePasswordParams): Promise<void>;
|
|
177
146
|
setPassword({ accountAddress, newPassword, }: {
|
|
178
147
|
accountAddress: string;
|
|
179
148
|
newPassword: string;
|
|
@@ -289,6 +258,23 @@ export declare class DynamicWaasBitcoinConnector extends DynamicWaasBitcoinConne
|
|
|
289
258
|
* the active address automatically.
|
|
290
259
|
*/
|
|
291
260
|
private getBitcoinNetworkEnum;
|
|
261
|
+
/**
|
|
262
|
+
* The address type the wallet's key was derived under, read back from the
|
|
263
|
+
* address itself.
|
|
264
|
+
*
|
|
265
|
+
* `bitcoinConfig.addressType` is the only thing that selects a BTC
|
|
266
|
+
* derivation path downstream (`getMPCChainConfig` throws without it), and a
|
|
267
|
+
* wallet created by an import carries no server-side derivation metadata to
|
|
268
|
+
* fall back on — so signing an imported wallet failed while a
|
|
269
|
+
* Dynamic-created one signed fine. The address already encodes the answer:
|
|
270
|
+
* witness v0 is P2WPKH (native segwit), v1 is P2TR (taproot), which are
|
|
271
|
+
* exactly the two types `importPrivateKey` accepts.
|
|
272
|
+
*
|
|
273
|
+
* Falls back to native segwit for an address that is not bech32 (a legacy
|
|
274
|
+
* P2PKH/P2SH encoding cannot come from this connector's own import or
|
|
275
|
+
* create paths) so a decode failure can never make signing impossible.
|
|
276
|
+
*/
|
|
277
|
+
private getAddressTypeForSigning;
|
|
292
278
|
supportsNetworkSwitching(): boolean;
|
|
293
279
|
/**
|
|
294
280
|
* Testnet when the testnet network (id 2) is selected — drives the widget's
|
|
@@ -424,32 +410,19 @@ export declare class DynamicWaasBitcoinConnector extends DynamicWaasBitcoinConne
|
|
|
424
410
|
* @param bitcoinConfig - Bitcoin configuration (addressType, network)
|
|
425
411
|
* @returns The created wallet account information
|
|
426
412
|
*/
|
|
427
|
-
createWalletAccount(
|
|
428
|
-
thresholdSignatureScheme?: string;
|
|
429
|
-
password?: string;
|
|
430
|
-
bitcoinConfig?: BitcoinConfig;
|
|
431
|
-
}): Promise<{
|
|
413
|
+
createWalletAccount(params?: CreateWalletAccountParams): Promise<{
|
|
432
414
|
chainName: string;
|
|
433
415
|
accountAddress: string;
|
|
434
416
|
publicKeyHex: string;
|
|
435
417
|
rawPublicKey: string | Uint8Array | undefined;
|
|
436
418
|
}>;
|
|
437
419
|
/**
|
|
438
|
-
*
|
|
439
|
-
* @param
|
|
440
|
-
*
|
|
441
|
-
* @param publicAddressCheck - Optional public address to verify against
|
|
442
|
-
* @param addressType - Required address type for Bitcoin ('native_segwit' or 'taproot')
|
|
443
|
-
* @param legacyWalletId - Optional ID of the legacy wallet being upgraded
|
|
420
|
+
* Requires and validates `addressType` for Bitcoin, then delegates.
|
|
421
|
+
* @param params - See ImportPrivateKeyParams. `addressType` is mandatory
|
|
422
|
+
* here ('native_segwit' or 'taproot') and `privateKey` is WIF.
|
|
444
423
|
* @throws {DynamicError} If addressType is missing or invalid for BTC
|
|
445
424
|
*/
|
|
446
|
-
importPrivateKey(
|
|
447
|
-
privateKey: string;
|
|
448
|
-
thresholdSignatureScheme?: string;
|
|
449
|
-
publicAddressCheck?: string;
|
|
450
|
-
addressType?: string;
|
|
451
|
-
legacyWalletId?: string;
|
|
452
|
-
}): Promise<void>;
|
|
425
|
+
importPrivateKey(params: ImportPrivateKeyParams): Promise<void>;
|
|
453
426
|
/**
|
|
454
427
|
* Gets the wallet client for a specific account address and sets it as
|
|
455
428
|
* active — unless `accountAddress` is just a different network-tagged
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
-
import { networks, Psbt } from 'bitcoinjs-lib';
|
|
3
|
+
import { address, networks, Psbt } from 'bitcoinjs-lib';
|
|
4
4
|
import { Logger } from '@dynamic-labs/logger';
|
|
5
5
|
import { MFAAction, TokenScope } from '@dynamic-labs/sdk-api-core';
|
|
6
6
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
@@ -132,6 +132,32 @@ class DynamicWaasBitcoinConnector extends withDynamicWaas(BitcoinWalletConnector
|
|
|
132
132
|
: 'mainnet');
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* The address type the wallet's key was derived under, read back from the
|
|
137
|
+
* address itself.
|
|
138
|
+
*
|
|
139
|
+
* `bitcoinConfig.addressType` is the only thing that selects a BTC
|
|
140
|
+
* derivation path downstream (`getMPCChainConfig` throws without it), and a
|
|
141
|
+
* wallet created by an import carries no server-side derivation metadata to
|
|
142
|
+
* fall back on — so signing an imported wallet failed while a
|
|
143
|
+
* Dynamic-created one signed fine. The address already encodes the answer:
|
|
144
|
+
* witness v0 is P2WPKH (native segwit), v1 is P2TR (taproot), which are
|
|
145
|
+
* exactly the two types `importPrivateKey` accepts.
|
|
146
|
+
*
|
|
147
|
+
* Falls back to native segwit for an address that is not bech32 (a legacy
|
|
148
|
+
* P2PKH/P2SH encoding cannot come from this connector's own import or
|
|
149
|
+
* create paths) so a decode failure can never make signing impossible.
|
|
150
|
+
*/
|
|
151
|
+
getAddressTypeForSigning(walletAddress) {
|
|
152
|
+
try {
|
|
153
|
+
const { version } = address.fromBech32(walletAddress);
|
|
154
|
+
return (version === 1 ? 'taproot' : 'native_segwit');
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
this.logger.warn('Could not read the address type from the wallet address; assuming native segwit', { error, walletAddress });
|
|
158
|
+
return 'native_segwit';
|
|
159
|
+
}
|
|
160
|
+
}
|
|
135
161
|
supportsNetworkSwitching() {
|
|
136
162
|
return true;
|
|
137
163
|
}
|
|
@@ -470,33 +496,29 @@ class DynamicWaasBitcoinConnector extends withDynamicWaas(BitcoinWalletConnector
|
|
|
470
496
|
const _super = Object.create(null, {
|
|
471
497
|
createWalletAccount: { get: () => super.createWalletAccount }
|
|
472
498
|
});
|
|
473
|
-
return __awaiter(this, arguments, void 0, function* (
|
|
474
|
-
var _a;
|
|
499
|
+
return __awaiter(this, arguments, void 0, function* (params = {}) {
|
|
500
|
+
var _a, _b;
|
|
475
501
|
const finalBitcoinConfig = {
|
|
476
|
-
addressType: ((_a = bitcoinConfig === null ||
|
|
502
|
+
addressType: ((_b = (_a = params.bitcoinConfig) === null || _a === void 0 ? void 0 : _a.addressType) !== null && _b !== void 0 ? _b : 'native_segwit'),
|
|
477
503
|
network: yield this.getBitcoinNetworkEnum(),
|
|
478
504
|
};
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
thresholdSignatureScheme,
|
|
483
|
-
});
|
|
505
|
+
// Spread, so a field added to CreateWalletAccountParams later still
|
|
506
|
+
// reaches the base instead of being silently dropped here.
|
|
507
|
+
return _super.createWalletAccount.call(this, Object.assign(Object.assign({}, params), { bitcoinConfig: finalBitcoinConfig }));
|
|
484
508
|
});
|
|
485
509
|
}
|
|
486
510
|
/**
|
|
487
|
-
*
|
|
488
|
-
* @param
|
|
489
|
-
*
|
|
490
|
-
* @param publicAddressCheck - Optional public address to verify against
|
|
491
|
-
* @param addressType - Required address type for Bitcoin ('native_segwit' or 'taproot')
|
|
492
|
-
* @param legacyWalletId - Optional ID of the legacy wallet being upgraded
|
|
511
|
+
* Requires and validates `addressType` for Bitcoin, then delegates.
|
|
512
|
+
* @param params - See ImportPrivateKeyParams. `addressType` is mandatory
|
|
513
|
+
* here ('native_segwit' or 'taproot') and `privateKey` is WIF.
|
|
493
514
|
* @throws {DynamicError} If addressType is missing or invalid for BTC
|
|
494
515
|
*/
|
|
495
|
-
importPrivateKey(
|
|
516
|
+
importPrivateKey(params) {
|
|
496
517
|
const _super = Object.create(null, {
|
|
497
518
|
importPrivateKey: { get: () => super.importPrivateKey }
|
|
498
519
|
});
|
|
499
|
-
return __awaiter(this,
|
|
520
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
521
|
+
const { addressType } = params;
|
|
500
522
|
if (!addressType) {
|
|
501
523
|
throw new DynamicError('addressType is required for BTC importPrivateKey', 'addresstype_is_required_for_btc_importprivatekey');
|
|
502
524
|
}
|
|
@@ -504,13 +526,10 @@ class DynamicWaasBitcoinConnector extends withDynamicWaas(BitcoinWalletConnector
|
|
|
504
526
|
if (!validAddressTypes.includes(addressType)) {
|
|
505
527
|
throw new DynamicError(`Invalid addressType: ${addressType}. Must be one of: ${validAddressTypes.join(', ')}`, 'invalid_addresstype_must_be_one_of');
|
|
506
528
|
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
publicAddressCheck,
|
|
512
|
-
thresholdSignatureScheme,
|
|
513
|
-
});
|
|
529
|
+
// Forwarded whole, never field-by-field: a re-declared parameter list is
|
|
530
|
+
// how `password` silently stopped reaching the base (see
|
|
531
|
+
// ImportPrivateKeyParams).
|
|
532
|
+
return _super.importPrivateKey.call(this, params);
|
|
514
533
|
});
|
|
515
534
|
}
|
|
516
535
|
/**
|
|
@@ -599,10 +618,14 @@ class DynamicWaasBitcoinConnector extends withDynamicWaas(BitcoinWalletConnector
|
|
|
599
618
|
accountAddress: this.getWalletIdentityAddress(),
|
|
600
619
|
});
|
|
601
620
|
const messageString = typeof message === 'string' ? message : message.raw;
|
|
621
|
+
const walletIdentityAddress = this.getWalletIdentityAddress();
|
|
602
622
|
return walletClient.signMessage({
|
|
603
|
-
accountAddress:
|
|
623
|
+
accountAddress: walletIdentityAddress,
|
|
604
624
|
authToken: (_e = this.getAuthToken) === null || _e === void 0 ? void 0 : _e.call(this),
|
|
605
|
-
bitcoinConfig: {
|
|
625
|
+
bitcoinConfig: {
|
|
626
|
+
addressType: this.getAddressTypeForSigning(walletIdentityAddress),
|
|
627
|
+
network: yield this.getBitcoinNetworkEnum(),
|
|
628
|
+
},
|
|
606
629
|
context,
|
|
607
630
|
elevatedAccessToken,
|
|
608
631
|
message: messageString,
|
|
@@ -834,6 +857,7 @@ class DynamicWaasBitcoinConnector extends withDynamicWaas(BitcoinWalletConnector
|
|
|
834
857
|
accountAddress: this.getWalletIdentityAddress(),
|
|
835
858
|
authToken: (_d = this.getAuthToken) === null || _d === void 0 ? void 0 : _d.call(this),
|
|
836
859
|
bitcoinConfig: {
|
|
860
|
+
addressType: this.getAddressTypeForSigning(this.getWalletIdentityAddress()),
|
|
837
861
|
network: yield this.getBitcoinNetworkEnum(),
|
|
838
862
|
},
|
|
839
863
|
elevatedAccessToken,
|