@dynamic-labs/bitcoin 3.0.0-alpha.66 → 3.0.0-alpha.68
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 +25 -0
- package/package.json +6 -6
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.cjs +35 -8
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.d.ts +1 -0
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.js +35 -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,29 @@
|
|
|
1
1
|
|
|
2
|
+
## [3.0.0-alpha.68](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.67...v3.0.0-alpha.68) (2024-09-12)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* combine signing inputs for new signTransaction method in bitcoin sats connector by address ([#6882](https://github.com/dynamic-labs/DynamicAuth/issues/6882)) ([dd78923](https://github.com/dynamic-labs/DynamicAuth/commit/dd78923e84042dbd23977c595467a6d587b729fb))
|
|
8
|
+
* log message during v1 embedded wallet email recovery ([#6877](https://github.com/dynamic-labs/DynamicAuth/issues/6877)) ([92fd70e](https://github.com/dynamic-labs/DynamicAuth/commit/92fd70e8d685edf334cb60c61b6411441fbfe54d))
|
|
9
|
+
* return correct chain format for smart wallets ([#6878](https://github.com/dynamic-labs/DynamicAuth/issues/6878)) ([e26544a](https://github.com/dynamic-labs/DynamicAuth/commit/e26544ad39277fcd5e94cf70cd871f7111f7a3c2))
|
|
10
|
+
|
|
11
|
+
## [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)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* 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))
|
|
17
|
+
* 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))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* 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))
|
|
23
|
+
* 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))
|
|
24
|
+
* 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))
|
|
25
|
+
* solana transaction decoder fallback ([#6868](https://github.com/dynamic-labs/DynamicAuth/issues/6868)) ([38c9242](https://github.com/dynamic-labs/DynamicAuth/commit/38c924253c29e8e3569d9da9bc452a8cdc3af0d2))
|
|
26
|
+
|
|
2
27
|
## [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
28
|
|
|
4
29
|
|
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.68",
|
|
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.68",
|
|
36
|
+
"@dynamic-labs/utils": "3.0.0-alpha.68",
|
|
37
|
+
"@dynamic-labs/wallet-book": "3.0.0-alpha.68",
|
|
38
|
+
"@dynamic-labs/wallet-connector-core": "3.0.0-alpha.68",
|
|
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,24 @@ 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
|
+
// we have to combine signing indexes for like addresses
|
|
136
|
+
signInputs: inputsToSign.reduce((accum, curr) => {
|
|
137
|
+
if (!accum[curr.address]) {
|
|
138
|
+
accum[curr.address] = [];
|
|
139
|
+
}
|
|
140
|
+
accum[curr.address].push(...curr.signingIndexes);
|
|
141
|
+
return accum;
|
|
142
|
+
}, {}),
|
|
143
|
+
};
|
|
144
|
+
walletConnectorCore.logger.logVerboseTroubleshootingMessage('[BitcoinSatsConnectConnector] signTransaction', {
|
|
145
|
+
signPbstPayload,
|
|
146
|
+
});
|
|
129
147
|
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
|
-
});
|
|
148
|
+
const response = yield satsConnect.request('signPsbt', signPbstPayload);
|
|
136
149
|
if (response.status !== 'success') {
|
|
137
150
|
throw response.error;
|
|
138
151
|
}
|
|
@@ -147,8 +160,15 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
|
|
|
147
160
|
signTransactions(transactions) {
|
|
148
161
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
149
162
|
const { message, psbts, network } = transactions;
|
|
163
|
+
walletConnectorCore.logger.logVerboseTroubleshootingMessage('[BitcoinSatsConnectConnector] signTransactions', {
|
|
164
|
+
transactions,
|
|
165
|
+
});
|
|
150
166
|
return new Promise((resolve, reject) => {
|
|
151
167
|
satsConnect.signMultipleTransactions({
|
|
168
|
+
getProvider: () => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
var _a, _b;
|
|
170
|
+
return (_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.features[_const.SATSCONNECT_FEATURE]) === null || _b === void 0 ? void 0 : _b.provider;
|
|
171
|
+
}),
|
|
152
172
|
onCancel: () => {
|
|
153
173
|
const error = this.getGenericUserCancelledError();
|
|
154
174
|
reject(error);
|
|
@@ -174,9 +194,15 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
|
|
|
174
194
|
const psbtFromBase64 = bitcoinjsLib.Psbt.fromBase64(request.unsignedPsbtBase64, {
|
|
175
195
|
network,
|
|
176
196
|
});
|
|
197
|
+
walletConnectorCore.logger.logVerboseTroubleshootingMessage('signPsbt', {
|
|
198
|
+
isLegacy: this.isLegacy,
|
|
199
|
+
psbtFromBase64,
|
|
200
|
+
request,
|
|
201
|
+
});
|
|
177
202
|
const signedPsbt = yield this.signTransaction({
|
|
203
|
+
allowedSignHash: request.allowedSighash[0],
|
|
178
204
|
broadcast: false,
|
|
179
|
-
inputsToSign: createSignPsbtOptions.createSignPsbtOptionsForSatsConnect(psbtFromBase64, request),
|
|
205
|
+
inputsToSign: createSignPsbtOptions.createSignPsbtOptionsForSatsConnect(psbtFromBase64, request, this.isLegacy),
|
|
180
206
|
psbtBase64: request.unsignedPsbtBase64,
|
|
181
207
|
});
|
|
182
208
|
if (!signedPsbt) {
|
|
@@ -200,12 +226,13 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
|
|
|
200
226
|
const psbtFromBase64 = bitcoinjsLib.Psbt.fromBase64(request.unsignedPsbtBase64, {
|
|
201
227
|
network,
|
|
202
228
|
});
|
|
203
|
-
const inputsToSign = createSignPsbtOptions.createSignPsbtOptionsForSatsConnect(psbtFromBase64, request);
|
|
229
|
+
const inputsToSign = createSignPsbtOptions.createSignPsbtOptionsForSatsConnect(psbtFromBase64, request, this.isLegacy);
|
|
204
230
|
signMultipleTransactionPayload.psbts.push({
|
|
205
231
|
inputsToSign,
|
|
206
232
|
psbtBase64: request.unsignedPsbtBase64,
|
|
207
233
|
});
|
|
208
234
|
}
|
|
235
|
+
walletConnectorCore.logger.logVerboseTroubleshootingMessage('signPsbts', signMultipleTransactionPayload);
|
|
209
236
|
const signedPsbts = yield this.signTransactions(signMultipleTransactionPayload);
|
|
210
237
|
return (_a = signedPsbts === null || signedPsbts === void 0 ? void 0 : signedPsbts.map((signedPsbts) => signedPsbts.psbtBase64)) !== null && _a !== void 0 ? _a : [];
|
|
211
238
|
});
|
|
@@ -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,24 @@ 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
|
+
// we have to combine signing indexes for like addresses
|
|
132
|
+
signInputs: inputsToSign.reduce((accum, curr) => {
|
|
133
|
+
if (!accum[curr.address]) {
|
|
134
|
+
accum[curr.address] = [];
|
|
135
|
+
}
|
|
136
|
+
accum[curr.address].push(...curr.signingIndexes);
|
|
137
|
+
return accum;
|
|
138
|
+
}, {}),
|
|
139
|
+
};
|
|
140
|
+
logger.logVerboseTroubleshootingMessage('[BitcoinSatsConnectConnector] signTransaction', {
|
|
141
|
+
signPbstPayload,
|
|
142
|
+
});
|
|
125
143
|
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
|
-
});
|
|
144
|
+
const response = yield request('signPsbt', signPbstPayload);
|
|
132
145
|
if (response.status !== 'success') {
|
|
133
146
|
throw response.error;
|
|
134
147
|
}
|
|
@@ -143,8 +156,15 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
|
143
156
|
signTransactions(transactions) {
|
|
144
157
|
return __awaiter(this, void 0, void 0, function* () {
|
|
145
158
|
const { message, psbts, network } = transactions;
|
|
159
|
+
logger.logVerboseTroubleshootingMessage('[BitcoinSatsConnectConnector] signTransactions', {
|
|
160
|
+
transactions,
|
|
161
|
+
});
|
|
146
162
|
return new Promise((resolve, reject) => {
|
|
147
163
|
signMultipleTransactions({
|
|
164
|
+
getProvider: () => __awaiter(this, void 0, void 0, function* () {
|
|
165
|
+
var _a, _b;
|
|
166
|
+
return (_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.features[SATSCONNECT_FEATURE]) === null || _b === void 0 ? void 0 : _b.provider;
|
|
167
|
+
}),
|
|
148
168
|
onCancel: () => {
|
|
149
169
|
const error = this.getGenericUserCancelledError();
|
|
150
170
|
reject(error);
|
|
@@ -170,9 +190,15 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
|
170
190
|
const psbtFromBase64 = Psbt.fromBase64(request.unsignedPsbtBase64, {
|
|
171
191
|
network,
|
|
172
192
|
});
|
|
193
|
+
logger.logVerboseTroubleshootingMessage('signPsbt', {
|
|
194
|
+
isLegacy: this.isLegacy,
|
|
195
|
+
psbtFromBase64,
|
|
196
|
+
request,
|
|
197
|
+
});
|
|
173
198
|
const signedPsbt = yield this.signTransaction({
|
|
199
|
+
allowedSignHash: request.allowedSighash[0],
|
|
174
200
|
broadcast: false,
|
|
175
|
-
inputsToSign: createSignPsbtOptionsForSatsConnect(psbtFromBase64, request),
|
|
201
|
+
inputsToSign: createSignPsbtOptionsForSatsConnect(psbtFromBase64, request, this.isLegacy),
|
|
176
202
|
psbtBase64: request.unsignedPsbtBase64,
|
|
177
203
|
});
|
|
178
204
|
if (!signedPsbt) {
|
|
@@ -196,12 +222,13 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
|
196
222
|
const psbtFromBase64 = Psbt.fromBase64(request.unsignedPsbtBase64, {
|
|
197
223
|
network,
|
|
198
224
|
});
|
|
199
|
-
const inputsToSign = createSignPsbtOptionsForSatsConnect(psbtFromBase64, request);
|
|
225
|
+
const inputsToSign = createSignPsbtOptionsForSatsConnect(psbtFromBase64, request, this.isLegacy);
|
|
200
226
|
signMultipleTransactionPayload.psbts.push({
|
|
201
227
|
inputsToSign,
|
|
202
228
|
psbtBase64: request.unsignedPsbtBase64,
|
|
203
229
|
});
|
|
204
230
|
}
|
|
231
|
+
logger.logVerboseTroubleshootingMessage('signPsbts', signMultipleTransactionPayload);
|
|
205
232
|
const signedPsbts = yield this.signTransactions(signMultipleTransactionPayload);
|
|
206
233
|
return (_a = signedPsbts === null || signedPsbts === void 0 ? void 0 : signedPsbts.map((signedPsbts) => signedPsbts.psbtBase64)) !== null && _a !== void 0 ? _a : [];
|
|
207
234
|
});
|
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
|
|