@scure/btc-signer 2.0.0-beta.1 → 2.0.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/package.json CHANGED
@@ -1,25 +1,24 @@
1
1
  {
2
2
  "name": "@scure/btc-signer",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0",
4
4
  "description": "Audited & minimal library for Bitcoin. Handle transactions, Schnorr, Taproot, UTXO & PSBT",
5
5
  "files": [
6
6
  "*.js",
7
7
  "*.d.ts",
8
8
  "*.js.map",
9
9
  "*.d.ts.map",
10
- "src"
10
+ "src",
11
+ "!_type_test.*"
11
12
  ],
12
13
  "dependencies": {
13
- "@noble/curves": "2.0.0-beta.3",
14
- "@noble/hashes": "2.0.0-beta.5",
15
- "@scure/base": "2.0.0-beta.1",
16
- "micro-packed": "0.8.0-beta.1"
14
+ "@noble/curves": "~2.0.0",
15
+ "@noble/hashes": "~2.0.0",
16
+ "@scure/base": "~2.0.0",
17
+ "micro-packed": "~0.8.0"
17
18
  },
18
19
  "devDependencies": {
19
- "@paulmillr/jsbt": "0.4.2",
20
- "@scure/bip32": "~1.7.0",
21
- "micro-bmark": "0.4.2",
22
- "micro-should": "0.5.3",
20
+ "@paulmillr/jsbt": "0.4.4",
21
+ "@scure/bip32": "~2.0.0",
23
22
  "prettier": "3.6.2",
24
23
  "typescript": "5.9.2"
25
24
  },
package/_type_test.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=_type_test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_type_test.d.ts","sourceRoot":"","sources":["src/_type_test.ts"],"names":[],"mappings":""}
package/_type_test.js DELETED
@@ -1,57 +0,0 @@
1
- import { secp256k1 as secp } from '@noble/curves/secp256k1.js';
2
- import { hex } from '@scure/base';
3
- import * as btc from "./index.js";
4
- const privKey1 = hex.decode('0101010101010101010101010101010101010101010101010101010101010101');
5
- const P1 = secp.getPublicKey(privKey1, true);
6
- const wpkh = btc.p2wpkh(P1);
7
- const tx = new btc.Transaction();
8
- // Basic input test
9
- tx.addInput({
10
- txid: hex.decode('0af50a00a22f74ece24c12cd667c290d3a35d48124a69f4082700589172a3aa2'),
11
- index: 0,
12
- ...wpkh,
13
- finalScriptSig: Uint8Array.of(),
14
- sequence: 1,
15
- });
16
- // Doesn't force any fields on input addition (only on sign)
17
- tx.addInput({
18
- sequence: 1,
19
- });
20
- tx.updateInput(0, {
21
- sequence: 1,
22
- });
23
- const nonWitnessUtxo = '0200000001aad73931018bd25f84ae400b68848be09db706eac2ac18298babee71ab656f8b0000000048473044022058f6fc7c6a33e1b31548d481c826c015bd30135aad42cd67790dab66d2ad243b02204a1ced2604c6735b6393e5b41691dd78b00f0c5942fb9f751856faa938157dba01feffffff0280f0fa020000000017a9140fb9463421696b82c833af241c78c17ddbde493487d0f20a270100000017a91429ca74f8a08f81999428185c97b5d852e4063f618765000000';
24
- const nonWitnessUtxoB = hex.decode(nonWitnessUtxo);
25
- tx.updateInput(0, { nonWitnessUtxo: nonWitnessUtxo });
26
- tx.updateInput(0, { nonWitnessUtxo: nonWitnessUtxoB });
27
- tx.addInput({
28
- txid: hex.decode('0af50a00a22f74ece24c12cd667c290d3a35d48124a69f4082700589172a3aa2'),
29
- index: 0,
30
- nonWitnessUtxo: nonWitnessUtxo,
31
- });
32
- tx.addInput({
33
- txid: hex.decode('0af50a00a22f74ece24c12cd667c290d3a35d48124a69f4082700589172a3aa2'),
34
- index: 0,
35
- nonWitnessUtxo: nonWitnessUtxoB,
36
- });
37
- // Should fail!
38
- // tx.updateInput(0, {
39
- // nonWitnessUtxo: 1,
40
- // });
41
- // Outputs
42
- tx.addOutput({ amount: 123n });
43
- // should fail
44
- // tx.updateOutput(0, { amount: '1' });
45
- // tx.updateOutput(0, { amount: 1 });
46
- // should fail
47
- // tx.addOutput({ amount: '123' });
48
- // tx.addOutput({ amount: 123 });
49
- for (let i = 0; i < tx.inputsLength; i++) {
50
- // @ts-ignore
51
- console.log('I', tx.getInput(i));
52
- }
53
- for (let i = 0; i < tx.outputsLength; i++) {
54
- // @ts-ignore
55
- console.log('O', tx.getOutput(i));
56
- }
57
- //# sourceMappingURL=_type_test.js.map
package/_type_test.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"_type_test.js","sourceRoot":"","sources":["src/_type_test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,GAAG,MAAM,YAAY,CAAC;AAElC,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,kEAAkE,CAAC,CAAC;AAChG,MAAM,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAE7C,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAE5B,MAAM,EAAE,GAAG,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;AAEjC,mBAAmB;AACnB,EAAE,CAAC,QAAQ,CAAC;IACV,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,kEAAkE,CAAC;IACpF,KAAK,EAAE,CAAC;IACR,GAAG,IAAI;IACP,cAAc,EAAE,UAAU,CAAC,EAAE,EAAE;IAC/B,QAAQ,EAAE,CAAC;CACZ,CAAC,CAAC;AAEH,4DAA4D;AAC5D,EAAE,CAAC,QAAQ,CAAC;IACV,QAAQ,EAAE,CAAC;CACZ,CAAC,CAAC;AAEH,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE;IAChB,QAAQ,EAAE,CAAC;CACZ,CAAC,CAAC;AAEH,MAAM,cAAc,GAClB,wXAAwX,CAAC;AAC3X,MAAM,eAAe,GAAG,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AAEnD,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC,CAAC;AACtD,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC,CAAC;AACvD,EAAE,CAAC,QAAQ,CAAC;IACV,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,kEAAkE,CAAC;IACpF,KAAK,EAAE,CAAC;IACR,cAAc,EAAE,cAAc;CAC/B,CAAC,CAAC;AAEH,EAAE,CAAC,QAAQ,CAAC;IACV,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,kEAAkE,CAAC;IACpF,KAAK,EAAE,CAAC;IACR,cAAc,EAAE,eAAe;CAChC,CAAC,CAAC;AAEH,eAAe;AACf,sBAAsB;AACtB,uBAAuB;AACvB,MAAM;AACN,UAAU;AACV,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;AAC/B,cAAc;AACd,uCAAuC;AACvC,qCAAqC;AACrC,cAAc;AACd,mCAAmC;AACnC,iCAAiC;AAEjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC,EAAE,EAAE,CAAC;IACzC,aAAa;IACb,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,aAAa,EAAE,CAAC,EAAE,EAAE,CAAC;IAC1C,aAAa;IACb,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC"}
package/src/_type_test.ts DELETED
@@ -1,69 +0,0 @@
1
- import { secp256k1 as secp } from '@noble/curves/secp256k1.js';
2
- import { hex } from '@scure/base';
3
- import * as btc from './index.ts';
4
-
5
- const privKey1 = hex.decode('0101010101010101010101010101010101010101010101010101010101010101');
6
- const P1 = secp.getPublicKey(privKey1, true);
7
-
8
- const wpkh = btc.p2wpkh(P1);
9
-
10
- const tx = new btc.Transaction();
11
-
12
- // Basic input test
13
- tx.addInput({
14
- txid: hex.decode('0af50a00a22f74ece24c12cd667c290d3a35d48124a69f4082700589172a3aa2'),
15
- index: 0,
16
- ...wpkh,
17
- finalScriptSig: Uint8Array.of(),
18
- sequence: 1,
19
- });
20
-
21
- // Doesn't force any fields on input addition (only on sign)
22
- tx.addInput({
23
- sequence: 1,
24
- });
25
-
26
- tx.updateInput(0, {
27
- sequence: 1,
28
- });
29
-
30
- const nonWitnessUtxo =
31
- '0200000001aad73931018bd25f84ae400b68848be09db706eac2ac18298babee71ab656f8b0000000048473044022058f6fc7c6a33e1b31548d481c826c015bd30135aad42cd67790dab66d2ad243b02204a1ced2604c6735b6393e5b41691dd78b00f0c5942fb9f751856faa938157dba01feffffff0280f0fa020000000017a9140fb9463421696b82c833af241c78c17ddbde493487d0f20a270100000017a91429ca74f8a08f81999428185c97b5d852e4063f618765000000';
32
- const nonWitnessUtxoB = hex.decode(nonWitnessUtxo);
33
-
34
- tx.updateInput(0, { nonWitnessUtxo: nonWitnessUtxo });
35
- tx.updateInput(0, { nonWitnessUtxo: nonWitnessUtxoB });
36
- tx.addInput({
37
- txid: hex.decode('0af50a00a22f74ece24c12cd667c290d3a35d48124a69f4082700589172a3aa2'),
38
- index: 0,
39
- nonWitnessUtxo: nonWitnessUtxo,
40
- });
41
-
42
- tx.addInput({
43
- txid: hex.decode('0af50a00a22f74ece24c12cd667c290d3a35d48124a69f4082700589172a3aa2'),
44
- index: 0,
45
- nonWitnessUtxo: nonWitnessUtxoB,
46
- });
47
-
48
- // Should fail!
49
- // tx.updateInput(0, {
50
- // nonWitnessUtxo: 1,
51
- // });
52
- // Outputs
53
- tx.addOutput({ amount: 123n });
54
- // should fail
55
- // tx.updateOutput(0, { amount: '1' });
56
- // tx.updateOutput(0, { amount: 1 });
57
- // should fail
58
- // tx.addOutput({ amount: '123' });
59
- // tx.addOutput({ amount: 123 });
60
-
61
- for (let i = 0; i < tx.inputsLength; i++) {
62
- // @ts-ignore
63
- console.log('I', tx.getInput(i));
64
- }
65
-
66
- for (let i = 0; i < tx.outputsLength; i++) {
67
- // @ts-ignore
68
- console.log('O', tx.getOutput(i));
69
- }