@exodus/bitcoin-api 2.15.0 → 2.15.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/bitcoin-api",
3
- "version": "2.15.0",
3
+ "version": "2.15.1",
4
4
  "description": "Exodus bitcoin-api",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -58,5 +58,5 @@
58
58
  "jest-when": "^3.5.1",
59
59
  "safe-buffer": "^5.2.1"
60
60
  },
61
- "gitHead": "364ffb79577938023d87e78e7d24a8e6413af060"
61
+ "gitHead": "19c4a56008f41bfc7001a6b7b8d2e4849b345d93"
62
62
  }
@@ -27,10 +27,14 @@ export function createSignWithWallet({
27
27
  return async (psbt, inputsToSign) => {
28
28
  // The Taproot SIGHASH flag includes all previous outputs,
29
29
  // so signing is only done AFTER all inputs have been updated
30
+ const signingPromises = []
31
+
30
32
  for (let index = 0; index < psbt.inputCount; index++) {
31
33
  const inputInfo = inputsToSign[index]
32
34
  // dApps request to sign only specific transaction inputs.
33
35
  if (!inputInfo) continue
36
+
37
+ const input = psbt.data.inputs[index]
34
38
  const { address, sigHash } = inputInfo
35
39
  // The sighash value from the PSBT input itself will be used.
36
40
  // This list just represents possible sighash values the inputs can have.
@@ -41,8 +45,7 @@ export function createSignWithWallet({
41
45
  const { key, purpose, keyId, publicKey } = await getKeyWithMetadata(address)
42
46
 
43
47
  const isP2SH = purpose === 49
44
- const hasTapLeafScript =
45
- psbt.data.inputs[index].tapLeafScript && psbt.data.inputs[index].tapLeafScript.length > 0
48
+ const hasTapLeafScript = input.tapLeafScript && input.tapLeafScript.length > 0
46
49
  const isTaprootKeySpend = isTaprootPurpose(purpose) && !hasTapLeafScript
47
50
 
48
51
  if (isP2SH) {
@@ -54,7 +57,7 @@ export function createSignWithWallet({
54
57
  const p2sh = payments.p2sh({ redeem: p2wpkh })
55
58
  if (address === p2sh.address) {
56
59
  // Set the redeem script in the psbt in case it's missing.
57
- if (!Buffer.isBuffer(psbt.data.inputs[index].redeemScript)) {
60
+ if (!Buffer.isBuffer(input.redeemScript)) {
58
61
  psbt.updateInput(index, {
59
62
  redeemScript: p2sh.redeem.output,
60
63
  })
@@ -62,7 +65,7 @@ export function createSignWithWallet({
62
65
  } else {
63
66
  throw new Error('Expected P2SH script to be a nested segwit input')
64
67
  }
65
- } else if (isTaprootKeySpend && !Buffer.isBuffer(psbt.data.inputs[index].tapInternalKey)) {
68
+ } else if (isTaprootKeySpend && !Buffer.isBuffer(input.tapInternalKey)) {
66
69
  // tapInternalKey is metadata for signing and not part of the hash to sign.
67
70
  // so modifying it here is fine.
68
71
  psbt.updateInput(index, { tapInternalKey: toXOnly(publicKey) })
@@ -73,7 +76,9 @@ export function createSignWithWallet({
73
76
  : toAsyncSigner({ keyPair: key, isTaprootKeySpend, network })
74
77
 
75
78
  // desktop / BE / mobile with bip-schnorr signing
76
- await psbt.signInputAsync(index, asyncSigner, allowedSigHashTypes)
79
+ signingPromises.push(psbt.signInputAsync(index, asyncSigner, allowedSigHashTypes))
77
80
  }
81
+
82
+ await Promise.all(signingPromises)
78
83
  }
79
84
  }