@dynamic-labs/bitcoin 3.0.0-alpha.66 → 3.0.0-alpha.67
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 +16 -0
- package/package.json +6 -6
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.cjs +28 -8
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.d.ts +1 -0
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.js +28 -8
- package/src/connectors/BitcoinSatsConnectLegacyConnector/BitcoinSatsConnectLegacyConnector.cjs +4 -0
- package/src/connectors/BitcoinSatsConnectLegacyConnector/BitcoinSatsConnectLegacyConnector.d.ts +1 -0
- package/src/connectors/BitcoinSatsConnectLegacyConnector/BitcoinSatsConnectLegacyConnector.js +4 -0
- package/src/connectors/BitcoinWalletConnector.cjs +1 -1
- package/src/connectors/BitcoinWalletConnector.js +1 -1
- package/src/utils/psbt/createSignPsbtOptions.cjs +7 -2
- package/src/utils/psbt/createSignPsbtOptions.d.ts +1 -1
- package/src/utils/psbt/createSignPsbtOptions.js +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
|
|
2
|
+
## [3.0.0-alpha.67](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.66...v3.0.0-alpha.67) (2024-09-12)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add blockaid url scanning to sdk api ([#6869](https://github.com/dynamic-labs/DynamicAuth/issues/6869)) ([0a20eef](https://github.com/dynamic-labs/DynamicAuth/commit/0a20eef2eec8793a714f67948ddba2bc1bab06cd))
|
|
8
|
+
* allow selecting which MetaMask account to connect with on sign-in ([#6838](https://github.com/dynamic-labs/DynamicAuth/issues/6838)) ([8a30614](https://github.com/dynamic-labs/DynamicAuth/commit/8a306140563390602a417fd191bc789d6e07c220))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* cach get server snashot to avoid next js rerender loop ([#6867](https://github.com/dynamic-labs/DynamicAuth/issues/6867)) ([6f77c01](https://github.com/dynamic-labs/DynamicAuth/commit/6f77c01663641ab870a8b96fb2d3b5611bc38c2c))
|
|
14
|
+
* clean up console errors on log out ([#6834](https://github.com/dynamic-labs/DynamicAuth/issues/6834)) ([a18a4ce](https://github.com/dynamic-labs/DynamicAuth/commit/a18a4ce57766dec0cc351794ff7a71b3c632d9a3))
|
|
15
|
+
* ensure open url method will be available in the webview controller ([#6852](https://github.com/dynamic-labs/DynamicAuth/issues/6852)) ([bdaf12f](https://github.com/dynamic-labs/DynamicAuth/commit/bdaf12f7a77b801c3dec67163e1fef2fdffc7d2a))
|
|
16
|
+
* solana transaction decoder fallback ([#6868](https://github.com/dynamic-labs/DynamicAuth/issues/6868)) ([38c9242](https://github.com/dynamic-labs/DynamicAuth/commit/38c924253c29e8e3569d9da9bc452a8cdc3af0d2))
|
|
17
|
+
|
|
2
18
|
## [3.0.0-alpha.66](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.65...v3.0.0-alpha.66) (2024-09-11)
|
|
3
19
|
|
|
4
20
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/bitcoin",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.67",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@btckit/types": "0.0.19",
|
|
30
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
30
|
+
"@dynamic-labs/sdk-api-core": "0.0.529",
|
|
31
31
|
"@wallet-standard/app": "1.0.1",
|
|
32
32
|
"@wallet-standard/base": "1.0.1",
|
|
33
33
|
"bitcoinjs-lib": "6.1.5",
|
|
34
34
|
"sats-connect": "2.8.0",
|
|
35
|
-
"@dynamic-labs/types": "3.0.0-alpha.
|
|
36
|
-
"@dynamic-labs/utils": "3.0.0-alpha.
|
|
37
|
-
"@dynamic-labs/wallet-book": "3.0.0-alpha.
|
|
38
|
-
"@dynamic-labs/wallet-connector-core": "3.0.0-alpha.
|
|
35
|
+
"@dynamic-labs/types": "3.0.0-alpha.67",
|
|
36
|
+
"@dynamic-labs/utils": "3.0.0-alpha.67",
|
|
37
|
+
"@dynamic-labs/wallet-book": "3.0.0-alpha.67",
|
|
38
|
+
"@dynamic-labs/wallet-connector-core": "3.0.0-alpha.67",
|
|
39
39
|
"stream": "0.0.2"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {}
|
|
@@ -12,10 +12,12 @@ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
|
12
12
|
var bitcoinNetworkTypeToNetworks = require('../../utils/psbt/bitcoinNetworkTypeToNetworks.cjs');
|
|
13
13
|
var BitcoinWalletConnector = require('../BitcoinWalletConnector.cjs');
|
|
14
14
|
var createSignPsbtOptions = require('../../utils/psbt/createSignPsbtOptions.cjs');
|
|
15
|
+
var _const = require('../../const.cjs');
|
|
15
16
|
|
|
16
17
|
class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletConnector {
|
|
17
18
|
constructor(opts) {
|
|
18
19
|
super(opts);
|
|
20
|
+
this.isLegacy = false;
|
|
19
21
|
this.currentNetwork = satsConnect.BitcoinNetworkType.Mainnet;
|
|
20
22
|
}
|
|
21
23
|
getGenericUserCancelledError() {
|
|
@@ -126,13 +128,17 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
|
|
|
126
128
|
signTransaction(params) {
|
|
127
129
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
128
130
|
const { allowedSignHash, psbtBase64, broadcast, inputsToSign } = params;
|
|
131
|
+
const signPbstPayload = {
|
|
132
|
+
allowedSignHash,
|
|
133
|
+
broadcast,
|
|
134
|
+
psbt: psbtBase64,
|
|
135
|
+
signInputs: Object.fromEntries(inputsToSign.map((input) => [input.address, input.signingIndexes])),
|
|
136
|
+
};
|
|
137
|
+
walletConnectorCore.logger.logVerboseTroubleshootingMessage('[BitcoinSatsConnectConnector] signTransaction', {
|
|
138
|
+
signPbstPayload,
|
|
139
|
+
});
|
|
129
140
|
try {
|
|
130
|
-
const response = yield satsConnect.request('signPsbt',
|
|
131
|
-
allowedSignHash,
|
|
132
|
-
broadcast,
|
|
133
|
-
psbt: psbtBase64,
|
|
134
|
-
signInputs: Object.fromEntries(inputsToSign.map((input) => [input.address, input.signingIndexes])),
|
|
135
|
-
});
|
|
141
|
+
const response = yield satsConnect.request('signPsbt', signPbstPayload);
|
|
136
142
|
if (response.status !== 'success') {
|
|
137
143
|
throw response.error;
|
|
138
144
|
}
|
|
@@ -147,8 +153,15 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
|
|
|
147
153
|
signTransactions(transactions) {
|
|
148
154
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
149
155
|
const { message, psbts, network } = transactions;
|
|
156
|
+
walletConnectorCore.logger.logVerboseTroubleshootingMessage('[BitcoinSatsConnectConnector] signTransactions', {
|
|
157
|
+
transactions,
|
|
158
|
+
});
|
|
150
159
|
return new Promise((resolve, reject) => {
|
|
151
160
|
satsConnect.signMultipleTransactions({
|
|
161
|
+
getProvider: () => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
162
|
+
var _a, _b;
|
|
163
|
+
return (_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.features[_const.SATSCONNECT_FEATURE]) === null || _b === void 0 ? void 0 : _b.provider;
|
|
164
|
+
}),
|
|
152
165
|
onCancel: () => {
|
|
153
166
|
const error = this.getGenericUserCancelledError();
|
|
154
167
|
reject(error);
|
|
@@ -174,9 +187,15 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
|
|
|
174
187
|
const psbtFromBase64 = bitcoinjsLib.Psbt.fromBase64(request.unsignedPsbtBase64, {
|
|
175
188
|
network,
|
|
176
189
|
});
|
|
190
|
+
walletConnectorCore.logger.logVerboseTroubleshootingMessage('signPsbt', {
|
|
191
|
+
isLegacy: this.isLegacy,
|
|
192
|
+
psbtFromBase64,
|
|
193
|
+
request,
|
|
194
|
+
});
|
|
177
195
|
const signedPsbt = yield this.signTransaction({
|
|
196
|
+
allowedSignHash: request.allowedSighash[0],
|
|
178
197
|
broadcast: false,
|
|
179
|
-
inputsToSign: createSignPsbtOptions.createSignPsbtOptionsForSatsConnect(psbtFromBase64, request),
|
|
198
|
+
inputsToSign: createSignPsbtOptions.createSignPsbtOptionsForSatsConnect(psbtFromBase64, request, this.isLegacy),
|
|
180
199
|
psbtBase64: request.unsignedPsbtBase64,
|
|
181
200
|
});
|
|
182
201
|
if (!signedPsbt) {
|
|
@@ -200,12 +219,13 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
|
|
|
200
219
|
const psbtFromBase64 = bitcoinjsLib.Psbt.fromBase64(request.unsignedPsbtBase64, {
|
|
201
220
|
network,
|
|
202
221
|
});
|
|
203
|
-
const inputsToSign = createSignPsbtOptions.createSignPsbtOptionsForSatsConnect(psbtFromBase64, request);
|
|
222
|
+
const inputsToSign = createSignPsbtOptions.createSignPsbtOptionsForSatsConnect(psbtFromBase64, request, this.isLegacy);
|
|
204
223
|
signMultipleTransactionPayload.psbts.push({
|
|
205
224
|
inputsToSign,
|
|
206
225
|
psbtBase64: request.unsignedPsbtBase64,
|
|
207
226
|
});
|
|
208
227
|
}
|
|
228
|
+
walletConnectorCore.logger.logVerboseTroubleshootingMessage('signPsbts', signMultipleTransactionPayload);
|
|
209
229
|
const signedPsbts = yield this.signTransactions(signMultipleTransactionPayload);
|
|
210
230
|
return (_a = signedPsbts === null || signedPsbts === void 0 ? void 0 : signedPsbts.map((signedPsbts) => signedPsbts.psbtBase64)) !== null && _a !== void 0 ? _a : [];
|
|
211
231
|
});
|
|
@@ -2,6 +2,7 @@ import { BitcoinNetworkType, SignMultipleTransactionsPayload, SignTransactionRes
|
|
|
2
2
|
import { BitcoinSignPsbtRequest, BitcoinSignPsbtResponse, BitcoinTransaction, SatsConnectSignTransactionInput } from '../../types';
|
|
3
3
|
import { BitcoinWalletConnector, BitcoinWalletConnectorOpts } from '../BitcoinWalletConnector';
|
|
4
4
|
export declare abstract class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
5
|
+
isLegacy: boolean;
|
|
5
6
|
currentNetwork: BitcoinNetworkType;
|
|
6
7
|
constructor(opts: BitcoinWalletConnectorOpts);
|
|
7
8
|
private getGenericUserCancelledError;
|
|
@@ -8,10 +8,12 @@ import { logger } from '@dynamic-labs/wallet-connector-core';
|
|
|
8
8
|
import { convertNetworkTypeForPsbt } from '../../utils/psbt/bitcoinNetworkTypeToNetworks.js';
|
|
9
9
|
import { BitcoinWalletConnector } from '../BitcoinWalletConnector.js';
|
|
10
10
|
import { createSignPsbtOptionsForSatsConnect } from '../../utils/psbt/createSignPsbtOptions.js';
|
|
11
|
+
import { SATSCONNECT_FEATURE } from '../../const.js';
|
|
11
12
|
|
|
12
13
|
class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
13
14
|
constructor(opts) {
|
|
14
15
|
super(opts);
|
|
16
|
+
this.isLegacy = false;
|
|
15
17
|
this.currentNetwork = BitcoinNetworkType.Mainnet;
|
|
16
18
|
}
|
|
17
19
|
getGenericUserCancelledError() {
|
|
@@ -122,13 +124,17 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
|
122
124
|
signTransaction(params) {
|
|
123
125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
124
126
|
const { allowedSignHash, psbtBase64, broadcast, inputsToSign } = params;
|
|
127
|
+
const signPbstPayload = {
|
|
128
|
+
allowedSignHash,
|
|
129
|
+
broadcast,
|
|
130
|
+
psbt: psbtBase64,
|
|
131
|
+
signInputs: Object.fromEntries(inputsToSign.map((input) => [input.address, input.signingIndexes])),
|
|
132
|
+
};
|
|
133
|
+
logger.logVerboseTroubleshootingMessage('[BitcoinSatsConnectConnector] signTransaction', {
|
|
134
|
+
signPbstPayload,
|
|
135
|
+
});
|
|
125
136
|
try {
|
|
126
|
-
const response = yield request('signPsbt',
|
|
127
|
-
allowedSignHash,
|
|
128
|
-
broadcast,
|
|
129
|
-
psbt: psbtBase64,
|
|
130
|
-
signInputs: Object.fromEntries(inputsToSign.map((input) => [input.address, input.signingIndexes])),
|
|
131
|
-
});
|
|
137
|
+
const response = yield request('signPsbt', signPbstPayload);
|
|
132
138
|
if (response.status !== 'success') {
|
|
133
139
|
throw response.error;
|
|
134
140
|
}
|
|
@@ -143,8 +149,15 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
|
143
149
|
signTransactions(transactions) {
|
|
144
150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
145
151
|
const { message, psbts, network } = transactions;
|
|
152
|
+
logger.logVerboseTroubleshootingMessage('[BitcoinSatsConnectConnector] signTransactions', {
|
|
153
|
+
transactions,
|
|
154
|
+
});
|
|
146
155
|
return new Promise((resolve, reject) => {
|
|
147
156
|
signMultipleTransactions({
|
|
157
|
+
getProvider: () => __awaiter(this, void 0, void 0, function* () {
|
|
158
|
+
var _a, _b;
|
|
159
|
+
return (_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.features[SATSCONNECT_FEATURE]) === null || _b === void 0 ? void 0 : _b.provider;
|
|
160
|
+
}),
|
|
148
161
|
onCancel: () => {
|
|
149
162
|
const error = this.getGenericUserCancelledError();
|
|
150
163
|
reject(error);
|
|
@@ -170,9 +183,15 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
|
170
183
|
const psbtFromBase64 = Psbt.fromBase64(request.unsignedPsbtBase64, {
|
|
171
184
|
network,
|
|
172
185
|
});
|
|
186
|
+
logger.logVerboseTroubleshootingMessage('signPsbt', {
|
|
187
|
+
isLegacy: this.isLegacy,
|
|
188
|
+
psbtFromBase64,
|
|
189
|
+
request,
|
|
190
|
+
});
|
|
173
191
|
const signedPsbt = yield this.signTransaction({
|
|
192
|
+
allowedSignHash: request.allowedSighash[0],
|
|
174
193
|
broadcast: false,
|
|
175
|
-
inputsToSign: createSignPsbtOptionsForSatsConnect(psbtFromBase64, request),
|
|
194
|
+
inputsToSign: createSignPsbtOptionsForSatsConnect(psbtFromBase64, request, this.isLegacy),
|
|
176
195
|
psbtBase64: request.unsignedPsbtBase64,
|
|
177
196
|
});
|
|
178
197
|
if (!signedPsbt) {
|
|
@@ -196,12 +215,13 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
|
196
215
|
const psbtFromBase64 = Psbt.fromBase64(request.unsignedPsbtBase64, {
|
|
197
216
|
network,
|
|
198
217
|
});
|
|
199
|
-
const inputsToSign = createSignPsbtOptionsForSatsConnect(psbtFromBase64, request);
|
|
218
|
+
const inputsToSign = createSignPsbtOptionsForSatsConnect(psbtFromBase64, request, this.isLegacy);
|
|
200
219
|
signMultipleTransactionPayload.psbts.push({
|
|
201
220
|
inputsToSign,
|
|
202
221
|
psbtBase64: request.unsignedPsbtBase64,
|
|
203
222
|
});
|
|
204
223
|
}
|
|
224
|
+
logger.logVerboseTroubleshootingMessage('signPsbts', signMultipleTransactionPayload);
|
|
205
225
|
const signedPsbts = yield this.signTransactions(signMultipleTransactionPayload);
|
|
206
226
|
return (_a = signedPsbts === null || signedPsbts === void 0 ? void 0 : signedPsbts.map((signedPsbts) => signedPsbts.psbtBase64)) !== null && _a !== void 0 ? _a : [];
|
|
207
227
|
});
|
package/src/connectors/BitcoinSatsConnectLegacyConnector/BitcoinSatsConnectLegacyConnector.cjs
CHANGED
|
@@ -16,6 +16,10 @@ var BitcoinSatsConnectConnector = require('../BitcoinSatsConnectConnector/Bitcoi
|
|
|
16
16
|
var supportsSatsConnect = require('../../utils/supportsSatsConnect.cjs');
|
|
17
17
|
|
|
18
18
|
class BitcoinSatsConnectLegacyConnector extends BitcoinSatsConnectConnector.BitcoinSatsConnectConnector {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.isLegacy = true;
|
|
22
|
+
}
|
|
19
23
|
getAddress() {
|
|
20
24
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
21
25
|
var _a;
|
package/src/connectors/BitcoinSatsConnectLegacyConnector/BitcoinSatsConnectLegacyConnector.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { SignMultipleTransactionsPayload, SignTransactionResponse } from 'sats-c
|
|
|
2
2
|
import { BitcoinTransaction, SatsConnectSignTransactionInput } from '../../types';
|
|
3
3
|
import { BitcoinSatsConnectConnector } from '../BitcoinSatsConnectConnector';
|
|
4
4
|
export declare abstract class BitcoinSatsConnectLegacyConnector extends BitcoinSatsConnectConnector {
|
|
5
|
+
isLegacy: boolean;
|
|
5
6
|
getAddress(): Promise<string | undefined>;
|
|
6
7
|
signMessage(messageToSign: string, withAddress: string): Promise<string | undefined>;
|
|
7
8
|
sendBitcoin(transaction: BitcoinTransaction): Promise<string | undefined>;
|
package/src/connectors/BitcoinSatsConnectLegacyConnector/BitcoinSatsConnectLegacyConnector.js
CHANGED
|
@@ -12,6 +12,10 @@ import { BitcoinSatsConnectConnector } from '../BitcoinSatsConnectConnector/Bitc
|
|
|
12
12
|
import { supportsSatsConnect } from '../../utils/supportsSatsConnect.js';
|
|
13
13
|
|
|
14
14
|
class BitcoinSatsConnectLegacyConnector extends BitcoinSatsConnectConnector {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.isLegacy = true;
|
|
18
|
+
}
|
|
15
19
|
getAddress() {
|
|
16
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
21
|
var _a;
|
|
@@ -129,7 +129,7 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
129
129
|
connectedAccount = yield this.getAddressPromise;
|
|
130
130
|
}
|
|
131
131
|
catch (error) {
|
|
132
|
-
walletConnectorCore.logger.error(`${this.key} getConnectedAccounts - error fetching connected account
|
|
132
|
+
walletConnectorCore.logger.error(`${this.key} getConnectedAccounts - error fetching connected account`, error);
|
|
133
133
|
//don't throw error just return empty array after clearing the promise
|
|
134
134
|
}
|
|
135
135
|
this.getAddressPromise = undefined;
|
|
@@ -125,7 +125,7 @@ class BitcoinWalletConnector extends WalletConnectorBase {
|
|
|
125
125
|
connectedAccount = yield this.getAddressPromise;
|
|
126
126
|
}
|
|
127
127
|
catch (error) {
|
|
128
|
-
logger.error(`${this.key} getConnectedAccounts - error fetching connected account
|
|
128
|
+
logger.error(`${this.key} getConnectedAccounts - error fetching connected account`, error);
|
|
129
129
|
//don't throw error just return empty array after clearing the promise
|
|
130
130
|
}
|
|
131
131
|
this.getAddressPromise = undefined;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
6
7
|
var validatePsbt = require('./validator/validatePsbt.cjs');
|
|
7
8
|
var getSigHashType = require('./getSigHashType.cjs');
|
|
8
9
|
require('bitcoinjs-lib');
|
|
@@ -32,19 +33,23 @@ const createPsbtOptions = (psbt, request) => {
|
|
|
32
33
|
}
|
|
33
34
|
return psbtSignOptions;
|
|
34
35
|
};
|
|
35
|
-
const createSignPsbtOptionsForSatsConnect = (psbtFromBase64, request) => {
|
|
36
|
+
const createSignPsbtOptionsForSatsConnect = (psbtFromBase64, request, isLegacyConnector = false) => {
|
|
36
37
|
var _a, _b, _c;
|
|
37
38
|
if ((_a = request.signature) === null || _a === void 0 ? void 0 : _a.length) {
|
|
38
39
|
validatePsbt.validatePsbt(psbtFromBase64, request.allowedSighash, request.signature);
|
|
39
40
|
}
|
|
41
|
+
walletConnectorCore.logger.logVerboseTroubleshootingMessage('createSignPsbtOptionsForSatsConnect', { isLegacyConnector, psbtFromBase64, request });
|
|
40
42
|
const inputsToSign = ((_c = (_b = request.signature) === null || _b === void 0 ? void 0 : _b.map((sig) => {
|
|
41
43
|
var _a;
|
|
42
44
|
return ((_a = sig.signingIndexes) !== null && _a !== void 0 ? _a : []).map((inputIndex) => ({
|
|
43
45
|
address: sig.address,
|
|
44
|
-
sigHash:
|
|
46
|
+
sigHash: isLegacyConnector
|
|
47
|
+
? getSigHashType.getSigHashType(psbtFromBase64.data.inputs[inputIndex])
|
|
48
|
+
: request.allowedSighash[0],
|
|
45
49
|
signingIndexes: [inputIndex],
|
|
46
50
|
}));
|
|
47
51
|
})) !== null && _c !== void 0 ? _c : []).flat();
|
|
52
|
+
walletConnectorCore.logger.logVerboseTroubleshootingMessage('createSignPsbtOptionsForSatsConnect', { inputsToSign });
|
|
48
53
|
return inputsToSign;
|
|
49
54
|
};
|
|
50
55
|
|
|
@@ -2,4 +2,4 @@ import { Psbt } from 'bitcoinjs-lib';
|
|
|
2
2
|
import { InputToSign } from 'sats-connect';
|
|
3
3
|
import { BitcoinSignPsbtRequest, SignPsbtOptions } from '../../types';
|
|
4
4
|
export declare const createPsbtOptions: (psbt: Psbt, request: BitcoinSignPsbtRequest) => SignPsbtOptions;
|
|
5
|
-
export declare const createSignPsbtOptionsForSatsConnect: (psbtFromBase64: Psbt, request: BitcoinSignPsbtRequest) => InputToSign[];
|
|
5
|
+
export declare const createSignPsbtOptionsForSatsConnect: (psbtFromBase64: Psbt, request: BitcoinSignPsbtRequest, isLegacyConnector?: boolean) => InputToSign[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client'
|
|
2
|
+
import { logger } from '@dynamic-labs/wallet-connector-core';
|
|
2
3
|
import { validatePsbt } from './validator/validatePsbt.js';
|
|
3
4
|
import { getSigHashType } from './getSigHashType.js';
|
|
4
5
|
import 'bitcoinjs-lib';
|
|
@@ -28,19 +29,23 @@ const createPsbtOptions = (psbt, request) => {
|
|
|
28
29
|
}
|
|
29
30
|
return psbtSignOptions;
|
|
30
31
|
};
|
|
31
|
-
const createSignPsbtOptionsForSatsConnect = (psbtFromBase64, request) => {
|
|
32
|
+
const createSignPsbtOptionsForSatsConnect = (psbtFromBase64, request, isLegacyConnector = false) => {
|
|
32
33
|
var _a, _b, _c;
|
|
33
34
|
if ((_a = request.signature) === null || _a === void 0 ? void 0 : _a.length) {
|
|
34
35
|
validatePsbt(psbtFromBase64, request.allowedSighash, request.signature);
|
|
35
36
|
}
|
|
37
|
+
logger.logVerboseTroubleshootingMessage('createSignPsbtOptionsForSatsConnect', { isLegacyConnector, psbtFromBase64, request });
|
|
36
38
|
const inputsToSign = ((_c = (_b = request.signature) === null || _b === void 0 ? void 0 : _b.map((sig) => {
|
|
37
39
|
var _a;
|
|
38
40
|
return ((_a = sig.signingIndexes) !== null && _a !== void 0 ? _a : []).map((inputIndex) => ({
|
|
39
41
|
address: sig.address,
|
|
40
|
-
sigHash:
|
|
42
|
+
sigHash: isLegacyConnector
|
|
43
|
+
? getSigHashType(psbtFromBase64.data.inputs[inputIndex])
|
|
44
|
+
: request.allowedSighash[0],
|
|
41
45
|
signingIndexes: [inputIndex],
|
|
42
46
|
}));
|
|
43
47
|
})) !== null && _c !== void 0 ? _c : []).flat();
|
|
48
|
+
logger.logVerboseTroubleshootingMessage('createSignPsbtOptionsForSatsConnect', { inputsToSign });
|
|
44
49
|
return inputsToSign;
|
|
45
50
|
};
|
|
46
51
|
|