@dynamic-labs/bitcoin 3.0.0-alpha.64 → 3.0.0-alpha.66

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.
Files changed (23) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/package.json +5 -4
  3. package/src/bitcoinProviderHelper.d.ts +1 -0
  4. package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.cjs +105 -150
  5. package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.d.ts +4 -2
  6. package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.js +106 -151
  7. package/src/connectors/BitcoinSatsConnectLegacyConnector/BitcoinSatsConnectLegacyConnector.cjs +212 -0
  8. package/src/connectors/BitcoinSatsConnectLegacyConnector/BitcoinSatsConnectLegacyConnector.d.ts +10 -0
  9. package/src/connectors/BitcoinSatsConnectLegacyConnector/BitcoinSatsConnectLegacyConnector.js +208 -0
  10. package/src/connectors/BitcoinSatsConnectLegacyConnector/index.d.ts +1 -0
  11. package/src/connectors/BitcoinWalletConnector.cjs +3 -10
  12. package/src/connectors/BitcoinWalletConnector.d.ts +2 -3
  13. package/src/connectors/BitcoinWalletConnector.js +3 -10
  14. package/src/connectors/PhantomConnector/PhantomConnector.cjs +3 -12
  15. package/src/connectors/PhantomConnector/PhantomConnector.d.ts +1 -2
  16. package/src/connectors/PhantomConnector/PhantomConnector.js +3 -12
  17. package/src/connectors/index.d.ts +1 -0
  18. package/src/types.d.ts +1 -0
  19. package/src/utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.cjs +14 -2
  20. package/src/utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.js +14 -2
  21. package/src/wallet/BitcoinWallet.cjs +15 -0
  22. package/src/wallet/BitcoinWallet.d.ts +9 -0
  23. package/src/wallet/BitcoinWallet.js +15 -0
@@ -0,0 +1,208 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../_virtual/_tslib.js';
3
+ import { getAddress, AddressPurpose, signMessage, sendBtcTransaction, signTransaction, signMultipleTransactions } from 'sats-connect';
4
+ import { isMobile, template } from '@dynamic-labs/utils';
5
+ import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
6
+ import { SATSCONNECT_FEATURE } from '../../const.js';
7
+ import 'bitcoinjs-lib';
8
+ import '@dynamic-labs/wallet-connector-core';
9
+ import '@dynamic-labs/sdk-api-core';
10
+ import '@wallet-standard/app';
11
+ import { BitcoinSatsConnectConnector } from '../BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.js';
12
+ import { supportsSatsConnect } from '../../utils/supportsSatsConnect.js';
13
+
14
+ class BitcoinSatsConnectLegacyConnector extends BitcoinSatsConnectConnector {
15
+ getAddress() {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ var _a;
18
+ // xverse doesn't support wallet standard, so we won't have a wallet object,
19
+ // but it's already the default provider for sats-connect, so it's ok
20
+ // for getProvider in getAddress to return undefined
21
+ // if we're not using xverse, we need to check if there is a wallet and
22
+ // that it has the satsconnect feature to return the correct provider to use
23
+ if (!supportsSatsConnect(this)) {
24
+ return;
25
+ }
26
+ const wallet = findWalletBookWallet(this.walletBook, this.key);
27
+ const inAppBrowserUrl = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.mobile) === null || _a === void 0 ? void 0 : _a.inAppBrowser;
28
+ if (isMobile() &&
29
+ !this.isInstalledOnBrowser() &&
30
+ inAppBrowserUrl &&
31
+ this.mobileExperience === 'in-app-browser') {
32
+ const inAppBrowserTemplate = template(inAppBrowserUrl);
33
+ const deepLink = inAppBrowserTemplate({
34
+ encodedDappURI: encodeURIComponent(window.location.toString()),
35
+ });
36
+ window.location.href = deepLink;
37
+ return;
38
+ }
39
+ return new Promise((resolve, reject) => {
40
+ getAddress({
41
+ getProvider: () => __awaiter(this, void 0, void 0, function* () {
42
+ var _a, _b;
43
+ return (_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.features[SATSCONNECT_FEATURE]) === null || _b === void 0 ? void 0 : _b.provider;
44
+ }),
45
+ onCancel: () => {
46
+ const error = new Error();
47
+ error.code = '-32000'; // error code for user cancelled
48
+ reject(error);
49
+ },
50
+ onFinish: (response) => __awaiter(this, void 0, void 0, function* () {
51
+ var _c;
52
+ const { addresses } = response;
53
+ const ordinalsAccount = addresses === null || addresses === void 0 ? void 0 : addresses.find((address) => address.purpose === AddressPurpose.Ordinals);
54
+ const paymentAccount = addresses === null || addresses === void 0 ? void 0 : addresses.find((address) => address.purpose === AddressPurpose.Payment);
55
+ const mainAddress = (_c = ordinalsAccount === null || ordinalsAccount === void 0 ? void 0 : ordinalsAccount.address) !== null && _c !== void 0 ? _c : paymentAccount === null || paymentAccount === void 0 ? void 0 : paymentAccount.address;
56
+ yield this.setConnectedAccountWithAddresses({
57
+ active: true,
58
+ mainAddress,
59
+ ordinalsAddress: ordinalsAccount,
60
+ paymentAddress: paymentAccount,
61
+ });
62
+ resolve(mainAddress);
63
+ }),
64
+ payload: {
65
+ message: 'Address for receiving Ordinals and payments',
66
+ network: {
67
+ type: this.currentNetwork,
68
+ },
69
+ purposes: [AddressPurpose.Ordinals, AddressPurpose.Payment],
70
+ },
71
+ });
72
+ });
73
+ });
74
+ }
75
+ signMessage(messageToSign, withAddress) {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ if (!supportsSatsConnect(this)) {
78
+ return;
79
+ }
80
+ return new Promise((resolve, reject) => {
81
+ signMessage({
82
+ getProvider: () => __awaiter(this, void 0, void 0, function* () {
83
+ var _a, _b;
84
+ return (_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.features[SATSCONNECT_FEATURE]) === null || _b === void 0 ? void 0 : _b.provider;
85
+ }),
86
+ onCancel: () => {
87
+ const error = new Error();
88
+ error.code = '-32000'; // error code for user cancelled
89
+ reject(error);
90
+ },
91
+ onFinish: (response) => __awaiter(this, void 0, void 0, function* () {
92
+ if (this.isHardwareWalletEnabled) {
93
+ return resolve(JSON.stringify({
94
+ signedTransaction: {
95
+ data: response,
96
+ },
97
+ }));
98
+ }
99
+ resolve(response);
100
+ }),
101
+ payload: {
102
+ address: withAddress,
103
+ message: messageToSign,
104
+ network: {
105
+ type: this.currentNetwork,
106
+ },
107
+ },
108
+ });
109
+ });
110
+ });
111
+ }
112
+ sendBitcoin(transaction) {
113
+ return __awaiter(this, void 0, void 0, function* () {
114
+ var _a;
115
+ const mainAddress = yield this.getAddress();
116
+ const senderAddress = (_a = (yield this.getAdditionalAddresses(mainAddress)).find((address) => address.type === 'payment')) === null || _a === void 0 ? void 0 : _a.address;
117
+ if (!senderAddress || !supportsSatsConnect(this)) {
118
+ return;
119
+ }
120
+ return new Promise((resolve, reject) => {
121
+ sendBtcTransaction({
122
+ getProvider: () => __awaiter(this, void 0, void 0, function* () {
123
+ var _a, _b;
124
+ return (_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.features[SATSCONNECT_FEATURE]) === null || _b === void 0 ? void 0 : _b.provider;
125
+ }),
126
+ onCancel: () => {
127
+ const error = new Error();
128
+ error.code = '-32000'; // error code for user cancelled
129
+ reject(error);
130
+ },
131
+ onFinish: (response) => {
132
+ resolve(response);
133
+ },
134
+ payload: {
135
+ network: {
136
+ type: this.currentNetwork,
137
+ },
138
+ recipients: [
139
+ {
140
+ address: transaction.recipientAddress,
141
+ amountSats: transaction.amount,
142
+ },
143
+ ],
144
+ senderAddress,
145
+ },
146
+ });
147
+ });
148
+ });
149
+ }
150
+ signTransaction(params) {
151
+ return __awaiter(this, void 0, void 0, function* () {
152
+ const { message, psbtBase64, broadcast, inputsToSign } = params;
153
+ return new Promise((resolve, reject) => {
154
+ signTransaction({
155
+ getProvider: () => __awaiter(this, void 0, void 0, function* () {
156
+ var _a, _b;
157
+ return (_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.features[SATSCONNECT_FEATURE]) === null || _b === void 0 ? void 0 : _b.provider;
158
+ }),
159
+ onCancel: () => {
160
+ const error = new Error();
161
+ error.code = '-32000'; // error code for user cancelled
162
+ reject(error);
163
+ },
164
+ onFinish: (response) => {
165
+ resolve(response);
166
+ },
167
+ payload: {
168
+ broadcast,
169
+ inputsToSign,
170
+ message: message || 'Sign Transaction',
171
+ network: {
172
+ type: this.currentNetwork,
173
+ },
174
+ psbtBase64,
175
+ },
176
+ });
177
+ });
178
+ });
179
+ }
180
+ signTransactions(transactions) {
181
+ return __awaiter(this, void 0, void 0, function* () {
182
+ const { message, psbts, network } = transactions;
183
+ return new Promise((resolve, reject) => {
184
+ signMultipleTransactions({
185
+ getProvider: () => __awaiter(this, void 0, void 0, function* () {
186
+ var _a, _b;
187
+ return (_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.features[SATSCONNECT_FEATURE]) === null || _b === void 0 ? void 0 : _b.provider;
188
+ }),
189
+ onCancel: () => {
190
+ const error = new Error();
191
+ error.code = '-32000'; // error code for user cancelled
192
+ reject(error);
193
+ },
194
+ onFinish: (response) => {
195
+ resolve(response);
196
+ },
197
+ payload: {
198
+ message: message || 'Sign Transaction',
199
+ network,
200
+ psbts,
201
+ },
202
+ });
203
+ });
204
+ });
205
+ }
206
+ }
207
+
208
+ export { BitcoinSatsConnectLegacyConnector };
@@ -0,0 +1 @@
1
+ export { BitcoinSatsConnectLegacyConnector } from './BitcoinSatsConnectLegacyConnector';
@@ -110,12 +110,12 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
110
110
  ];
111
111
  });
112
112
  }
113
- getConnectedAccounts(options) {
113
+ getConnectedAccounts() {
114
114
  return _tslib.__awaiter(this, void 0, void 0, function* () {
115
115
  // some wallets like xverse don't support fetching connected accounts
116
116
  // without prompting for a connection
117
117
  // to avoid this behavior, we cache the connected accounts
118
- if (!this.canFetchConnectedAccounts && !(options === null || options === void 0 ? void 0 : options.forceFetch)) {
118
+ if (!this.canFetchConnectedAccounts) {
119
119
  return this.getConnectedAccountsFromCache();
120
120
  }
121
121
  // if we decide that is ok to prompt for a connection when fetching connected accounts
@@ -285,14 +285,7 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
285
285
  }
286
286
  proveOwnership(address, messageToSign) {
287
287
  return _tslib.__awaiter(this, void 0, void 0, function* () {
288
- return this.signMessageWithAddress(messageToSign, address);
289
- });
290
- }
291
- signMessageWithAddress(messageToSign,
292
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
293
- _address) {
294
- return _tslib.__awaiter(this, void 0, void 0, function* () {
295
- return this.signMessage(messageToSign);
288
+ return this.signMessage(messageToSign, address);
296
289
  });
297
290
  }
298
291
  }
@@ -2,7 +2,7 @@
2
2
  /// <reference types="node" />
3
3
  import { EventEmitter } from 'stream';
4
4
  import type { Wallet } from '@wallet-standard/base';
5
- import { Chain, IBitcoinWalletConnector, WalletConnectorBase, GetConnectedAccountsOpts } from '@dynamic-labs/wallet-connector-core';
5
+ import { Chain, IBitcoinWalletConnector, WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
6
6
  import { WalletBookSchema, WalletSchema } from '@dynamic-labs/wallet-book';
7
7
  import { JwtVerifiedCredential, WalletAdditionalAddress } from '@dynamic-labs/sdk-api-core';
8
8
  import { IBitcoinSessionCache } from '../BitcoinLocalStorageCache';
@@ -36,7 +36,7 @@ export declare abstract class BitcoinWalletConnector extends WalletConnectorBase
36
36
  endSession(): Promise<void>;
37
37
  getBalance(address: string): Promise<string | undefined>;
38
38
  getConnectedAccountsFromCache(): Promise<string[]>;
39
- getConnectedAccounts(options?: GetConnectedAccountsOpts): Promise<string[]>;
39
+ getConnectedAccounts(): Promise<string[]>;
40
40
  getAdditionalAddresses(mainAddress?: string): Promise<WalletAdditionalAddress[]>;
41
41
  setAdditionalAddresses(mainAddress: string, additionalAddresses: WalletAdditionalAddress[]): Promise<void>;
42
42
  sendRawTransaction(rawTransaction: string): Promise<string>;
@@ -49,5 +49,4 @@ export declare abstract class BitcoinWalletConnector extends WalletConnectorBase
49
49
  setVerifiedCredentials(verifiedCredentials: JwtVerifiedCredential[]): void;
50
50
  isLedgerAddress(address: string): boolean;
51
51
  proveOwnership(address: string, messageToSign: string): Promise<string | undefined>;
52
- signMessageWithAddress(messageToSign: string, _address: string): Promise<string | undefined>;
53
52
  }
@@ -106,12 +106,12 @@ class BitcoinWalletConnector extends WalletConnectorBase {
106
106
  ];
107
107
  });
108
108
  }
109
- getConnectedAccounts(options) {
109
+ getConnectedAccounts() {
110
110
  return __awaiter(this, void 0, void 0, function* () {
111
111
  // some wallets like xverse don't support fetching connected accounts
112
112
  // without prompting for a connection
113
113
  // to avoid this behavior, we cache the connected accounts
114
- if (!this.canFetchConnectedAccounts && !(options === null || options === void 0 ? void 0 : options.forceFetch)) {
114
+ if (!this.canFetchConnectedAccounts) {
115
115
  return this.getConnectedAccountsFromCache();
116
116
  }
117
117
  // if we decide that is ok to prompt for a connection when fetching connected accounts
@@ -281,14 +281,7 @@ class BitcoinWalletConnector extends WalletConnectorBase {
281
281
  }
282
282
  proveOwnership(address, messageToSign) {
283
283
  return __awaiter(this, void 0, void 0, function* () {
284
- return this.signMessageWithAddress(messageToSign, address);
285
- });
286
- }
287
- signMessageWithAddress(messageToSign,
288
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
289
- _address) {
290
- return __awaiter(this, void 0, void 0, function* () {
291
- return this.signMessage(messageToSign);
284
+ return this.signMessage(messageToSign, address);
292
285
  });
293
286
  }
294
287
  }
@@ -67,13 +67,13 @@ class PhantomConnector extends BitcoinWalletConnector.BitcoinWalletConnector {
67
67
  return undefined;
68
68
  });
69
69
  }
70
- signMessageWithAddress(messageToSign, address) {
70
+ signMessage(messageToSign, withAddress) {
71
71
  return _tslib.__awaiter(this, void 0, void 0, function* () {
72
72
  var _a;
73
73
  if ((_a = this.walletMethods) === null || _a === void 0 ? void 0 : _a.signMessage) {
74
74
  const [result] = yield this.walletMethods.signMessage({
75
75
  // we need to sign with the ordinals account
76
- account: { address },
76
+ account: { address: withAddress },
77
77
  message: new TextEncoder().encode(messageToSign),
78
78
  });
79
79
  return Buffer.from(result.signature).toString('base64');
@@ -83,20 +83,11 @@ class PhantomConnector extends BitcoinWalletConnector.BitcoinWalletConnector {
83
83
  if (!provider) {
84
84
  return;
85
85
  }
86
- const result = yield provider.signMessage(address, new TextEncoder().encode(messageToSign));
86
+ const result = yield provider.signMessage(withAddress, new TextEncoder().encode(messageToSign));
87
87
  return Buffer.from(result.signature).toString('base64');
88
88
  }
89
89
  });
90
90
  }
91
- signMessage(messageToSign) {
92
- return _tslib.__awaiter(this, void 0, void 0, function* () {
93
- const [walletAddress] = yield this.getConnectedAccounts();
94
- if (!walletAddress) {
95
- return;
96
- }
97
- return this.signMessageWithAddress(messageToSign, walletAddress);
98
- });
99
- }
100
91
  sendBitcoin(transaction) {
101
92
  return _tslib.__awaiter(this, void 0, void 0, function* () {
102
93
  walletConnectorCore.logger.debug('sendBitcoin - function not implemented', transaction);
@@ -5,8 +5,7 @@ export declare class PhantomConnector extends BitcoinWalletConnector {
5
5
  constructor(opts: BitcoinWalletConnectorOpts);
6
6
  private connectWithInstalledExtension;
7
7
  getAddress(): Promise<string | undefined>;
8
- signMessageWithAddress(messageToSign: string, address: string): Promise<string | undefined>;
9
- signMessage(messageToSign: string): Promise<string | undefined>;
8
+ signMessage(messageToSign: string, withAddress: string): Promise<string | undefined>;
10
9
  sendBitcoin(transaction: BitcoinTransaction): Promise<string | undefined>;
11
10
  signPsbt(request: BitcoinSignPsbtRequest): Promise<BitcoinSignPsbtResponse | undefined>;
12
11
  }
@@ -63,13 +63,13 @@ class PhantomConnector extends BitcoinWalletConnector {
63
63
  return undefined;
64
64
  });
65
65
  }
66
- signMessageWithAddress(messageToSign, address) {
66
+ signMessage(messageToSign, withAddress) {
67
67
  return __awaiter(this, void 0, void 0, function* () {
68
68
  var _a;
69
69
  if ((_a = this.walletMethods) === null || _a === void 0 ? void 0 : _a.signMessage) {
70
70
  const [result] = yield this.walletMethods.signMessage({
71
71
  // we need to sign with the ordinals account
72
- account: { address },
72
+ account: { address: withAddress },
73
73
  message: new TextEncoder().encode(messageToSign),
74
74
  });
75
75
  return Buffer.from(result.signature).toString('base64');
@@ -79,20 +79,11 @@ class PhantomConnector extends BitcoinWalletConnector {
79
79
  if (!provider) {
80
80
  return;
81
81
  }
82
- const result = yield provider.signMessage(address, new TextEncoder().encode(messageToSign));
82
+ const result = yield provider.signMessage(withAddress, new TextEncoder().encode(messageToSign));
83
83
  return Buffer.from(result.signature).toString('base64');
84
84
  }
85
85
  });
86
86
  }
87
- signMessage(messageToSign) {
88
- return __awaiter(this, void 0, void 0, function* () {
89
- const [walletAddress] = yield this.getConnectedAccounts();
90
- if (!walletAddress) {
91
- return;
92
- }
93
- return this.signMessageWithAddress(messageToSign, walletAddress);
94
- });
95
- }
96
87
  sendBitcoin(transaction) {
97
88
  return __awaiter(this, void 0, void 0, function* () {
98
89
  logger.debug('sendBitcoin - function not implemented', transaction);
@@ -1,6 +1,7 @@
1
1
  export * from './BitcoinWalletConnector';
2
2
  export * from './BitcoinBtcKitConnector';
3
3
  export * from './BitcoinSatsConnectConnector';
4
+ export * from './BitcoinSatsConnectLegacyConnector';
4
5
  export * from './PhantomConnector';
5
6
  export * from './OkxConnector';
6
7
  export * from './UnisatConnector';
package/src/types.d.ts CHANGED
@@ -53,6 +53,7 @@ export type SatsConnectSignTransactionInput = {
53
53
  psbtBase64: string;
54
54
  inputsToSign: SatsConnectInputToSign[];
55
55
  broadcast?: boolean;
56
+ allowedSignHash?: number;
56
57
  };
57
58
  export type BtcKitSignPsbtResponseExtended = BtcKitSignPsbtResponse & {
58
59
  result: {
@@ -13,6 +13,7 @@ require('@dynamic-labs/sdk-api-core');
13
13
  require('@wallet-standard/app');
14
14
  require('bitcoinjs-lib');
15
15
  var BitcoinSatsConnectConnector = require('../../connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.cjs');
16
+ var BitcoinSatsConnectLegacyConnector = require('../../connectors/BitcoinSatsConnectLegacyConnector/BitcoinSatsConnectLegacyConnector.cjs');
16
17
 
17
18
  const fetchSatsConnectConnectors = ({ walletBook, }) => {
18
19
  var _a;
@@ -27,9 +28,20 @@ const fetchSatsConnectConnectors = ({ walletBook, }) => {
27
28
  });
28
29
  })
29
30
  .map(([key, wallet]) => {
30
- const { shortName } = wallet;
31
+ var _a;
32
+ const { shortName, injectedConfig } = wallet;
31
33
  const name = shortName || wallet.name;
32
- return class extends BitcoinSatsConnectConnector.BitcoinSatsConnectConnector {
34
+ // if has providerId, use the new connector (xverse)
35
+ if ((_a = injectedConfig === null || injectedConfig === void 0 ? void 0 : injectedConfig[0].walletStandard) === null || _a === void 0 ? void 0 : _a.providerId) {
36
+ return class extends BitcoinSatsConnectConnector.BitcoinSatsConnectConnector {
37
+ constructor(props) {
38
+ super(Object.assign(Object.assign({}, props), { overrideKey: key, walletData: wallet }));
39
+ this.name = name;
40
+ }
41
+ };
42
+ }
43
+ // id doesn't have providerId, use the legacy connector (magiceden)
44
+ return class extends BitcoinSatsConnectLegacyConnector.BitcoinSatsConnectLegacyConnector {
33
45
  constructor(props) {
34
46
  super(Object.assign(Object.assign({}, props), { overrideKey: key, walletData: wallet }));
35
47
  this.name = name;
@@ -9,6 +9,7 @@ import '@dynamic-labs/sdk-api-core';
9
9
  import '@wallet-standard/app';
10
10
  import 'bitcoinjs-lib';
11
11
  import { BitcoinSatsConnectConnector } from '../../connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.js';
12
+ import { BitcoinSatsConnectLegacyConnector } from '../../connectors/BitcoinSatsConnectLegacyConnector/BitcoinSatsConnectLegacyConnector.js';
12
13
 
13
14
  const fetchSatsConnectConnectors = ({ walletBook, }) => {
14
15
  var _a;
@@ -23,9 +24,20 @@ const fetchSatsConnectConnectors = ({ walletBook, }) => {
23
24
  });
24
25
  })
25
26
  .map(([key, wallet]) => {
26
- const { shortName } = wallet;
27
+ var _a;
28
+ const { shortName, injectedConfig } = wallet;
27
29
  const name = shortName || wallet.name;
28
- return class extends BitcoinSatsConnectConnector {
30
+ // if has providerId, use the new connector (xverse)
31
+ if ((_a = injectedConfig === null || injectedConfig === void 0 ? void 0 : injectedConfig[0].walletStandard) === null || _a === void 0 ? void 0 : _a.providerId) {
32
+ return class extends BitcoinSatsConnectConnector {
33
+ constructor(props) {
34
+ super(Object.assign(Object.assign({}, props), { overrideKey: key, walletData: wallet }));
35
+ this.name = name;
36
+ }
37
+ };
38
+ }
39
+ // id doesn't have providerId, use the legacy connector (magiceden)
40
+ return class extends BitcoinSatsConnectLegacyConnector {
29
41
  constructor(props) {
30
42
  super(Object.assign(Object.assign({}, props), { overrideKey: key, walletData: wallet }));
31
43
  this.name = name;
@@ -27,6 +27,21 @@ class BitcoinWallet extends walletConnectorCore.Wallet {
27
27
  return this._connector.sendBitcoin(transaction);
28
28
  });
29
29
  }
30
+ /**
31
+ * Signs a message using a specific address type (payment or ordinals).
32
+ * @param messageToSign - The message to sign.
33
+ * @param addressType - The type of address to sign the message with (payment or ordinals).
34
+ * @returns A promise that resolves to the signature of the message as a string,
35
+ * or undefined if the message cannot be signed.
36
+ */
37
+ signMessageWithAddress(messageToSign, addressType) {
38
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
39
+ var _a;
40
+ yield this.sync();
41
+ const address = ((_a = this.additionalAddresses.find((addr) => addr.type === addressType)) === null || _a === void 0 ? void 0 : _a.address) || this.address;
42
+ return this._connector.signMessage(messageToSign, address);
43
+ });
44
+ }
30
45
  /**
31
46
  * Sings a PSBT
32
47
  * @returns A promise that resolves to an object with the signed PSBT
@@ -1,4 +1,5 @@
1
1
  import { Wallet } from '@dynamic-labs/wallet-connector-core';
2
+ import type { WalletAddressType } from '@dynamic-labs/types';
2
3
  import { BitcoinWalletConnector } from '../connectors';
3
4
  import { BitcoinSignPsbtRequest, BitcoinSignPsbtResponse, BitcoinTransaction } from '../types';
4
5
  export declare class BitcoinWallet extends Wallet<BitcoinWalletConnector> {
@@ -12,6 +13,14 @@ export declare class BitcoinWallet extends Wallet<BitcoinWalletConnector> {
12
13
  * @returns A promise that resolves to the transaction id
13
14
  */
14
15
  sendBitcoin(transaction: BitcoinTransaction): Promise<string | undefined>;
16
+ /**
17
+ * Signs a message using a specific address type (payment or ordinals).
18
+ * @param messageToSign - The message to sign.
19
+ * @param addressType - The type of address to sign the message with (payment or ordinals).
20
+ * @returns A promise that resolves to the signature of the message as a string,
21
+ * or undefined if the message cannot be signed.
22
+ */
23
+ signMessageWithAddress(messageToSign: string, addressType: WalletAddressType): Promise<string | undefined>;
15
24
  /**
16
25
  * Sings a PSBT
17
26
  * @returns A promise that resolves to an object with the signed PSBT
@@ -23,6 +23,21 @@ class BitcoinWallet extends Wallet {
23
23
  return this._connector.sendBitcoin(transaction);
24
24
  });
25
25
  }
26
+ /**
27
+ * Signs a message using a specific address type (payment or ordinals).
28
+ * @param messageToSign - The message to sign.
29
+ * @param addressType - The type of address to sign the message with (payment or ordinals).
30
+ * @returns A promise that resolves to the signature of the message as a string,
31
+ * or undefined if the message cannot be signed.
32
+ */
33
+ signMessageWithAddress(messageToSign, addressType) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ var _a;
36
+ yield this.sync();
37
+ const address = ((_a = this.additionalAddresses.find((addr) => addr.type === addressType)) === null || _a === void 0 ? void 0 : _a.address) || this.address;
38
+ return this._connector.signMessage(messageToSign, address);
39
+ });
40
+ }
26
41
  /**
27
42
  * Sings a PSBT
28
43
  * @returns A promise that resolves to an object with the signed PSBT