@dynamic-labs/embedded-wallet-bitcoin 4.27.0 → 4.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.27.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.27.0...v4.27.1) (2025-08-18)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* apple icon black background ([#9363](https://github.com/dynamic-labs/dynamic-auth/issues/9363)) ([b8242e6](https://github.com/dynamic-labs/dynamic-auth/commit/b8242e699f457036f5dbe5e061617d966b6e639e))
|
|
8
|
+
* issue when signing pbst with embedded wallet ([#9356](https://github.com/dynamic-labs/dynamic-auth/issues/9356)) ([3abac9a](https://github.com/dynamic-labs/dynamic-auth/commit/3abac9a52f27a27a95f576e402163ea9d19f69a5))
|
|
9
|
+
* secondary embedded wallets can register session on transactions and signing ([#9030](https://github.com/dynamic-labs/dynamic-auth/issues/9030)) ([716bd95](https://github.com/dynamic-labs/dynamic-auth/commit/716bd9588ac0c435dd6e3e2f37e93f4c488aa0ae))
|
|
10
|
+
* show native balance when on testnet ([#9329](https://github.com/dynamic-labs/dynamic-auth/issues/9329)) ([d8cbe3b](https://github.com/dynamic-labs/dynamic-auth/commit/d8cbe3b319c2ab2f3579e3759ca45913c7434e44))
|
|
11
|
+
|
|
2
12
|
## [4.27.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.26.0...v4.27.0) (2025-08-16)
|
|
3
13
|
|
|
4
14
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/embedded-wallet-bitcoin",
|
|
3
|
-
"version": "4.27.
|
|
3
|
+
"version": "4.27.1",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,17 +19,17 @@
|
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@bitcoinerlab/secp256k1": "1.1.1",
|
|
22
|
-
"@dynamic-labs/bitcoin": "4.27.
|
|
22
|
+
"@dynamic-labs/bitcoin": "4.27.1",
|
|
23
23
|
"@dynamic-labs/sdk-api-core": "0.0.753",
|
|
24
|
-
"@dynamic-labs/types": "4.27.
|
|
25
|
-
"@dynamic-labs/utils": "4.27.
|
|
24
|
+
"@dynamic-labs/types": "4.27.1",
|
|
25
|
+
"@dynamic-labs/utils": "4.27.1",
|
|
26
26
|
"@turnkey/http": "2.15.0",
|
|
27
27
|
"bitcoinjs-lib": "6.1.5",
|
|
28
28
|
"ecpair": "2.1.0",
|
|
29
|
-
"@dynamic-labs/assert-package-version": "4.27.
|
|
30
|
-
"@dynamic-labs/embedded-wallet": "4.27.
|
|
31
|
-
"@dynamic-labs/wallet-book": "4.27.
|
|
32
|
-
"@dynamic-labs/wallet-connector-core": "4.27.
|
|
29
|
+
"@dynamic-labs/assert-package-version": "4.27.1",
|
|
30
|
+
"@dynamic-labs/embedded-wallet": "4.27.1",
|
|
31
|
+
"@dynamic-labs/wallet-book": "4.27.1",
|
|
32
|
+
"@dynamic-labs/wallet-connector-core": "4.27.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {}
|
|
35
35
|
}
|
|
@@ -9,6 +9,7 @@ var ecpair = require('ecpair');
|
|
|
9
9
|
var bitcoinjsLib = require('bitcoinjs-lib');
|
|
10
10
|
var bitcoin = require('@dynamic-labs/bitcoin');
|
|
11
11
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
12
|
+
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
12
13
|
var utils = require('@dynamic-labs/utils');
|
|
13
14
|
var embeddedWallet = require('@dynamic-labs/embedded-wallet');
|
|
14
15
|
var fees = require('./fees.cjs');
|
|
@@ -239,38 +240,60 @@ class TurnkeyBitcoinWalletConnector extends embeddedWallet.TurnkeyWalletConnecto
|
|
|
239
240
|
}
|
|
240
241
|
signPsbt(_a) {
|
|
241
242
|
return _tslib.__awaiter(this, arguments, void 0, function* ({ allowedSighash, unsignedPsbtBase64, signature, }) {
|
|
242
|
-
var _b, _c, _d;
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
243
|
+
var _b, _c, _d, _e, _f, _g, _h;
|
|
244
|
+
try {
|
|
245
|
+
yield this.createOrRestoreSession();
|
|
246
|
+
const accountAddress = this.getAccount();
|
|
247
|
+
if (!accountAddress) {
|
|
248
|
+
throw new Error('Failed to get address');
|
|
249
|
+
}
|
|
250
|
+
const psbt = bitcoinjsLib.Psbt.fromBase64(unsignedPsbtBase64);
|
|
251
|
+
const turnkeyClient = yield this.getTurnkeyAccount();
|
|
252
|
+
if (!turnkeyClient) {
|
|
253
|
+
throw new Error('Failed to get turnkey client');
|
|
254
|
+
}
|
|
255
|
+
const taprootSigner = new signer.TurnkeySigner({
|
|
256
|
+
address: accountAddress,
|
|
257
|
+
client: turnkeyClient,
|
|
258
|
+
organizationId: (_b = this.walletProperties) === null || _b === void 0 ? void 0 : _b.turnkeySubOrganizationId,
|
|
259
|
+
publicKey: bitcoinjsLib.address.fromBech32(accountAddress).data,
|
|
260
|
+
});
|
|
261
|
+
let segwitSigner;
|
|
262
|
+
const paymentAddressInfo = (_d = (_c = this.verifiedCredential) === null || _c === void 0 ? void 0 : _c.walletAdditionalAddresses) === null || _d === void 0 ? void 0 : _d.find((address) => address.type === sdkApiCore.WalletAddressType.Payment);
|
|
263
|
+
if ((paymentAddressInfo === null || paymentAddressInfo === void 0 ? void 0 : paymentAddressInfo.address) && (paymentAddressInfo === null || paymentAddressInfo === void 0 ? void 0 : paymentAddressInfo.publicKey)) {
|
|
264
|
+
segwitSigner = new signer.TurnkeySigner({
|
|
265
|
+
address: paymentAddressInfo.address,
|
|
266
|
+
client: turnkeyClient,
|
|
267
|
+
organizationId: (_e = this.walletProperties) === null || _e === void 0 ? void 0 : _e.turnkeySubOrganizationId,
|
|
268
|
+
publicKey: Buffer.from(paymentAddressInfo.publicKey, 'hex'),
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
if (signature) {
|
|
272
|
+
for (let i = 0; i < signature.length; i++) {
|
|
273
|
+
const sigIdx = (_g = (_f = signature[i]) === null || _f === void 0 ? void 0 : _f.signingIndexes) === null || _g === void 0 ? void 0 : _g[0];
|
|
274
|
+
const address = (_h = signature[i]) === null || _h === void 0 ? void 0 : _h.address;
|
|
275
|
+
const isSigningWithSegwitAddress = (address === null || address === void 0 ? void 0 : address.startsWith('bc1q')) || (address === null || address === void 0 ? void 0 : address.startsWith('tb1q'));
|
|
276
|
+
const signer = segwitSigner && isSigningWithSegwitAddress
|
|
277
|
+
? segwitSigner
|
|
278
|
+
: taprootSigner;
|
|
279
|
+
if (sigIdx !== undefined) {
|
|
280
|
+
yield psbt.signInputAsync(sigIdx, signer, allowedSighash);
|
|
281
|
+
}
|
|
264
282
|
}
|
|
265
283
|
}
|
|
284
|
+
else {
|
|
285
|
+
// use taproot signer by default
|
|
286
|
+
yield psbt.signAllInputsAsync(taprootSigner, allowedSighash);
|
|
287
|
+
}
|
|
288
|
+
psbt.finalizeAllInputs();
|
|
289
|
+
return {
|
|
290
|
+
signedPsbt: psbt.toBase64(),
|
|
291
|
+
};
|
|
266
292
|
}
|
|
267
|
-
|
|
268
|
-
|
|
293
|
+
catch (error) {
|
|
294
|
+
embeddedWallet.logger.error('Error signing PSBT', error);
|
|
295
|
+
throw error;
|
|
269
296
|
}
|
|
270
|
-
psbt.finalizeAllInputs();
|
|
271
|
-
return {
|
|
272
|
-
signedPsbt: psbt.toBase64(),
|
|
273
|
-
};
|
|
274
297
|
});
|
|
275
298
|
}
|
|
276
299
|
signPsbts(requests) {
|
|
@@ -5,6 +5,7 @@ import { ECPairFactory } from 'ecpair';
|
|
|
5
5
|
import { initEccLib, networks, Psbt, payments, address } from 'bitcoinjs-lib';
|
|
6
6
|
import { BitcoinWallet, getMempoolApiUrl, satoshisToBtc } from '@dynamic-labs/bitcoin';
|
|
7
7
|
import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
|
|
8
|
+
import { WalletAddressType } from '@dynamic-labs/sdk-api-core';
|
|
8
9
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
9
10
|
import { TurnkeyWalletConnectorBase, findTurnkeyVerifiedCredentials, logger } from '@dynamic-labs/embedded-wallet';
|
|
10
11
|
import { estimateFees } from './fees.js';
|
|
@@ -231,38 +232,60 @@ class TurnkeyBitcoinWalletConnector extends TurnkeyWalletConnectorBase {
|
|
|
231
232
|
}
|
|
232
233
|
signPsbt(_a) {
|
|
233
234
|
return __awaiter(this, arguments, void 0, function* ({ allowedSighash, unsignedPsbtBase64, signature, }) {
|
|
234
|
-
var _b, _c, _d;
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
235
|
+
var _b, _c, _d, _e, _f, _g, _h;
|
|
236
|
+
try {
|
|
237
|
+
yield this.createOrRestoreSession();
|
|
238
|
+
const accountAddress = this.getAccount();
|
|
239
|
+
if (!accountAddress) {
|
|
240
|
+
throw new Error('Failed to get address');
|
|
241
|
+
}
|
|
242
|
+
const psbt = Psbt.fromBase64(unsignedPsbtBase64);
|
|
243
|
+
const turnkeyClient = yield this.getTurnkeyAccount();
|
|
244
|
+
if (!turnkeyClient) {
|
|
245
|
+
throw new Error('Failed to get turnkey client');
|
|
246
|
+
}
|
|
247
|
+
const taprootSigner = new TurnkeySigner({
|
|
248
|
+
address: accountAddress,
|
|
249
|
+
client: turnkeyClient,
|
|
250
|
+
organizationId: (_b = this.walletProperties) === null || _b === void 0 ? void 0 : _b.turnkeySubOrganizationId,
|
|
251
|
+
publicKey: address.fromBech32(accountAddress).data,
|
|
252
|
+
});
|
|
253
|
+
let segwitSigner;
|
|
254
|
+
const paymentAddressInfo = (_d = (_c = this.verifiedCredential) === null || _c === void 0 ? void 0 : _c.walletAdditionalAddresses) === null || _d === void 0 ? void 0 : _d.find((address) => address.type === WalletAddressType.Payment);
|
|
255
|
+
if ((paymentAddressInfo === null || paymentAddressInfo === void 0 ? void 0 : paymentAddressInfo.address) && (paymentAddressInfo === null || paymentAddressInfo === void 0 ? void 0 : paymentAddressInfo.publicKey)) {
|
|
256
|
+
segwitSigner = new TurnkeySigner({
|
|
257
|
+
address: paymentAddressInfo.address,
|
|
258
|
+
client: turnkeyClient,
|
|
259
|
+
organizationId: (_e = this.walletProperties) === null || _e === void 0 ? void 0 : _e.turnkeySubOrganizationId,
|
|
260
|
+
publicKey: Buffer.from(paymentAddressInfo.publicKey, 'hex'),
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
if (signature) {
|
|
264
|
+
for (let i = 0; i < signature.length; i++) {
|
|
265
|
+
const sigIdx = (_g = (_f = signature[i]) === null || _f === void 0 ? void 0 : _f.signingIndexes) === null || _g === void 0 ? void 0 : _g[0];
|
|
266
|
+
const address = (_h = signature[i]) === null || _h === void 0 ? void 0 : _h.address;
|
|
267
|
+
const isSigningWithSegwitAddress = (address === null || address === void 0 ? void 0 : address.startsWith('bc1q')) || (address === null || address === void 0 ? void 0 : address.startsWith('tb1q'));
|
|
268
|
+
const signer = segwitSigner && isSigningWithSegwitAddress
|
|
269
|
+
? segwitSigner
|
|
270
|
+
: taprootSigner;
|
|
271
|
+
if (sigIdx !== undefined) {
|
|
272
|
+
yield psbt.signInputAsync(sigIdx, signer, allowedSighash);
|
|
273
|
+
}
|
|
256
274
|
}
|
|
257
275
|
}
|
|
276
|
+
else {
|
|
277
|
+
// use taproot signer by default
|
|
278
|
+
yield psbt.signAllInputsAsync(taprootSigner, allowedSighash);
|
|
279
|
+
}
|
|
280
|
+
psbt.finalizeAllInputs();
|
|
281
|
+
return {
|
|
282
|
+
signedPsbt: psbt.toBase64(),
|
|
283
|
+
};
|
|
258
284
|
}
|
|
259
|
-
|
|
260
|
-
|
|
285
|
+
catch (error) {
|
|
286
|
+
logger.error('Error signing PSBT', error);
|
|
287
|
+
throw error;
|
|
261
288
|
}
|
|
262
|
-
psbt.finalizeAllInputs();
|
|
263
|
-
return {
|
|
264
|
-
signedPsbt: psbt.toBase64(),
|
|
265
|
-
};
|
|
266
289
|
});
|
|
267
290
|
}
|
|
268
291
|
signPsbts(requests) {
|