@scure/btc-signer 1.0.1 โ†’ 1.1.0

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/README.md CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  Audited & minimal library for creating, signing & decoding Bitcoin transactions.
4
4
 
5
+ - ๐Ÿ”’ [**Audited**](#security) by an independent security firm
5
6
  - โœ๏ธ Create transactions, inputs, outputs, sign them
6
7
  - ๐Ÿ“ก No network code: simplified audits and offline usage
7
8
  - ๐ŸŽป Classic & SegWit: P2PK, P2PKH, P2WPKH, P2SH, P2WSH, P2MS
8
9
  - ๐Ÿงช Schnorr & Taproot BIP340/BIP341: P2TR, P2TR-NS, P2TR-MS
9
10
  - ๐Ÿ“จ BIP174 PSBT
10
11
  - ๐Ÿ‘ฅ Multisig support
11
- - ๐Ÿ”’ [**Audited**](#security) by an independent security firm
12
12
  - ๐Ÿชถ ~2600 lines
13
13
 
14
14
  Initial development has been funded by [Ryan Shea](https://shea.io). Check out [the demo](https://signerdemo.micro-btc.dev/) & [its github](https://github.com/shea256/micro-btc-web-demo).
@@ -17,14 +17,14 @@ Initial development has been funded by [Ryan Shea](https://shea.io). Check out [
17
17
 
18
18
  > **scure** โ€” secure, independently audited packages for every use case.
19
19
 
20
- - All releases are signed with PGP keys
20
+ - Minimal or zero dependencies
21
+ - Releases are signed with PGP keys and built transparently with NPM provenance
21
22
  - Check out all libraries:
22
23
  [base](https://github.com/paulmillr/scure-base),
23
24
  [bip32](https://github.com/paulmillr/scure-bip32),
24
25
  [bip39](https://github.com/paulmillr/scure-bip39),
25
- [btc-signer](https://github.com/paulmillr/scure-btc-signer)
26
-
27
- *Check out all web3 utility libraries:* [ETH](https://github.com/paulmillr/micro-eth-signer), [BTC](https://github.com/paulmillr/scure-btc-signer), [SOL](https://github.com/paulmillr/micro-sol-signer), [micro-web3](https://github.com/paulmillr/micro-web3), [tx-tor-broadcaster](https://github.com/paulmillr/tx-tor-broadcaster)
26
+ [btc-signer](https://github.com/paulmillr/scure-btc-signer),
27
+ [starknet](https://github.com/paulmillr/scure-starknet)
28
28
 
29
29
  ## Usage
30
30
 
@@ -36,7 +36,7 @@ For React Native, you may need a [polyfill for crypto.getRandomValues](https://g
36
36
 
37
37
  ```ts
38
38
  import * as btc from '@scure/btc-signer';
39
- // import * as btc from "npm:@scure/btc-signer@0.5.0"; // Deno
39
+ // import * as btc from "npm:@scure/btc-signer@1.0.0"; // Deno
40
40
  ```
41
41
 
42
42
  ### Table of Contents
@@ -621,10 +621,10 @@ const epriv =
621
621
  'tprv8ZgxMBicQKsPd9TeAdPADNnSyH9SSUUbTVeFszDE23Ki6TBB5nCefAdHkK8Fm3qMQR6sHwA56zqRmKmxnHk37JkiFzvncDqoKmPWubu7hDF';
622
622
  const hdkey = bip32.HDKey.fromExtendedKey(epriv, testnet.bip32);
623
623
  // const seed = 'cUkG8i1RFfWGWy5ziR11zJ5V4U4W3viSFCfyJmZnvQaUsd1xuF3T';
624
- const tx = new btc.Transaction(2);
624
+ const tx = new btc.Transaction();
625
625
  // A creator creating a PSBT for a transaction which creates the following outputs:
626
- tx.addOutput({ script: '0014d85c2b71d0060b09c9886aeb815e50991dda124d', amount: '1.49990000' });
627
- tx.addOutput({ script: '001400aea9a2e5f0f876a588df5546e8742d1d87008f', amount: '1.00000000' });
626
+ tx.addOutput({ script: '0014d85c2b71d0060b09c9886aeb815e50991dda124d', amount: btc.Decimal.decode('1.49990000') });
627
+ tx.addOutput({ script: '001400aea9a2e5f0f876a588df5546e8742d1d87008f', amount: btc.Decimal.decode('1.00000000') });
628
628
  // and spends the following inputs:
629
629
  tx.addInput({
630
630
  txid: '75ddabb27b8845f5247975c8a5ba7c6f336c4570708ebe230caf6db5217ae858',
@@ -696,7 +696,7 @@ const psbt2 = tx2.toPSBT();
696
696
  // An updater which adds SIGHASH_ALL to the above PSBT must create this PSBT:
697
697
  const tx3 = btc.Transaction.fromPSBT(psbt2);
698
698
  for (let i = 0; i < tx3.inputs.length; i++)
699
- tx3.updateInput(i, { sighashType: btc.SignatureHash.ALL });
699
+ tx3.updateInput(i, { sighashType: btc.SigHash.ALL });
700
700
  const psbt3 = tx3.toPSBT();
701
701
  /*
702
702
  Given the above updated PSBT, a signer that supports SIGHASH_ALL for P2PKH and P2WPKH spends and uses RFC6979 for nonce generation and has the following keys:
@@ -836,16 +836,36 @@ deepStrictEqual(
836
836
 
837
837
  ## Security
838
838
 
839
- The library has been audited on Feb 21, 2023 by an independent security firm cure53: [PDF](./audit/2023-02-21-cure53-audit-report.pdf). The audit has been funded by Ryan Shea.
840
-
841
- Target was v0.3.0 (commit 397ed56), see [changes since audit](https://github.com/paulmillr/scure-btc-signer/compare/0.3.0..main).
842
-
843
- We consider infrastructure attacks like rogue NPM modules very important; that's why it's crucial to minimize the amount of 3rd-party dependencies & native bindings. If your app uses 500 dependencies, any dep could get hacked and you'll be downloading malware with every `npm install`. Our goal is to minimize this attack vector. As for dependencies used by the library:
844
-
845
- - noble-curves, noble-hashes are audited cryptography libraries also developed by us and follow the same practices
846
- - scure-base is used for bech32 / base64 and was also audited
847
- - micro-packed is used for binary encoding, has not been audited
848
- - devDependencies contain scure-bip32, micro-packed-debugger, micro-should (our packages). Locked versions of prettier (linter) and typescript which are rarely updated. Every update is checked with `npm-diff`. They are only used if you clone the git repo and want to add some feature to it. End-users won't use them
839
+ The library has been independently audited:
840
+
841
+ - at version 0.3.0, in Feb 2023, by [cure53](https://cure53.de)
842
+ - PDFs: [online](https://cure53.de/audit-report_micro-btc-signer.pdf), [offline](./audit/2023-02-21-cure53-audit-report.pdf)
843
+ - [Changes since audit](https://github.com/paulmillr/scure-btc-signer/compare/0.3.0..main).
844
+ - The audit has been funded by [Ryan Shea](https://shea.io)
845
+
846
+ ### Supply chain security
847
+
848
+ 1. **Commits** are signed with PGP keys, to prevent forgery. Make sure to verify commit signatures.
849
+ 2. **Releases** are transparent and built on GitHub CI. Make sure to verify [provenance](https://docs.npmjs.com/generating-provenance-statements) logs
850
+ 3. **Rare releasing** is followed.
851
+ The less often it is done, the less code dependents would need to audit
852
+ 4. **Dependencies** are minimal:
853
+ - All deps are prevented from automatic updates and have locked-down version ranges. Every update is checked with `npm-diff`
854
+ - Updates themselves are rare, to ensure rogue updates are not catched accidentally
855
+ - [noble-hashes](https://github.com/paulmillr/noble-hashes) provides hashing functionality
856
+ - [noble-curves](https://github.com/paulmillr/noble-curves) provides elliptic curve cryptography
857
+ - [scure-base](https://github.com/paulmillr/scure-base) provides bech32 / base64
858
+ - [micro-packed](https://github.com/paulmillr/micro-packed) provides binary encoding - it has not been audited
859
+ 5. devDependencies are only used if you want to contribute to the repo. They are disabled for end-users:
860
+ - scure-bip32, micro-packed-debugger and micro-should are developed by the same author and follow identical security practices
861
+ - prettier (linter), fast-check (property-based testing) and typescript are used for code quality, vector generation and ts compilation. The packages are big, which makes it hard to audit their source code thoroughly and fully
862
+
863
+ We consider infrastructure attacks like rogue NPM modules very important;
864
+ that's why it's crucial to minimize the amount of 3rd-party dependencies & native bindings.
865
+ If your app uses 500 dependencies, any dep could get hacked and you'll be
866
+ downloading malware with every install. Our goal is to minimize this attack vector.
867
+
868
+ If you see anything unusual: investigate and report.
849
869
 
850
870
  ## License
851
871
 
package/index.d.ts CHANGED
@@ -1007,7 +1007,7 @@ export declare const RawPSBTV2: P.CoderType<({
1007
1007
  readonly proprietary: readonly [252, P.CoderType<Uint8Array>, P.CoderType<Uint8Array>, readonly [], readonly [0, 2], false];
1008
1008
  }>[];
1009
1009
  } & {})>;
1010
- type P2Ret = {
1010
+ export type P2Ret = {
1011
1011
  type: string;
1012
1012
  script: Bytes;
1013
1013
  address?: string;
@@ -1088,7 +1088,6 @@ type TaprootLeaf = {
1088
1088
  script: Bytes;
1089
1089
  hash: Bytes;
1090
1090
  path: Bytes[];
1091
- tapInternalKey?: Bytes;
1092
1091
  };
1093
1092
  export declare const TAPROOT_UNSPENDABLE_KEY: Uint8Array;
1094
1093
  export type P2TROut = P2Ret & {
@@ -1103,7 +1102,7 @@ export declare function p2tr(internalPubKey?: Bytes | string, tree?: TaprootScri
1103
1102
  pubKeyHash: number;
1104
1103
  scriptHash: number;
1105
1104
  wif: number;
1106
- }, allowUnknowOutput?: boolean): P2TROut;
1105
+ }, allowUnknownOutputs?: boolean): P2TROut;
1107
1106
  type OutTRNSType = {
1108
1107
  type: 'tr_ns';
1109
1108
  pubkeys: Bytes[];
@@ -1135,7 +1134,7 @@ export declare function programToWitness(version: number, data: Bytes, network?:
1135
1134
  pubKeyHash: number;
1136
1135
  scriptHash: number;
1137
1136
  wif: number;
1138
- }): string;
1137
+ }): `${Lowercase<string>}1${string}`;
1139
1138
  export declare function WIF(network?: {
1140
1139
  bech32: string;
1141
1140
  pubKeyHash: number;
@@ -1151,6 +1150,10 @@ export declare function Address(network?: {
1151
1150
  encode(from: P.UnwrapCoder<typeof OutScript>): string;
1152
1151
  decode(address: string): P.UnwrapCoder<typeof OutScript>;
1153
1152
  };
1153
+ /**
1154
+ * Internal, exported only for backwards-compat. Use `SigHash` instead.
1155
+ * @deprecated
1156
+ */
1154
1157
  export declare enum SignatureHash {
1155
1158
  DEFAULT = 0,
1156
1159
  ALL = 1,
@@ -1158,7 +1161,16 @@ export declare enum SignatureHash {
1158
1161
  SINGLE = 3,
1159
1162
  ANYONECANPAY = 128
1160
1163
  }
1161
- export declare const SigHashCoder: P.CoderType<"DEFAULT" | "ALL" | "NONE" | "SINGLE" | "ANYONECANPAY">;
1164
+ export declare enum SigHash {
1165
+ DEFAULT = 0,
1166
+ ALL = 1,
1167
+ NONE = 2,
1168
+ SINGLE = 3,
1169
+ DEFAULT_ANYONECANPAY = 128,
1170
+ ALL_ANYONECANPAY = 129,
1171
+ NONE_ANYONECANPAY = 130,
1172
+ SINGLE_ANYONECANPAY = 131
1173
+ }
1162
1174
  export declare const _sortPubkeys: (pubkeys: Bytes[]) => Uint8Array[];
1163
1175
  export type TransactionInput = P.UnwrapCoder<typeof PSBTInputCoder>;
1164
1176
  export type TransactionInputUpdate = ExtendType<TransactionInput, {
@@ -1194,8 +1206,12 @@ export type TxOpts = {
1194
1206
  version?: number;
1195
1207
  lockTime?: number;
1196
1208
  PSBTVersion?: number;
1209
+ /** @deprecated Use `allowUnknownOutputs` */
1197
1210
  allowUnknowOutput?: boolean;
1211
+ allowUnknownOutputs?: boolean;
1212
+ /** @deprecated Use `allowUnknownInputs` */
1198
1213
  allowUnknowInput?: boolean;
1214
+ allowUnknownInputs?: boolean;
1199
1215
  disableScriptCheck?: boolean;
1200
1216
  bip174jsCompat?: boolean;
1201
1217
  allowLegacyWitnessUtxo?: boolean;
@@ -1205,8 +1221,12 @@ declare function validateOpts(opts: TxOpts): Readonly<{
1205
1221
  version: number;
1206
1222
  lockTime: number;
1207
1223
  PSBTVersion: number;
1224
+ /** @deprecated Use `allowUnknownOutputs` */
1208
1225
  allowUnknowOutput?: boolean | undefined;
1226
+ allowUnknownOutputs?: boolean | undefined;
1227
+ /** @deprecated Use `allowUnknownInputs` */
1209
1228
  allowUnknowInput?: boolean | undefined;
1229
+ allowUnknownInputs?: boolean | undefined;
1210
1230
  disableScriptCheck?: boolean | undefined;
1211
1231
  bip174jsCompat?: boolean | undefined;
1212
1232
  allowLegacyWitnessUtxo?: boolean | undefined;
@@ -1344,7 +1364,7 @@ export declare class Transaction {
1344
1364
  private preimageWitnessV1;
1345
1365
  private prevOut;
1346
1366
  private inputType;
1347
- signIdx(privateKey: Signer, idx: number, allowedSighash?: SignatureHash[], _auxRand?: Bytes): boolean;
1367
+ signIdx(privateKey: Signer, idx: number, allowedSighash?: SigHash[], _auxRand?: Bytes): boolean;
1348
1368
  sign(privateKey: Signer, allowedSighash?: number[], _auxRand?: Bytes): number;
1349
1369
  finalizeIdx(idx: number): void;
1350
1370
  finalize(): void;
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAA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,OAAO,EAAE,KAAK,EAAE,OAAO;;;;;CAAU,sBAQxF;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,UAAQ,EAAE,OAAO,UAAQ,SAGpF;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,UAAQ,SAE1E;AAGD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAehD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,KAAK,CAMjD"}
package/index.js CHANGED
@@ -431,6 +431,7 @@ export function OpToNum(op, bytesLimit = 4, forceMinimal = true) {
431
431
  return;
432
432
  }
433
433
  }
434
+ return;
434
435
  }
435
436
  // BTC specific variable length integer encoding
436
437
  // https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer
@@ -746,10 +747,10 @@ const PSBTInputCoder = P.validate(PSBTKeyMap(PSBTInput), (i) => {
746
747
  if (i.partialSig && !i.partialSig.length)
747
748
  throw new Error('Empty partialSig');
748
749
  if (i.partialSig)
749
- for (const [k, v] of i.partialSig)
750
+ for (const [k] of i.partialSig)
750
751
  validatePubkey(k, PubT.ecdsa);
751
752
  if (i.bip32Derivation)
752
- for (const [k, v] of i.bip32Derivation)
753
+ for (const [k] of i.bip32Derivation)
753
754
  validatePubkey(k, PubT.ecdsa);
754
755
  // Locktime = unsigned little endian integer greater than or equal to 500000000 representing
755
756
  if (i.requiredTimeLocktime !== undefined && i.requiredTimeLocktime < 500000000)
@@ -791,7 +792,7 @@ const PSBTInputCoder = P.validate(PSBTKeyMap(PSBTInput), (i) => {
791
792
  });
792
793
  const PSBTOutputCoder = P.validate(PSBTKeyMap(PSBTOutput), (o) => {
793
794
  if (o.bip32Derivation)
794
- for (const [k, v] of o.bip32Derivation)
795
+ for (const [k] of o.bip32Derivation)
795
796
  validatePubkey(k, PubT.ecdsa);
796
797
  return o;
797
798
  });
@@ -966,7 +967,9 @@ const OutPK = {
966
967
  },
967
968
  decode: (to) => (to.type === 'pk' ? [to.pubkey, 'CHECKSIG'] : undefined),
968
969
  };
970
+ // @ts-ignore
969
971
  export const p2pk = (pubkey, network = NETWORK) => {
972
+ // network is unused
970
973
  if (!isValidPubkey(pubkey, PubT.ecdsa))
971
974
  throw new Error('P2PK: invalid publicKey');
972
975
  return {
@@ -1121,34 +1124,47 @@ export function taprootListToTree(taprootList) {
1121
1124
  const last = lst[0];
1122
1125
  return (last?.childs || last);
1123
1126
  }
1124
- function checkTaprootScript(script, allowUnknowOutput = false) {
1127
+ function checkTaprootScript(script, internalPubKey, allowUnknownOutputs = false) {
1125
1128
  const out = OutScript.decode(script);
1126
- if (out.type === 'unknown' && allowUnknowOutput)
1129
+ if (out.type === 'unknown' && allowUnknownOutputs)
1127
1130
  return;
1128
1131
  if (!['tr_ns', 'tr_ms'].includes(out.type))
1129
1132
  throw new Error(`P2TR: invalid leaf script=${out.type}`);
1133
+ const outms = out;
1134
+ if (!allowUnknownOutputs && outms.pubkeys) {
1135
+ for (const p of outms.pubkeys) {
1136
+ if (P.equalBytes(p, TAPROOT_UNSPENDABLE_KEY))
1137
+ throw new Error('Unspendable taproot key in leaf script');
1138
+ // It's likely a mistake at this point:
1139
+ // 1. p2tr(A, p2tr_ns(2, [A, B])) == p2tr(A, p2tr_pk(B)) (A or B key)
1140
+ // but will take more space and fees.
1141
+ // 2. For multi-sig p2tr(A, p2tr_ns(2, [A, B, C])) it's probably a security issue:
1142
+ // User creates 2 of 3 multisig of keys [A, B, C],
1143
+ // but key A always can spend whole output without signatures from other keys.
1144
+ // p2tr(A, p2tr_ns(2, [B, C, D])) is ok: A or (B and C) or (B and D) or (C and D)
1145
+ if (P.equalBytes(p, internalPubKey)) {
1146
+ throw new Error('Using P2TR with leaf script with same key as internal key is not supported');
1147
+ }
1148
+ }
1149
+ }
1130
1150
  }
1131
- function taprootHashTree(tree, allowUnknowOutput = false) {
1151
+ function taprootHashTree(tree, internalPubKey, allowUnknownOutputs = false) {
1132
1152
  if (!tree)
1133
1153
  throw new Error('taprootHashTree: empty tree');
1134
1154
  if (Array.isArray(tree) && tree.length === 1)
1135
1155
  tree = tree[0];
1136
1156
  // Terminal node (leaf)
1137
1157
  if (!Array.isArray(tree)) {
1138
- const { leafVersion: version, script: leafScript, tapInternalKey } = tree;
1158
+ const { leafVersion: version, script: leafScript } = tree;
1139
1159
  // Earliest tree walk where we can validate tapScripts
1140
1160
  if (tree.tapLeafScript || (tree.tapMerkleRoot && !P.equalBytes(tree.tapMerkleRoot, P.EMPTY)))
1141
1161
  throw new Error('P2TR: tapRoot leafScript cannot have tree');
1142
- // Just to be sure that it is spendable
1143
- if (tapInternalKey && P.equalBytes(tapInternalKey, TAPROOT_UNSPENDABLE_KEY))
1144
- throw new Error('P2TR: tapRoot leafScript cannot have unspendble key');
1145
1162
  const script = typeof leafScript === 'string' ? hex.decode(leafScript) : leafScript;
1146
1163
  if (!isBytes(script))
1147
1164
  throw new Error(`checkScript: wrong script type=${script}`);
1148
- checkTaprootScript(script, allowUnknowOutput);
1165
+ checkTaprootScript(script, internalPubKey, allowUnknownOutputs);
1149
1166
  return {
1150
1167
  type: 'leaf',
1151
- tapInternalKey,
1152
1168
  version,
1153
1169
  script,
1154
1170
  hash: tapLeafHash(script, version),
@@ -1161,8 +1177,8 @@ function taprootHashTree(tree, allowUnknowOutput = false) {
1161
1177
  throw new Error('hashTree: non binary tree!');
1162
1178
  // branch
1163
1179
  // Both nodes should exist
1164
- const left = taprootHashTree(tree[0], allowUnknowOutput);
1165
- const right = taprootHashTree(tree[1], allowUnknowOutput);
1180
+ const left = taprootHashTree(tree[0], internalPubKey, allowUnknownOutputs);
1181
+ const right = taprootHashTree(tree[1], internalPubKey, allowUnknownOutputs);
1166
1182
  // We cannot swap left/right here, since it will change structure of tree
1167
1183
  let [lH, rH] = [left.hash, right.hash];
1168
1184
  if (_cmpBytes(rH, lH) === -1)
@@ -1203,7 +1219,7 @@ export const TAPROOT_UNSPENDABLE_KEY = sha256(ProjPoint.BASE.toRawBytes(false));
1203
1219
  // Works as key OR tree.
1204
1220
  // If we only have tree, need to add unspendable key, otherwise
1205
1221
  // complex multisig wallet can be spent by owner of key only. See TAPROOT_UNSPENDABLE_KEY
1206
- export function p2tr(internalPubKey, tree, network = NETWORK, allowUnknowOutput = false) {
1222
+ export function p2tr(internalPubKey, tree, network = NETWORK, allowUnknownOutputs = false) {
1207
1223
  // Unspendable
1208
1224
  if (!internalPubKey && !tree)
1209
1225
  throw new Error('p2tr: should have pubKey or scriptTree (or both)');
@@ -1212,7 +1228,9 @@ export function p2tr(internalPubKey, tree, network = NETWORK, allowUnknowOutput
1212
1228
  : internalPubKey || TAPROOT_UNSPENDABLE_KEY;
1213
1229
  if (!isValidPubkey(pubKey, PubT.schnorr))
1214
1230
  throw new Error('p2tr: non-schnorr pubkey');
1215
- let hashedTree = tree ? taprootAddPath(taprootHashTree(tree, allowUnknowOutput)) : undefined;
1231
+ let hashedTree = tree
1232
+ ? taprootAddPath(taprootHashTree(tree, pubKey, allowUnknownOutputs))
1233
+ : undefined;
1216
1234
  const tapMerkleRoot = hashedTree ? hashedTree.hash : undefined;
1217
1235
  const [tweakedPubkey, parity] = taprootTweakPubkey(pubKey, tapMerkleRoot || P.EMPTY);
1218
1236
  let leaves;
@@ -1221,7 +1239,7 @@ export function p2tr(internalPubKey, tree, network = NETWORK, allowUnknowOutput
1221
1239
  ...l,
1222
1240
  controlBlock: TaprootControlBlock.encode({
1223
1241
  version: (l.version || TAP_LEAF_VERSION) + parity,
1224
- internalKey: l.tapInternalKey || pubKey,
1242
+ internalKey: pubKey,
1225
1243
  merklePath: l.path,
1226
1244
  }),
1227
1245
  }));
@@ -1512,7 +1530,7 @@ export function Address(network = NETWORK) {
1512
1530
  else if (version === 1 && data.length === 32)
1513
1531
  return { type: 'tr', pubkey: data };
1514
1532
  else
1515
- throw new Error('Unkown witness program');
1533
+ throw new Error('Unknown witness program');
1516
1534
  }
1517
1535
  const data = base58check.decode(address);
1518
1536
  if (data.length !== 21)
@@ -1532,6 +1550,10 @@ export function Address(network = NETWORK) {
1532
1550
  };
1533
1551
  }
1534
1552
  // /Address
1553
+ /**
1554
+ * Internal, exported only for backwards-compat. Use `SigHash` instead.
1555
+ * @deprecated
1556
+ */
1535
1557
  export var SignatureHash;
1536
1558
  (function (SignatureHash) {
1537
1559
  SignatureHash[SignatureHash["DEFAULT"] = 0] = "DEFAULT";
@@ -1540,7 +1562,22 @@ export var SignatureHash;
1540
1562
  SignatureHash[SignatureHash["SINGLE"] = 3] = "SINGLE";
1541
1563
  SignatureHash[SignatureHash["ANYONECANPAY"] = 128] = "ANYONECANPAY";
1542
1564
  })(SignatureHash || (SignatureHash = {}));
1543
- export const SigHashCoder = P.apply(P.U32LE, P.coders.tsEnum(SignatureHash));
1565
+ export var SigHash;
1566
+ (function (SigHash) {
1567
+ SigHash[SigHash["DEFAULT"] = 0] = "DEFAULT";
1568
+ SigHash[SigHash["ALL"] = 1] = "ALL";
1569
+ SigHash[SigHash["NONE"] = 2] = "NONE";
1570
+ SigHash[SigHash["SINGLE"] = 3] = "SINGLE";
1571
+ SigHash[SigHash["DEFAULT_ANYONECANPAY"] = 128] = "DEFAULT_ANYONECANPAY";
1572
+ SigHash[SigHash["ALL_ANYONECANPAY"] = 129] = "ALL_ANYONECANPAY";
1573
+ SigHash[SigHash["NONE_ANYONECANPAY"] = 130] = "NONE_ANYONECANPAY";
1574
+ SigHash[SigHash["SINGLE_ANYONECANPAY"] = 131] = "SINGLE_ANYONECANPAY";
1575
+ })(SigHash || (SigHash = {}));
1576
+ function validateSigHash(s) {
1577
+ if (typeof s !== 'number' || typeof SigHash[s] !== 'string')
1578
+ throw new Error(`Invalid SigHash=${s}`);
1579
+ return s;
1580
+ }
1544
1581
  function unpackSighash(hashType) {
1545
1582
  const masked = hashType & 0b0011111;
1546
1583
  return {
@@ -1583,17 +1620,21 @@ function getTaprootKeys(privKey, pubKey, internalKey, merkleRoot = P.EMPTY) {
1583
1620
  }
1584
1621
  return { privKey, pubKey };
1585
1622
  }
1586
- // Check if object doens't have custom constructor (like Uint8Array/Array)
1587
- const isPlainObject = (obj) => Object.prototype.toString.call(obj) === '[object Object]' && obj.constructor === Object;
1623
+ const toStr = {}.toString;
1588
1624
  function validateOpts(opts) {
1589
- if (!isPlainObject(opts))
1625
+ if (opts !== undefined && toStr.call(opts) !== '[object Object]')
1590
1626
  throw new Error(`Wrong object type for transaction options: ${opts}`);
1591
1627
  const _opts = {
1592
1628
  ...opts,
1629
+ // Defaults
1593
1630
  version: def(opts.version, DEFAULT_VERSION),
1594
1631
  lockTime: def(opts.lockTime, 0),
1595
1632
  PSBTVersion: def(opts.PSBTVersion, 0),
1596
- }; // Defaults
1633
+ };
1634
+ if (typeof _opts.allowUnknowInput !== 'undefined')
1635
+ opts.allowUnknownInputs = _opts.allowUnknowInput;
1636
+ if (typeof _opts.allowUnknowOutput !== 'undefined')
1637
+ opts.allowUnknownOutputs = _opts.allowUnknowOutput;
1597
1638
  // 0 and -1 happens in tests
1598
1639
  if (![-1, 0, 1, 2].includes(_opts.version))
1599
1640
  throw new Error(`Unknown version: ${_opts.version}`);
@@ -1606,8 +1647,8 @@ function validateOpts(opts) {
1606
1647
  throw new Error(`Unknown PSBT version ${_opts.PSBTVersion}`);
1607
1648
  // Flags
1608
1649
  for (const k of [
1609
- 'allowUnknowOutput',
1610
- 'allowUnknowInput',
1650
+ 'allowUnknownOutputs',
1651
+ 'allowUnknownInputs',
1611
1652
  'disableScriptCheck',
1612
1653
  'bip174jsCompat',
1613
1654
  'allowLegacyWitnessUtxo',
@@ -1973,9 +2014,9 @@ export class Transaction {
1973
2014
  res = mergeKeyMap(PSBTOutput, res, cur, allowedFields);
1974
2015
  PSBTOutputCoder.encode(res);
1975
2016
  if (res.script &&
1976
- !this.opts.allowUnknowOutput &&
2017
+ !this.opts.allowUnknownOutputs &&
1977
2018
  OutScript.decode(res.script).type === 'unknown') {
1978
- throw new Error('Transaction/output: unknown output script type, there is a chance that input is unspendable. Pass allowUnkownScript=true, if you sure');
2019
+ throw new Error('Transaction/output: unknown output script type, there is a chance that input is unspendable. Pass allowUnknownScript=true, if you sure');
1979
2020
  }
1980
2021
  if (!this.opts.disableScriptCheck)
1981
2022
  checkScript(res.script, res.redeemScript, res.witnessScript);
@@ -2120,13 +2161,13 @@ export class Transaction {
2120
2161
  prevOut(input) {
2121
2162
  if (input.nonWitnessUtxo) {
2122
2163
  if (input.index === undefined)
2123
- throw new Error('Uknown input index');
2164
+ throw new Error('Unknown input index');
2124
2165
  return input.nonWitnessUtxo.outputs[input.index];
2125
2166
  }
2126
2167
  else if (input.witnessUtxo)
2127
2168
  return input.witnessUtxo;
2128
2169
  else
2129
- throw new Error('Cannot find previous output info.');
2170
+ throw new Error('Cannot find previous output info');
2130
2171
  }
2131
2172
  inputType(input) {
2132
2173
  let txType = 'legacy';
@@ -2222,6 +2263,8 @@ export class Transaction {
2222
2263
  // Just for compat with bitcoinjs-lib, so users won't face unexpected behaviour.
2223
2264
  if (!allowedSighash)
2224
2265
  allowedSighash = [inputType.defaultSighash];
2266
+ else
2267
+ allowedSighash.forEach(validateSigHash);
2225
2268
  const sighash = inputType.sighash;
2226
2269
  if (!allowedSighash.includes(sighash)) {
2227
2270
  throw new Error(`Input with not allowed sigHash=${sighash}. Allowed: ${allowedSighash.join(', ')}`);
@@ -2230,7 +2273,7 @@ export class Transaction {
2230
2273
  // however this was because of bug in bitcoin-core, which remains here because of consensus.
2231
2274
  // If this is absolutely neccessary for your case, please open issue.
2232
2275
  // We disable it to avoid complicated workflow where SINGLE will block adding new outputs
2233
- const { sigInputs, sigOutputs } = this.inputSighash(idx);
2276
+ const { sigOutputs } = this.inputSighash(idx);
2234
2277
  if (sigOutputs === SignatureHash.SINGLE && idx >= this.outputs.length) {
2235
2278
  throw new Error(`Input with sighash SINGLE, but there is no output with corresponding index=${idx}`);
2236
2279
  }
@@ -2252,7 +2295,7 @@ export class Transaction {
2252
2295
  // otherwise sign as is. bitcoinjs implementation always wants tweaked
2253
2296
  // priv key to be provided
2254
2297
  const { pubKey, privKey } = getTaprootKeys(privateKey, schnorrPub, input.tapInternalKey, merkleRoot);
2255
- const [taprootPubKey, parity] = taprootTweakPubkey(input.tapInternalKey, merkleRoot);
2298
+ const [taprootPubKey, _] = taprootTweakPubkey(input.tapInternalKey, merkleRoot);
2256
2299
  if (P.equalBytes(taprootPubKey, pubKey)) {
2257
2300
  const hash = this.preimageWitnessV1(idx, prevOutScript, sighash, amount);
2258
2301
  const sig = concat(schnorr.sign(hash, privKey, _auxRand), sighash !== SignatureHash.DEFAULT ? new Uint8Array([sighash]) : P.EMPTY);
@@ -2262,20 +2305,19 @@ export class Transaction {
2262
2305
  }
2263
2306
  if (input.tapLeafScript) {
2264
2307
  input.tapScriptSig = input.tapScriptSig || [];
2265
- for (const [cb, _script] of input.tapLeafScript) {
2308
+ for (const [_, _script] of input.tapLeafScript) {
2266
2309
  const script = _script.subarray(0, -1);
2267
2310
  const scriptDecoded = Script.decode(script);
2268
2311
  const ver = _script[_script.length - 1];
2269
2312
  const hash = tapLeafHash(script, ver);
2270
- const { pubKey, privKey } = getTaprootKeys(privateKey, schnorrPub, cb.internalKey, P.EMPTY // Because we cannot have nested taproot tree
2271
- );
2272
- const pos = scriptDecoded.findIndex((i) => isBytes(i) && P.equalBytes(i, pubKey));
2313
+ // NOTE: no need to tweak internal key here, since we don't support nested p2tr
2314
+ const pos = scriptDecoded.findIndex((i) => isBytes(i) && P.equalBytes(i, schnorrPub));
2273
2315
  // Skip if there is no public key in tapLeafScript
2274
2316
  if (pos === -1)
2275
2317
  continue;
2276
2318
  const msg = this.preimageWitnessV1(idx, prevOutScript, sighash, amount, undefined, script, ver);
2277
- const sig = concat(schnorr.sign(msg, privKey, _auxRand), sighash !== SignatureHash.DEFAULT ? new Uint8Array([sighash]) : P.EMPTY);
2278
- this.updateInput(idx, { tapScriptSig: [[{ pubKey: pubKey, leafHash: hash }, sig]] }, true);
2319
+ const sig = concat(schnorr.sign(msg, privateKey, _auxRand), sighash !== SignatureHash.DEFAULT ? new Uint8Array([sighash]) : P.EMPTY);
2320
+ this.updateInput(idx, { tapScriptSig: [[{ pubKey: schnorrPub, leafHash: hash }, sig]] }, true);
2279
2321
  signed = true;
2280
2322
  }
2281
2323
  }
@@ -2385,7 +2427,7 @@ export class Transaction {
2385
2427
  if (signatures.length !== outScript.pubkeys.length)
2386
2428
  continue;
2387
2429
  }
2388
- else if (outScript.type === 'unknown' && this.opts.allowUnknowInput) {
2430
+ else if (outScript.type === 'unknown' && this.opts.allowUnknownInputs) {
2389
2431
  // Trying our best to sign what we can
2390
2432
  const scriptDecoded = Script.decode(script);
2391
2433
  signatures = scriptSig
@@ -2451,7 +2493,7 @@ export class Transaction {
2451
2493
  inputScript = P.EMPTY;
2452
2494
  witness = [input.partialSig[0][1], input.partialSig[0][0]];
2453
2495
  }
2454
- else if (inputType.last.type === 'unknown' && !this.opts.allowUnknowInput)
2496
+ else if (inputType.last.type === 'unknown' && !this.opts.allowUnknownInputs)
2455
2497
  throw new Error('Unknown inputs not allowed');
2456
2498
  // Create final scripts (generic part)
2457
2499
  let finalScriptSig, finalScriptWitness;