@dynamic-labs/bitcoin 5.4.0 → 5.5.0
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 +27 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/connectors/DynamicWaasBitcoinConnector/DynamicWaasBitcoinConnector.cjs +49 -26
- package/src/connectors/DynamicWaasBitcoinConnector/DynamicWaasBitcoinConnector.d.ts +34 -71
- package/src/connectors/DynamicWaasBitcoinConnector/DynamicWaasBitcoinConnector.js +49 -26
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,31 @@
|
|
|
1
1
|
|
|
2
|
+
## [5.5.0](https://github.com/dynamic-labs/dynamic-auth/compare/v5.4.1...v5.5.0) (2026-08-31)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **waas-evm:** route embedded EVM sends through gas sponsorship when enabled ([#12306](https://github.com/dynamic-labs/dynamic-auth/issues/12306)) ([6046ff3](https://github.com/dynamic-labs/dynamic-auth/commit/6046ff362d8de9402793bdaa7319fda645ff4c04))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* **bitcoin:** resolve the active BTC wallet and network correctly across the widget ([#12308](https://github.com/dynamic-labs/dynamic-auth/issues/12308)) ([13e9eae](https://github.com/dynamic-labs/dynamic-auth/commit/13e9eaec19b3925db507c878988cfd82da5a6de6))
|
|
13
|
+
* **btc:** unbreak BTC transaction confirmation, testnet balances and taproot testnet switching ([#12305](https://github.com/dynamic-labs/dynamic-auth/issues/12305)) ([5fd999c](https://github.com/dynamic-labs/dynamic-auth/commit/5fd999c4c819d3a74e967c0cfa77c5877a74906b))
|
|
14
|
+
* **react-native-extension:** stop leaking expo-secure-store into consumer autolinking ([#12296](https://github.com/dynamic-labs/dynamic-auth/issues/12296)) ([1e0396a](https://github.com/dynamic-labs/dynamic-auth/commit/1e0396ab00c79aa0b2f45b6d7b1d339c1dac1203)), closes [#12254](https://github.com/dynamic-labs/dynamic-auth/issues/12254)
|
|
15
|
+
* **screening:** wire connected-wallet screening into the Send Balance UI (DYNT-1663) ([#12303](https://github.com/dynamic-labs/dynamic-auth/issues/12303)) ([5d26ff3](https://github.com/dynamic-labs/dynamic-auth/commit/5d26ff375118302522c39bd2f1fa9e04f7378eaf))
|
|
16
|
+
|
|
17
|
+
### [5.4.1](https://github.com/dynamic-labs/dynamic-auth/compare/v5.4.0...v5.4.1) (2026-08-26)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **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))
|
|
23
|
+
* **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))
|
|
24
|
+
* **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)
|
|
25
|
+
* **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))
|
|
26
|
+
* **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))
|
|
27
|
+
* **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)
|
|
28
|
+
|
|
2
29
|
## [5.4.0](https://github.com/dynamic-labs/dynamic-auth/compare/v5.3.2...v5.4.0) (2026-08-25)
|
|
3
30
|
|
|
4
31
|
|
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.5.0",
|
|
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.5.0",
|
|
33
|
+
"@dynamic-labs/logger": "5.5.0",
|
|
34
|
+
"@dynamic-labs/types": "5.5.0",
|
|
35
|
+
"@dynamic-labs/utils": "5.5.0",
|
|
36
|
+
"@dynamic-labs/waas": "5.5.0",
|
|
37
|
+
"@dynamic-labs/wallet-book": "5.5.0",
|
|
38
|
+
"@dynamic-labs/wallet-connector-core": "5.5.0",
|
|
39
39
|
"eventemitter3": "5.0.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {}
|
|
@@ -286,13 +286,15 @@ class DynamicWaasBitcoinConnector extends waas.withDynamicWaas(BitcoinWalletConn
|
|
|
286
286
|
* address (wallets created before per-network registration).
|
|
287
287
|
*/
|
|
288
288
|
getPaymentAddressForNetwork(network) {
|
|
289
|
-
var _a, _b;
|
|
289
|
+
var _a, _b, _c;
|
|
290
290
|
// Resolved against the wallet that is currently active. Reading
|
|
291
291
|
// `verifiedCredential` alone would switch the network on the user's first
|
|
292
292
|
// wallet, handing back an address that belongs to a different wallet.
|
|
293
293
|
const credential = (_a = this.findCredentialForActiveAddress()) !== null && _a !== void 0 ? _a : this.verifiedCredential;
|
|
294
|
-
|
|
295
|
-
|
|
294
|
+
// Taproot wallets are minted with `ordinals` rows only, so a `payment`
|
|
295
|
+
// row is preferred but cannot be required or they lose testnet entirely.
|
|
296
|
+
const forNetwork = (_b = credential === null || credential === void 0 ? void 0 : credential.walletAdditionalAddresses) === null || _b === void 0 ? void 0 : _b.filter((addr) => addr.network === network);
|
|
297
|
+
const tagged = (_c = forNetwork === null || forNetwork === void 0 ? void 0 : forNetwork.find((addr) => addr.type === 'payment')) !== null && _c !== void 0 ? _c : forNetwork === null || forNetwork === void 0 ? void 0 : forNetwork.find((addr) => addr.type === 'ordinals');
|
|
296
298
|
if (tagged === null || tagged === void 0 ? void 0 : tagged.address) {
|
|
297
299
|
return tagged.address;
|
|
298
300
|
}
|
|
@@ -500,33 +502,29 @@ class DynamicWaasBitcoinConnector extends waas.withDynamicWaas(BitcoinWalletConn
|
|
|
500
502
|
const _super = Object.create(null, {
|
|
501
503
|
createWalletAccount: { get: () => super.createWalletAccount }
|
|
502
504
|
});
|
|
503
|
-
return _tslib.__awaiter(this, arguments, void 0, function* (
|
|
504
|
-
var _a;
|
|
505
|
+
return _tslib.__awaiter(this, arguments, void 0, function* (params = {}) {
|
|
506
|
+
var _a, _b;
|
|
505
507
|
const finalBitcoinConfig = {
|
|
506
|
-
addressType: ((_a = bitcoinConfig === null ||
|
|
508
|
+
addressType: ((_b = (_a = params.bitcoinConfig) === null || _a === void 0 ? void 0 : _a.addressType) !== null && _b !== void 0 ? _b : 'native_segwit'),
|
|
507
509
|
network: yield this.getBitcoinNetworkEnum(),
|
|
508
510
|
};
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
thresholdSignatureScheme,
|
|
513
|
-
});
|
|
511
|
+
// Spread, so a field added to CreateWalletAccountParams later still
|
|
512
|
+
// reaches the base instead of being silently dropped here.
|
|
513
|
+
return _super.createWalletAccount.call(this, Object.assign(Object.assign({}, params), { bitcoinConfig: finalBitcoinConfig }));
|
|
514
514
|
});
|
|
515
515
|
}
|
|
516
516
|
/**
|
|
517
|
-
*
|
|
518
|
-
* @param
|
|
519
|
-
*
|
|
520
|
-
* @param publicAddressCheck - Optional public address to verify against
|
|
521
|
-
* @param addressType - Required address type for Bitcoin ('native_segwit' or 'taproot')
|
|
522
|
-
* @param legacyWalletId - Optional ID of the legacy wallet being upgraded
|
|
517
|
+
* Requires and validates `addressType` for Bitcoin, then delegates.
|
|
518
|
+
* @param params - See ImportPrivateKeyParams. `addressType` is mandatory
|
|
519
|
+
* here ('native_segwit' or 'taproot') and `privateKey` is WIF.
|
|
523
520
|
* @throws {DynamicError} If addressType is missing or invalid for BTC
|
|
524
521
|
*/
|
|
525
|
-
importPrivateKey(
|
|
522
|
+
importPrivateKey(params) {
|
|
526
523
|
const _super = Object.create(null, {
|
|
527
524
|
importPrivateKey: { get: () => super.importPrivateKey }
|
|
528
525
|
});
|
|
529
|
-
return _tslib.__awaiter(this,
|
|
526
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
527
|
+
const { addressType } = params;
|
|
530
528
|
if (!addressType) {
|
|
531
529
|
throw new utils.DynamicError('addressType is required for BTC importPrivateKey', 'addresstype_is_required_for_btc_importprivatekey');
|
|
532
530
|
}
|
|
@@ -534,13 +532,10 @@ class DynamicWaasBitcoinConnector extends waas.withDynamicWaas(BitcoinWalletConn
|
|
|
534
532
|
if (!validAddressTypes.includes(addressType)) {
|
|
535
533
|
throw new utils.DynamicError(`Invalid addressType: ${addressType}. Must be one of: ${validAddressTypes.join(', ')}`, 'invalid_addresstype_must_be_one_of');
|
|
536
534
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
publicAddressCheck,
|
|
542
|
-
thresholdSignatureScheme,
|
|
543
|
-
});
|
|
535
|
+
// Forwarded whole, never field-by-field: a re-declared parameter list is
|
|
536
|
+
// how `password` silently stopped reaching the base (see
|
|
537
|
+
// ImportPrivateKeyParams).
|
|
538
|
+
return _super.importPrivateKey.call(this, params);
|
|
544
539
|
});
|
|
545
540
|
}
|
|
546
541
|
/**
|
|
@@ -558,6 +553,34 @@ class DynamicWaasBitcoinConnector extends waas.withDynamicWaas(BitcoinWalletConn
|
|
|
558
553
|
}
|
|
559
554
|
return this.getWaasWalletClient();
|
|
560
555
|
}
|
|
556
|
+
/**
|
|
557
|
+
* Rebinds the connector when the user switches primary wallet. One connector
|
|
558
|
+
* instance is shared by every BTC wallet, so without this the connector stays
|
|
559
|
+
* on whichever address it was first seeded with and every address-derived
|
|
560
|
+
* read — displayed address, deposit address, balance — reports that wallet.
|
|
561
|
+
*
|
|
562
|
+
* Guarded by isSameWalletAddress so switching to a wallet that is already
|
|
563
|
+
* active on a non-mainnet encoding does not reset it to the primary address.
|
|
564
|
+
*/
|
|
565
|
+
afterWalletSelectHook(walletAddress) {
|
|
566
|
+
if (!this.isSameWalletAddress(walletAddress)) {
|
|
567
|
+
this.setActiveAccountAddress(this.resolveAddressForActiveNetwork(walletAddress));
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Selecting a wallet hands us its primary (mainnet) address, so binding it
|
|
572
|
+
* verbatim would silently drop a switchNetwork the user already made. Map it
|
|
573
|
+
* onto the network that is currently active instead. Falls back to the given
|
|
574
|
+
* address when the wallet has no row for that network.
|
|
575
|
+
*/
|
|
576
|
+
resolveAddressForActiveNetwork(walletAddress) {
|
|
577
|
+
var _a, _b, _c, _d, _e, _f;
|
|
578
|
+
const network = this.activeNetworkId === BITCOIN_TESTNET_NETWORK_ID
|
|
579
|
+
? 'testnet'
|
|
580
|
+
: 'mainnet';
|
|
581
|
+
const forNetwork = ((_b = (_a = this.findCredentialForAddress(walletAddress)) === null || _a === void 0 ? void 0 : _a.walletAdditionalAddresses) !== null && _b !== void 0 ? _b : []).filter((addr) => addr.network === network);
|
|
582
|
+
return ((_f = (_d = (_c = forNetwork.find((addr) => addr.type === 'payment')) === null || _c === void 0 ? void 0 : _c.address) !== null && _d !== void 0 ? _d : (_e = forNetwork.find((addr) => addr.type === 'ordinals')) === null || _e === void 0 ? void 0 : _e.address) !== null && _f !== void 0 ? _f : walletAddress);
|
|
583
|
+
}
|
|
561
584
|
/**
|
|
562
585
|
* Gets the currently active account address
|
|
563
586
|
* @returns The active account address or undefined if not set
|
|
@@ -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,15 +86,7 @@ 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, isRawScalarImport, }:
|
|
96
|
-
privateKey: string;
|
|
97
|
-
thresholdSignatureScheme?: string | undefined;
|
|
98
|
-
publicAddressCheck?: string | undefined;
|
|
99
|
-
addressType?: string | undefined;
|
|
100
|
-
legacyWalletId?: string | undefined;
|
|
101
|
-
password?: string | undefined;
|
|
102
|
-
isRawScalarImport?: boolean | undefined;
|
|
103
|
-
}): Promise<void>;
|
|
89
|
+
importPrivateKey({ privateKey, thresholdSignatureScheme, publicAddressCheck, addressType, legacyWalletId, password, isRawScalarImport, }: ImportPrivateKeyParams): Promise<void>;
|
|
104
90
|
migrateFromFireblocks({ deviceId, jwt, walletPassword, ncwStorage, expectedAddresses, coinTypes, password, }: {
|
|
105
91
|
deviceId: string;
|
|
106
92
|
jwt: string;
|
|
@@ -109,7 +95,9 @@ declare const DynamicWaasBitcoinConnector_base: (abstract new (...args: any[]) =
|
|
|
109
95
|
expectedAddresses: Record<string, string>;
|
|
110
96
|
coinTypes?: Record<string, number> | undefined;
|
|
111
97
|
password?: string | undefined;
|
|
112
|
-
}): Promise<Record<string, unknown>>;
|
|
98
|
+
}): Promise<Record<string, unknown>>; /**
|
|
99
|
+
* Gets the current Bitcoin network id (1 mainnet, 2 testnet)
|
|
100
|
+
*/
|
|
113
101
|
exportPrivateKey({ accountAddress, displayContainer, password, }?: {
|
|
114
102
|
accountAddress?: string | undefined;
|
|
115
103
|
displayContainer?: HTMLIFrameElement | undefined;
|
|
@@ -118,10 +106,7 @@ declare const DynamicWaasBitcoinConnector_base: (abstract new (...args: any[]) =
|
|
|
118
106
|
getExportHandler(): {
|
|
119
107
|
clear: () => void;
|
|
120
108
|
};
|
|
121
|
-
exportClientKeyshares({ accountAddress, password, }:
|
|
122
|
-
accountAddress: string;
|
|
123
|
-
password?: string | undefined;
|
|
124
|
-
}): Promise<void>;
|
|
109
|
+
exportClientKeyshares({ accountAddress, password, }: import("@dynamic-labs/wallet-connector-core").ExportClientKeysharesParams): Promise<void>;
|
|
125
110
|
runBackupLifecycle({ provider, accountAddress, password, performBackup, }: {
|
|
126
111
|
provider: string;
|
|
127
112
|
accountAddress: string;
|
|
@@ -137,11 +122,7 @@ declare const DynamicWaasBitcoinConnector_base: (abstract new (...args: any[]) =
|
|
|
137
122
|
};
|
|
138
123
|
}) => Promise<void>;
|
|
139
124
|
}): Promise<void>;
|
|
140
|
-
backupKeySharesToGoogleDrive({ accountAddress, password, googleDriveAccessToken, }:
|
|
141
|
-
accountAddress: string;
|
|
142
|
-
password?: string | undefined;
|
|
143
|
-
googleDriveAccessToken?: string | undefined;
|
|
144
|
-
}): Promise<void>;
|
|
125
|
+
backupKeySharesToGoogleDrive({ accountAddress, password, googleDriveAccessToken, }: import("@dynamic-labs/wallet-connector-core").BackupKeySharesToGoogleDriveParams): Promise<void>;
|
|
145
126
|
exportClientKeysharesFromGoogleDrive({ accountAddress, password, }: {
|
|
146
127
|
accountAddress: string;
|
|
147
128
|
password?: string | undefined;
|
|
@@ -155,24 +136,13 @@ declare const DynamicWaasBitcoinConnector_base: (abstract new (...args: any[]) =
|
|
|
155
136
|
}): Promise<void>;
|
|
156
137
|
hideICloudSignIn(): Promise<void>;
|
|
157
138
|
isICloudAuthenticated(): Promise<boolean>;
|
|
158
|
-
refreshWalletAccountShares({ accountAddress, password, }:
|
|
159
|
-
|
|
160
|
-
password?: string | undefined;
|
|
161
|
-
}): Promise<void>;
|
|
162
|
-
reshareWalletAccountShares({ accountAddress, thresholdSignatureScheme, password, }: {
|
|
163
|
-
accountAddress: string;
|
|
164
|
-
thresholdSignatureScheme: string;
|
|
165
|
-
password?: string | undefined;
|
|
166
|
-
}): 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>;
|
|
167
141
|
revokeDelegation({ accountAddress, password, }: {
|
|
168
142
|
accountAddress: string;
|
|
169
143
|
password?: string | undefined;
|
|
170
144
|
}): Promise<void>;
|
|
171
|
-
updatePassword({ accountAddress, existingPassword, newPassword, }:
|
|
172
|
-
accountAddress: string;
|
|
173
|
-
existingPassword?: string | undefined;
|
|
174
|
-
newPassword: string;
|
|
175
|
-
}): Promise<void>;
|
|
145
|
+
updatePassword({ accountAddress, existingPassword, newPassword, }: import("@dynamic-labs/wallet-connector-core").UpdatePasswordParams): Promise<void>;
|
|
176
146
|
setPassword({ accountAddress, newPassword, }: {
|
|
177
147
|
accountAddress: string;
|
|
178
148
|
newPassword: string;
|
|
@@ -202,18 +172,7 @@ declare const DynamicWaasBitcoinConnector_base: (abstract new (...args: any[]) =
|
|
|
202
172
|
generateTraceId(): string;
|
|
203
173
|
buildErrorInstrumentContext(error: unknown): {
|
|
204
174
|
errorCode: string | import("@dynamic-labs/utils").ErrorCode;
|
|
205
|
-
errorMessage: string;
|
|
206
|
-
* Wallet identity: keyshares/wallet records are keyed by the wallet's
|
|
207
|
-
* primary (mainnet) address. On testnet the active address is the same
|
|
208
|
-
* wallet's per-network encoding — WaaS lookups (password, signing) must use
|
|
209
|
-
* the primary address (the same key signs both encodings).
|
|
210
|
-
*
|
|
211
|
-
* Resolved from the credential that owns the active address, so a user with
|
|
212
|
-
* several Bitcoin wallets gets the identity of the wallet being spent from.
|
|
213
|
-
* Never falls back to another wallet's address: a substituted key produces a
|
|
214
|
-
* signature that looks valid locally and is rejected by the network, so the
|
|
215
|
-
* failure has to surface here instead.
|
|
216
|
-
*/
|
|
175
|
+
errorMessage: string;
|
|
217
176
|
errorType: string | undefined;
|
|
218
177
|
} | {
|
|
219
178
|
errorCode: string;
|
|
@@ -451,32 +410,19 @@ export declare class DynamicWaasBitcoinConnector extends DynamicWaasBitcoinConne
|
|
|
451
410
|
* @param bitcoinConfig - Bitcoin configuration (addressType, network)
|
|
452
411
|
* @returns The created wallet account information
|
|
453
412
|
*/
|
|
454
|
-
createWalletAccount(
|
|
455
|
-
thresholdSignatureScheme?: string;
|
|
456
|
-
password?: string;
|
|
457
|
-
bitcoinConfig?: BitcoinConfig;
|
|
458
|
-
}): Promise<{
|
|
413
|
+
createWalletAccount(params?: CreateWalletAccountParams): Promise<{
|
|
459
414
|
chainName: string;
|
|
460
415
|
accountAddress: string;
|
|
461
416
|
publicKeyHex: string;
|
|
462
417
|
rawPublicKey: string | Uint8Array | undefined;
|
|
463
418
|
}>;
|
|
464
419
|
/**
|
|
465
|
-
*
|
|
466
|
-
* @param
|
|
467
|
-
*
|
|
468
|
-
* @param publicAddressCheck - Optional public address to verify against
|
|
469
|
-
* @param addressType - Required address type for Bitcoin ('native_segwit' or 'taproot')
|
|
470
|
-
* @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.
|
|
471
423
|
* @throws {DynamicError} If addressType is missing or invalid for BTC
|
|
472
424
|
*/
|
|
473
|
-
importPrivateKey(
|
|
474
|
-
privateKey: string;
|
|
475
|
-
thresholdSignatureScheme?: string;
|
|
476
|
-
publicAddressCheck?: string;
|
|
477
|
-
addressType?: string;
|
|
478
|
-
legacyWalletId?: string;
|
|
479
|
-
}): Promise<void>;
|
|
425
|
+
importPrivateKey(params: ImportPrivateKeyParams): Promise<void>;
|
|
480
426
|
/**
|
|
481
427
|
* Gets the wallet client for a specific account address and sets it as
|
|
482
428
|
* active — unless `accountAddress` is just a different network-tagged
|
|
@@ -489,6 +435,23 @@ export declare class DynamicWaasBitcoinConnector extends DynamicWaasBitcoinConne
|
|
|
489
435
|
getWalletClientByAddress({ accountAddress }: {
|
|
490
436
|
accountAddress: string;
|
|
491
437
|
}): Promise<import("@dynamic-labs-wallet/browser-wallet-client").DynamicWalletClient>;
|
|
438
|
+
/**
|
|
439
|
+
* Rebinds the connector when the user switches primary wallet. One connector
|
|
440
|
+
* instance is shared by every BTC wallet, so without this the connector stays
|
|
441
|
+
* on whichever address it was first seeded with and every address-derived
|
|
442
|
+
* read — displayed address, deposit address, balance — reports that wallet.
|
|
443
|
+
*
|
|
444
|
+
* Guarded by isSameWalletAddress so switching to a wallet that is already
|
|
445
|
+
* active on a non-mainnet encoding does not reset it to the primary address.
|
|
446
|
+
*/
|
|
447
|
+
afterWalletSelectHook(walletAddress: string): void;
|
|
448
|
+
/**
|
|
449
|
+
* Selecting a wallet hands us its primary (mainnet) address, so binding it
|
|
450
|
+
* verbatim would silently drop a switchNetwork the user already made. Map it
|
|
451
|
+
* onto the network that is currently active instead. Falls back to the given
|
|
452
|
+
* address when the wallet has no row for that network.
|
|
453
|
+
*/
|
|
454
|
+
private resolveAddressForActiveNetwork;
|
|
492
455
|
/**
|
|
493
456
|
* Gets the currently active account address
|
|
494
457
|
* @returns The active account address or undefined if not set
|
|
@@ -282,13 +282,15 @@ class DynamicWaasBitcoinConnector extends withDynamicWaas(BitcoinWalletConnector
|
|
|
282
282
|
* address (wallets created before per-network registration).
|
|
283
283
|
*/
|
|
284
284
|
getPaymentAddressForNetwork(network) {
|
|
285
|
-
var _a, _b;
|
|
285
|
+
var _a, _b, _c;
|
|
286
286
|
// Resolved against the wallet that is currently active. Reading
|
|
287
287
|
// `verifiedCredential` alone would switch the network on the user's first
|
|
288
288
|
// wallet, handing back an address that belongs to a different wallet.
|
|
289
289
|
const credential = (_a = this.findCredentialForActiveAddress()) !== null && _a !== void 0 ? _a : this.verifiedCredential;
|
|
290
|
-
|
|
291
|
-
|
|
290
|
+
// Taproot wallets are minted with `ordinals` rows only, so a `payment`
|
|
291
|
+
// row is preferred but cannot be required or they lose testnet entirely.
|
|
292
|
+
const forNetwork = (_b = credential === null || credential === void 0 ? void 0 : credential.walletAdditionalAddresses) === null || _b === void 0 ? void 0 : _b.filter((addr) => addr.network === network);
|
|
293
|
+
const tagged = (_c = forNetwork === null || forNetwork === void 0 ? void 0 : forNetwork.find((addr) => addr.type === 'payment')) !== null && _c !== void 0 ? _c : forNetwork === null || forNetwork === void 0 ? void 0 : forNetwork.find((addr) => addr.type === 'ordinals');
|
|
292
294
|
if (tagged === null || tagged === void 0 ? void 0 : tagged.address) {
|
|
293
295
|
return tagged.address;
|
|
294
296
|
}
|
|
@@ -496,33 +498,29 @@ class DynamicWaasBitcoinConnector extends withDynamicWaas(BitcoinWalletConnector
|
|
|
496
498
|
const _super = Object.create(null, {
|
|
497
499
|
createWalletAccount: { get: () => super.createWalletAccount }
|
|
498
500
|
});
|
|
499
|
-
return __awaiter(this, arguments, void 0, function* (
|
|
500
|
-
var _a;
|
|
501
|
+
return __awaiter(this, arguments, void 0, function* (params = {}) {
|
|
502
|
+
var _a, _b;
|
|
501
503
|
const finalBitcoinConfig = {
|
|
502
|
-
addressType: ((_a = bitcoinConfig === null ||
|
|
504
|
+
addressType: ((_b = (_a = params.bitcoinConfig) === null || _a === void 0 ? void 0 : _a.addressType) !== null && _b !== void 0 ? _b : 'native_segwit'),
|
|
503
505
|
network: yield this.getBitcoinNetworkEnum(),
|
|
504
506
|
};
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
thresholdSignatureScheme,
|
|
509
|
-
});
|
|
507
|
+
// Spread, so a field added to CreateWalletAccountParams later still
|
|
508
|
+
// reaches the base instead of being silently dropped here.
|
|
509
|
+
return _super.createWalletAccount.call(this, Object.assign(Object.assign({}, params), { bitcoinConfig: finalBitcoinConfig }));
|
|
510
510
|
});
|
|
511
511
|
}
|
|
512
512
|
/**
|
|
513
|
-
*
|
|
514
|
-
* @param
|
|
515
|
-
*
|
|
516
|
-
* @param publicAddressCheck - Optional public address to verify against
|
|
517
|
-
* @param addressType - Required address type for Bitcoin ('native_segwit' or 'taproot')
|
|
518
|
-
* @param legacyWalletId - Optional ID of the legacy wallet being upgraded
|
|
513
|
+
* Requires and validates `addressType` for Bitcoin, then delegates.
|
|
514
|
+
* @param params - See ImportPrivateKeyParams. `addressType` is mandatory
|
|
515
|
+
* here ('native_segwit' or 'taproot') and `privateKey` is WIF.
|
|
519
516
|
* @throws {DynamicError} If addressType is missing or invalid for BTC
|
|
520
517
|
*/
|
|
521
|
-
importPrivateKey(
|
|
518
|
+
importPrivateKey(params) {
|
|
522
519
|
const _super = Object.create(null, {
|
|
523
520
|
importPrivateKey: { get: () => super.importPrivateKey }
|
|
524
521
|
});
|
|
525
|
-
return __awaiter(this,
|
|
522
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
523
|
+
const { addressType } = params;
|
|
526
524
|
if (!addressType) {
|
|
527
525
|
throw new DynamicError('addressType is required for BTC importPrivateKey', 'addresstype_is_required_for_btc_importprivatekey');
|
|
528
526
|
}
|
|
@@ -530,13 +528,10 @@ class DynamicWaasBitcoinConnector extends withDynamicWaas(BitcoinWalletConnector
|
|
|
530
528
|
if (!validAddressTypes.includes(addressType)) {
|
|
531
529
|
throw new DynamicError(`Invalid addressType: ${addressType}. Must be one of: ${validAddressTypes.join(', ')}`, 'invalid_addresstype_must_be_one_of');
|
|
532
530
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
publicAddressCheck,
|
|
538
|
-
thresholdSignatureScheme,
|
|
539
|
-
});
|
|
531
|
+
// Forwarded whole, never field-by-field: a re-declared parameter list is
|
|
532
|
+
// how `password` silently stopped reaching the base (see
|
|
533
|
+
// ImportPrivateKeyParams).
|
|
534
|
+
return _super.importPrivateKey.call(this, params);
|
|
540
535
|
});
|
|
541
536
|
}
|
|
542
537
|
/**
|
|
@@ -554,6 +549,34 @@ class DynamicWaasBitcoinConnector extends withDynamicWaas(BitcoinWalletConnector
|
|
|
554
549
|
}
|
|
555
550
|
return this.getWaasWalletClient();
|
|
556
551
|
}
|
|
552
|
+
/**
|
|
553
|
+
* Rebinds the connector when the user switches primary wallet. One connector
|
|
554
|
+
* instance is shared by every BTC wallet, so without this the connector stays
|
|
555
|
+
* on whichever address it was first seeded with and every address-derived
|
|
556
|
+
* read — displayed address, deposit address, balance — reports that wallet.
|
|
557
|
+
*
|
|
558
|
+
* Guarded by isSameWalletAddress so switching to a wallet that is already
|
|
559
|
+
* active on a non-mainnet encoding does not reset it to the primary address.
|
|
560
|
+
*/
|
|
561
|
+
afterWalletSelectHook(walletAddress) {
|
|
562
|
+
if (!this.isSameWalletAddress(walletAddress)) {
|
|
563
|
+
this.setActiveAccountAddress(this.resolveAddressForActiveNetwork(walletAddress));
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Selecting a wallet hands us its primary (mainnet) address, so binding it
|
|
568
|
+
* verbatim would silently drop a switchNetwork the user already made. Map it
|
|
569
|
+
* onto the network that is currently active instead. Falls back to the given
|
|
570
|
+
* address when the wallet has no row for that network.
|
|
571
|
+
*/
|
|
572
|
+
resolveAddressForActiveNetwork(walletAddress) {
|
|
573
|
+
var _a, _b, _c, _d, _e, _f;
|
|
574
|
+
const network = this.activeNetworkId === BITCOIN_TESTNET_NETWORK_ID
|
|
575
|
+
? 'testnet'
|
|
576
|
+
: 'mainnet';
|
|
577
|
+
const forNetwork = ((_b = (_a = this.findCredentialForAddress(walletAddress)) === null || _a === void 0 ? void 0 : _a.walletAdditionalAddresses) !== null && _b !== void 0 ? _b : []).filter((addr) => addr.network === network);
|
|
578
|
+
return ((_f = (_d = (_c = forNetwork.find((addr) => addr.type === 'payment')) === null || _c === void 0 ? void 0 : _c.address) !== null && _d !== void 0 ? _d : (_e = forNetwork.find((addr) => addr.type === 'ordinals')) === null || _e === void 0 ? void 0 : _e.address) !== null && _f !== void 0 ? _f : walletAddress);
|
|
579
|
+
}
|
|
557
580
|
/**
|
|
558
581
|
* Gets the currently active account address
|
|
559
582
|
* @returns The active account address or undefined if not set
|