@arkade-os/sdk 0.3.0-alpha.0 → 0.3.0-alpha.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.
Files changed (63) hide show
  1. package/dist/cjs/arknote/index.js +4 -4
  2. package/dist/cjs/bip322/index.js +9 -7
  3. package/dist/cjs/forfeit.js +2 -2
  4. package/dist/cjs/identity/singleKey.js +7 -7
  5. package/dist/cjs/index.js +2 -2
  6. package/dist/cjs/musig2/keys.js +1 -1
  7. package/dist/cjs/musig2/nonces.js +1 -1
  8. package/dist/cjs/musig2/sign.js +1 -1
  9. package/dist/cjs/networks.js +6 -6
  10. package/dist/cjs/script/address.js +3 -3
  11. package/dist/cjs/script/base.js +7 -7
  12. package/dist/cjs/script/tapscript.js +21 -21
  13. package/dist/cjs/script/vhtlc.js +2 -2
  14. package/dist/cjs/tree/signingSession.js +8 -7
  15. package/dist/cjs/tree/txTree.js +6 -6
  16. package/dist/cjs/tree/validation.js +5 -5
  17. package/dist/cjs/utils/arkTransaction.js +5 -5
  18. package/dist/cjs/utils/unknownFields.js +5 -5
  19. package/dist/cjs/wallet/onchain.js +5 -5
  20. package/dist/cjs/wallet/unroll.js +6 -6
  21. package/dist/cjs/wallet/wallet.js +16 -16
  22. package/dist/esm/arknote/index.js +2 -2
  23. package/dist/esm/bip322/index.js +3 -1
  24. package/dist/esm/forfeit.js +1 -1
  25. package/dist/esm/identity/singleKey.js +2 -2
  26. package/dist/esm/index.js +1 -1
  27. package/dist/esm/musig2/keys.js +1 -1
  28. package/dist/esm/musig2/nonces.js +1 -1
  29. package/dist/esm/musig2/sign.js +1 -1
  30. package/dist/esm/networks.js +1 -1
  31. package/dist/esm/script/address.js +1 -1
  32. package/dist/esm/script/base.js +3 -3
  33. package/dist/esm/script/tapscript.js +2 -2
  34. package/dist/esm/script/vhtlc.js +1 -1
  35. package/dist/esm/tree/signingSession.js +3 -2
  36. package/dist/esm/tree/txTree.js +2 -2
  37. package/dist/esm/tree/validation.js +2 -2
  38. package/dist/esm/utils/arkTransaction.js +2 -2
  39. package/dist/esm/utils/unknownFields.js +1 -1
  40. package/dist/esm/wallet/onchain.js +2 -2
  41. package/dist/esm/wallet/unroll.js +2 -2
  42. package/dist/esm/wallet/wallet.js +4 -4
  43. package/dist/types/arknote/index.d.ts +1 -1
  44. package/dist/types/bip322/index.d.ts +2 -2
  45. package/dist/types/forfeit.d.ts +1 -1
  46. package/dist/types/identity/index.d.ts +1 -1
  47. package/dist/types/identity/singleKey.d.ts +1 -1
  48. package/dist/types/index.d.ts +1 -1
  49. package/dist/types/script/address.d.ts +1 -1
  50. package/dist/types/script/base.d.ts +1 -1
  51. package/dist/types/script/default.d.ts +1 -1
  52. package/dist/types/script/tapscript.d.ts +1 -1
  53. package/dist/types/script/vhtlc.d.ts +1 -1
  54. package/dist/types/tree/txTree.d.ts +1 -1
  55. package/dist/types/tree/validation.d.ts +1 -1
  56. package/dist/types/utils/anchor.d.ts +1 -1
  57. package/dist/types/utils/arkTransaction.d.ts +3 -3
  58. package/dist/types/utils/unknownFields.d.ts +1 -1
  59. package/dist/types/wallet/index.d.ts +1 -1
  60. package/dist/types/wallet/onchain.d.ts +2 -2
  61. package/dist/types/wallet/unroll.d.ts +1 -1
  62. package/dist/types/wallet/wallet.d.ts +1 -1
  63. package/package.json +2 -2
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ArkNote = void 0;
4
4
  const base_1 = require("@scure/base");
5
5
  const base_2 = require("../script/base");
6
- const utils_1 = require("@scure/btc-signer/utils");
7
- const btc_signer_1 = require("@scure/btc-signer");
6
+ const utils_js_1 = require("@scure/btc-signer/utils.js");
7
+ const script_js_1 = require("@scure/btc-signer/script.js");
8
8
  /**
9
9
  * ArkNotes are special virtual coins in the Ark protocol that can be created
10
10
  * and spent without requiring any transactions. The server mints them, and they
@@ -29,7 +29,7 @@ class ArkNote {
29
29
  this.value = value;
30
30
  this.HRP = HRP;
31
31
  this.vout = 0;
32
- const preimageHash = (0, utils_1.sha256)(this.preimage);
32
+ const preimageHash = (0, utils_js_1.sha256)(this.preimage);
33
33
  this.vtxoScript = new base_2.VtxoScript([noteTapscript(preimageHash)]);
34
34
  const leaf = this.vtxoScript.leaves[0];
35
35
  this.txid = base_1.hex.encode(new Uint8Array(preimageHash).reverse());
@@ -85,5 +85,5 @@ function readUInt32BE(array, offset) {
85
85
  return view.getUint32(0, false);
86
86
  }
87
87
  function noteTapscript(preimageHash) {
88
- return btc_signer_1.Script.encode(["SHA256", preimageHash, "EQUAL"]);
88
+ return script_js_1.Script.encode(["SHA256", preimageHash, "EQUAL"]);
89
89
  }
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BIP322 = void 0;
4
4
  exports.craftToSpendTx = craftToSpendTx;
5
- const btc_signer_1 = require("@scure/btc-signer");
5
+ const script_js_1 = require("@scure/btc-signer/script.js");
6
+ const transaction_js_1 = require("@scure/btc-signer/transaction.js");
7
+ const script_js_2 = require("@scure/btc-signer/script.js");
6
8
  const errors_1 = require("./errors");
7
9
  const secp256k1_js_1 = require("@noble/curves/secp256k1.js");
8
10
  const base_1 = require("@scure/base");
@@ -75,7 +77,7 @@ var BIP322;
75
77
  }
76
78
  BIP322.signature = signature;
77
79
  })(BIP322 || (exports.BIP322 = BIP322 = {}));
78
- const OP_RETURN_EMPTY_PKSCRIPT = new Uint8Array([btc_signer_1.OP.RETURN]);
80
+ const OP_RETURN_EMPTY_PKSCRIPT = new Uint8Array([script_js_1.OP.RETURN]);
79
81
  const ZERO_32 = new Uint8Array(32).fill(0);
80
82
  const MAX_INDEX = 0xffffffff;
81
83
  const TAG_BIP322 = "BIP0322-signed-message";
@@ -106,7 +108,7 @@ function validateOutputs(outputs) {
106
108
  // craftToSpendTx creates the initial transaction that will be spent in the proof
107
109
  function craftToSpendTx(message, pkScript) {
108
110
  const messageHash = hashMessage(message);
109
- const tx = new btc_signer_1.Transaction({
111
+ const tx = new transaction_js_1.Transaction({
110
112
  version: 0,
111
113
  allowUnknownOutputs: true,
112
114
  allowUnknown: true,
@@ -124,14 +126,14 @@ function craftToSpendTx(message, pkScript) {
124
126
  script: pkScript,
125
127
  });
126
128
  tx.updateInput(0, {
127
- finalScriptSig: btc_signer_1.Script.encode(["OP_0", messageHash]),
129
+ finalScriptSig: script_js_2.Script.encode(["OP_0", messageHash]),
128
130
  });
129
131
  return tx;
130
132
  }
131
133
  // craftToSignTx creates the transaction that will be signed for the proof
132
134
  function craftToSignTx(toSpend, inputs, outputs) {
133
135
  const firstInput = inputs[0];
134
- const tx = new btc_signer_1.Transaction({
136
+ const tx = new transaction_js_1.Transaction({
135
137
  version: 2,
136
138
  allowUnknownOutputs: outputs.length === 0,
137
139
  allowUnknown: true,
@@ -147,13 +149,13 @@ function craftToSignTx(toSpend, inputs, outputs) {
147
149
  script: firstInput.witnessUtxo.script,
148
150
  amount: 0n,
149
151
  },
150
- sighashType: btc_signer_1.SigHash.ALL,
152
+ sighashType: transaction_js_1.SigHash.ALL,
151
153
  });
152
154
  // add other inputs
153
155
  for (const input of inputs) {
154
156
  tx.addInput({
155
157
  ...input,
156
- sighashType: btc_signer_1.SigHash.ALL,
158
+ sighashType: transaction_js_1.SigHash.ALL,
157
159
  });
158
160
  }
159
161
  // add the special OP_RETURN output if no outputs are provided
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildForfeitTx = buildForfeitTx;
4
- const btc_signer_1 = require("@scure/btc-signer");
4
+ const transaction_js_1 = require("@scure/btc-signer/transaction.js");
5
5
  const anchor_1 = require("./utils/anchor");
6
6
  function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
7
- const tx = new btc_signer_1.Transaction({
7
+ const tx = new transaction_js_1.Transaction({
8
8
  version: 3,
9
9
  lockTime: txLocktime,
10
10
  });
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SingleKey = void 0;
4
- const utils_1 = require("@scure/btc-signer/utils");
4
+ const utils_js_1 = require("@scure/btc-signer/utils.js");
5
5
  const base_1 = require("@scure/base");
6
- const btc_signer_1 = require("@scure/btc-signer");
6
+ const transaction_js_1 = require("@scure/btc-signer/transaction.js");
7
7
  const signingSession_1 = require("../tree/signingSession");
8
8
  const secp256k1_1 = require("@noble/secp256k1");
9
9
  const ZERO_32 = new Uint8Array(32).fill(0);
10
- const ALL_SIGHASH = Object.values(btc_signer_1.SigHash).filter((x) => typeof x === "number");
10
+ const ALL_SIGHASH = Object.values(transaction_js_1.SigHash).filter((x) => typeof x === "number");
11
11
  /**
12
12
  * In-memory single key implementation for Bitcoin transaction signing.
13
13
  *
@@ -28,7 +28,7 @@ const ALL_SIGHASH = Object.values(btc_signer_1.SigHash).filter((x) => typeof x =
28
28
  */
29
29
  class SingleKey {
30
30
  constructor(key) {
31
- this.key = key || (0, utils_1.randomPrivateKeyBytes)();
31
+ this.key = key || (0, utils_js_1.randomPrivateKeyBytes)();
32
32
  }
33
33
  static fromPrivateKey(privateKey) {
34
34
  return new SingleKey(privateKey);
@@ -37,7 +37,7 @@ class SingleKey {
37
37
  return new SingleKey(base_1.hex.decode(privateKeyHex));
38
38
  }
39
39
  static fromRandomBytes() {
40
- return new SingleKey((0, utils_1.randomPrivateKeyBytes)());
40
+ return new SingleKey((0, utils_js_1.randomPrivateKeyBytes)());
41
41
  }
42
42
  /**
43
43
  * Export the private key as a hex string.
@@ -74,14 +74,14 @@ class SingleKey {
74
74
  return txCpy;
75
75
  }
76
76
  xOnlyPublicKey() {
77
- return Promise.resolve((0, utils_1.pubSchnorr)(this.key));
77
+ return Promise.resolve((0, utils_js_1.pubSchnorr)(this.key));
78
78
  }
79
79
  signerSession() {
80
80
  return signingSession_1.TreeSignerSession.random();
81
81
  }
82
82
  async signMessage(message) {
83
83
  const msgBytes = new TextEncoder().encode(message);
84
- return secp256k1_1.schnorr.sign((0, utils_1.sha256)(msgBytes), this.key);
84
+ return secp256k1_1.schnorr.sign((0, utils_js_1.sha256)(msgBytes), this.key);
85
85
  }
86
86
  }
87
87
  exports.SingleKey = SingleKey;
package/dist/cjs/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Transaction = exports.Unroll = exports.P2A = exports.TxTree = exports.BIP322 = exports.ContractRepositoryImpl = exports.WalletRepositoryImpl = exports.networks = exports.ArkNote = exports.waitForIncomingFunds = exports.buildOffchainTx = exports.ConditionWitness = exports.VtxoTaprootTree = exports.VtxoTreeExpiry = exports.CosignerPublicKey = exports.getArkPsbtFields = exports.setArkPsbtField = exports.ArkPsbtFieldKeyType = exports.ArkPsbtFieldKey = exports.CLTVMultisigTapscript = exports.ConditionMultisigTapscript = exports.ConditionCSVMultisigTapscript = exports.CSVMultisigTapscript = exports.MultisigTapscript = exports.decodeTapscript = exports.Response = exports.Request = exports.ServiceWorkerWallet = exports.Worker = exports.setupServiceWorker = exports.SettlementEventType = exports.ChainTxType = exports.IndexerTxType = exports.TxType = exports.VHTLC = exports.VtxoScript = exports.DefaultVtxo = exports.ArkAddress = exports.RestIndexerProvider = exports.RestArkProvider = exports.EsploraProvider = exports.ESPLORA_URL = exports.Ramps = exports.OnchainWallet = exports.SingleKey = exports.Wallet = void 0;
4
- const btc_signer_1 = require("@scure/btc-signer");
5
- Object.defineProperty(exports, "Transaction", { enumerable: true, get: function () { return btc_signer_1.Transaction; } });
4
+ const transaction_js_1 = require("@scure/btc-signer/transaction.js");
5
+ Object.defineProperty(exports, "Transaction", { enumerable: true, get: function () { return transaction_js_1.Transaction; } });
6
6
  const singleKey_1 = require("./identity/singleKey");
7
7
  Object.defineProperty(exports, "SingleKey", { enumerable: true, get: function () { return singleKey_1.SingleKey; } });
8
8
  const address_1 = require("./script/address");
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.aggregateKeys = aggregateKeys;
37
- const musig = __importStar(require("@scure/btc-signer/musig2"));
37
+ const musig = __importStar(require("@scure/btc-signer/musig2.js"));
38
38
  const secp256k1_js_1 = require("@noble/curves/secp256k1.js");
39
39
  // Aggregates multiple public keys according to the MuSig2 algorithm
40
40
  function aggregateKeys(publicKeys, sort, options = {}) {
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.generateNonces = generateNonces;
37
- const musig = __importStar(require("@scure/btc-signer/musig2"));
37
+ const musig = __importStar(require("@scure/btc-signer/musig2.js"));
38
38
  /**
39
39
  * Generates a pair of public and secret nonces for MuSig2 signing
40
40
  */
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.PartialSig = exports.PartialSignatureError = void 0;
37
37
  exports.sign = sign;
38
- const musig = __importStar(require("@scure/btc-signer/musig2"));
38
+ const musig = __importStar(require("@scure/btc-signer/musig2.js"));
39
39
  const utils_js_1 = require("@noble/curves/utils.js");
40
40
  const secp256k1_1 = require("@noble/secp256k1");
41
41
  const keys_1 = require("./keys");
@@ -1,18 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.networks = exports.getNetwork = void 0;
4
- const btc_signer_1 = require("@scure/btc-signer");
4
+ const utils_js_1 = require("@scure/btc-signer/utils.js");
5
5
  const getNetwork = (network) => {
6
6
  return exports.networks[network];
7
7
  };
8
8
  exports.getNetwork = getNetwork;
9
9
  exports.networks = {
10
- bitcoin: withArkPrefix(btc_signer_1.NETWORK, "ark"),
11
- testnet: withArkPrefix(btc_signer_1.TEST_NETWORK, "tark"),
12
- signet: withArkPrefix(btc_signer_1.TEST_NETWORK, "tark"),
13
- mutinynet: withArkPrefix(btc_signer_1.TEST_NETWORK, "tark"),
10
+ bitcoin: withArkPrefix(utils_js_1.NETWORK, "ark"),
11
+ testnet: withArkPrefix(utils_js_1.TEST_NETWORK, "tark"),
12
+ signet: withArkPrefix(utils_js_1.TEST_NETWORK, "tark"),
13
+ mutinynet: withArkPrefix(utils_js_1.TEST_NETWORK, "tark"),
14
14
  regtest: withArkPrefix({
15
- ...btc_signer_1.TEST_NETWORK,
15
+ ...utils_js_1.TEST_NETWORK,
16
16
  bech32: "bcrt",
17
17
  pubKeyHash: 0x6f,
18
18
  scriptHash: 0xc4,
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ArkAddress = void 0;
4
4
  const base_1 = require("@scure/base");
5
- const btc_signer_1 = require("@scure/btc-signer");
5
+ const script_js_1 = require("@scure/btc-signer/script.js");
6
6
  /**
7
7
  * ArkAddress allows to create and decode bech32m encoded ark address.
8
8
  * An ark address is composed of:
@@ -66,11 +66,11 @@ class ArkAddress {
66
66
  }
67
67
  // pkScript is the script that should be used to send non-dust funds to the address
68
68
  get pkScript() {
69
- return btc_signer_1.Script.encode(["OP_1", this.vtxoTaprootKey]);
69
+ return script_js_1.Script.encode(["OP_1", this.vtxoTaprootKey]);
70
70
  }
71
71
  // subdustPkScript is the script that should be used to send sub-dust funds to the address
72
72
  get subdustPkScript() {
73
- return btc_signer_1.Script.encode(["RETURN", this.vtxoTaprootKey]);
73
+ return script_js_1.Script.encode(["RETURN", this.vtxoTaprootKey]);
74
74
  }
75
75
  }
76
76
  exports.ArkAddress = ArkAddress;
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VtxoScript = void 0;
4
4
  exports.scriptFromTapLeafScript = scriptFromTapLeafScript;
5
- const payment_1 = require("@scure/btc-signer/payment");
6
- const utils_1 = require("@scure/btc-signer/utils");
5
+ const payment_js_1 = require("@scure/btc-signer/payment.js");
6
+ const utils_js_1 = require("@scure/btc-signer/utils.js");
7
7
  const address_1 = require("./address");
8
- const btc_signer_1 = require("@scure/btc-signer");
8
+ const script_js_1 = require("@scure/btc-signer/script.js");
9
9
  const base_1 = require("@scure/base");
10
10
  const tapscript_1 = require("./tapscript");
11
11
  function scriptFromTapLeafScript(leaf) {
@@ -26,8 +26,8 @@ class VtxoScript {
26
26
  }
27
27
  constructor(scripts) {
28
28
  this.scripts = scripts;
29
- const tapTree = (0, payment_1.taprootListToTree)(scripts.map((script) => ({ script, leafVersion: payment_1.TAP_LEAF_VERSION })));
30
- const payment = (0, payment_1.p2tr)(utils_1.TAPROOT_UNSPENDABLE_KEY, tapTree, undefined, true);
29
+ const tapTree = (0, payment_js_1.taprootListToTree)(scripts.map((script) => ({ script, leafVersion: payment_js_1.TAP_LEAF_VERSION })));
30
+ const payment = (0, payment_js_1.p2tr)(utils_js_1.TAPROOT_UNSPENDABLE_KEY, tapTree, undefined, true);
31
31
  if (!payment.tapLeafScript ||
32
32
  payment.tapLeafScript.length !== scripts.length) {
33
33
  throw new Error("invalid scripts");
@@ -43,10 +43,10 @@ class VtxoScript {
43
43
  return new address_1.ArkAddress(serverPubKey, this.tweakedPublicKey, prefix);
44
44
  }
45
45
  get pkScript() {
46
- return btc_signer_1.Script.encode(["OP_1", this.tweakedPublicKey]);
46
+ return script_js_1.Script.encode(["OP_1", this.tweakedPublicKey]);
47
47
  }
48
48
  onchainAddress(network) {
49
- return (0, payment_1.Address)(network).encode({
49
+ return (0, payment_js_1.Address)(network).encode({
50
50
  type: "tr",
51
51
  pubkey: this.tweakedPublicKey,
52
52
  });
@@ -36,10 +36,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.CLTVMultisigTapscript = exports.ConditionMultisigTapscript = exports.ConditionCSVMultisigTapscript = exports.CSVMultisigTapscript = exports.MultisigTapscript = exports.TapscriptType = void 0;
37
37
  exports.decodeTapscript = decodeTapscript;
38
38
  const bip68 = __importStar(require("bip68"));
39
- const script_1 = require("@scure/btc-signer/script");
40
- const payment_1 = require("@scure/btc-signer/payment");
39
+ const script_js_1 = require("@scure/btc-signer/script.js");
40
+ const payment_js_1 = require("@scure/btc-signer/payment.js");
41
41
  const base_1 = require("@scure/base");
42
- const MinimalScriptNum = (0, script_1.ScriptNum)(undefined, true);
42
+ const MinimalScriptNum = (0, script_js_1.ScriptNum)(undefined, true);
43
43
  var TapscriptType;
44
44
  (function (TapscriptType) {
45
45
  TapscriptType["Multisig"] = "multisig";
@@ -109,7 +109,7 @@ var MultisigTapscript;
109
109
  return {
110
110
  type: TapscriptType.Multisig,
111
111
  params,
112
- script: (0, payment_1.p2tr_ms)(params.pubkeys.length, params.pubkeys).script,
112
+ script: (0, payment_js_1.p2tr_ms)(params.pubkeys.length, params.pubkeys).script,
113
113
  };
114
114
  }
115
115
  const asm = [];
@@ -126,7 +126,7 @@ var MultisigTapscript;
126
126
  return {
127
127
  type: TapscriptType.Multisig,
128
128
  params,
129
- script: script_1.Script.encode(asm),
129
+ script: script_js_1.Script.encode(asm),
130
130
  };
131
131
  }
132
132
  MultisigTapscript.encode = encode;
@@ -151,7 +151,7 @@ var MultisigTapscript;
151
151
  MultisigTapscript.decode = decode;
152
152
  // <pubkey> CHECKSIG <pubkey> CHECKSIGADD <len_keys> NUMEQUAL
153
153
  function decodeChecksigAdd(script) {
154
- const asm = script_1.Script.decode(script);
154
+ const asm = script_js_1.Script.decode(script);
155
155
  const pubkeys = [];
156
156
  let foundNumEqual = false;
157
157
  // Parse through ASM operations
@@ -201,7 +201,7 @@ var MultisigTapscript;
201
201
  }
202
202
  // <pubkey> CHECKSIGVERIFY <pubkey> CHECKSIG
203
203
  function decodeChecksig(script) {
204
- const asm = script_1.Script.decode(script);
204
+ const asm = script_js_1.Script.decode(script);
205
205
  const pubkeys = [];
206
206
  // Parse through ASM operations
207
207
  for (let i = 0; i < asm.length; i++) {
@@ -278,7 +278,7 @@ var CSVMultisigTapscript;
278
278
  ];
279
279
  const multisigScript = MultisigTapscript.encode(params);
280
280
  const script = new Uint8Array([
281
- ...script_1.Script.encode(asm),
281
+ ...script_js_1.Script.encode(asm),
282
282
  ...multisigScript.script,
283
283
  ]);
284
284
  return {
@@ -292,7 +292,7 @@ var CSVMultisigTapscript;
292
292
  if (script.length === 0) {
293
293
  throw new Error("Failed to decode: script is empty");
294
294
  }
295
- const asm = script_1.Script.decode(script);
295
+ const asm = script_js_1.Script.decode(script);
296
296
  if (asm.length < 3) {
297
297
  throw new Error(`Invalid script: too short (expected at least 3)`);
298
298
  }
@@ -303,7 +303,7 @@ var CSVMultisigTapscript;
303
303
  if (asm[1] !== "CHECKSEQUENCEVERIFY" || asm[2] !== "DROP") {
304
304
  throw new Error("Invalid script: expected CHECKSEQUENCEVERIFY DROP");
305
305
  }
306
- const multisigScript = new Uint8Array(script_1.Script.encode(asm.slice(3)));
306
+ const multisigScript = new Uint8Array(script_js_1.Script.encode(asm.slice(3)));
307
307
  let multisig;
308
308
  try {
309
309
  multisig = MultisigTapscript.decode(multisigScript);
@@ -355,7 +355,7 @@ var ConditionCSVMultisigTapscript;
355
355
  function encode(params) {
356
356
  const script = new Uint8Array([
357
357
  ...params.conditionScript,
358
- ...script_1.Script.encode(["VERIFY"]),
358
+ ...script_js_1.Script.encode(["VERIFY"]),
359
359
  ...CSVMultisigTapscript.encode(params).script,
360
360
  ]);
361
361
  return {
@@ -369,7 +369,7 @@ var ConditionCSVMultisigTapscript;
369
369
  if (script.length === 0) {
370
370
  throw new Error("Failed to decode: script is empty");
371
371
  }
372
- const asm = script_1.Script.decode(script);
372
+ const asm = script_js_1.Script.decode(script);
373
373
  if (asm.length < 1) {
374
374
  throw new Error(`Invalid script: too short (expected at least 1)`);
375
375
  }
@@ -382,8 +382,8 @@ var ConditionCSVMultisigTapscript;
382
382
  if (verifyIndex === -1) {
383
383
  throw new Error("Invalid script: missing VERIFY operation");
384
384
  }
385
- const conditionScript = new Uint8Array(script_1.Script.encode(asm.slice(0, verifyIndex)));
386
- const csvMultisigScript = new Uint8Array(script_1.Script.encode(asm.slice(verifyIndex + 1)));
385
+ const conditionScript = new Uint8Array(script_js_1.Script.encode(asm.slice(0, verifyIndex)));
386
+ const csvMultisigScript = new Uint8Array(script_js_1.Script.encode(asm.slice(verifyIndex + 1)));
387
387
  let csvMultisig;
388
388
  try {
389
389
  csvMultisig = CSVMultisigTapscript.decode(csvMultisigScript);
@@ -430,7 +430,7 @@ var ConditionMultisigTapscript;
430
430
  function encode(params) {
431
431
  const script = new Uint8Array([
432
432
  ...params.conditionScript,
433
- ...script_1.Script.encode(["VERIFY"]),
433
+ ...script_js_1.Script.encode(["VERIFY"]),
434
434
  ...MultisigTapscript.encode(params).script,
435
435
  ]);
436
436
  return {
@@ -444,7 +444,7 @@ var ConditionMultisigTapscript;
444
444
  if (script.length === 0) {
445
445
  throw new Error("Failed to decode: script is empty");
446
446
  }
447
- const asm = script_1.Script.decode(script);
447
+ const asm = script_js_1.Script.decode(script);
448
448
  if (asm.length < 1) {
449
449
  throw new Error(`Invalid script: too short (expected at least 1)`);
450
450
  }
@@ -457,8 +457,8 @@ var ConditionMultisigTapscript;
457
457
  if (verifyIndex === -1) {
458
458
  throw new Error("Invalid script: missing VERIFY operation");
459
459
  }
460
- const conditionScript = new Uint8Array(script_1.Script.encode(asm.slice(0, verifyIndex)));
461
- const multisigScript = new Uint8Array(script_1.Script.encode(asm.slice(verifyIndex + 1)));
460
+ const conditionScript = new Uint8Array(script_js_1.Script.encode(asm.slice(0, verifyIndex)));
461
+ const multisigScript = new Uint8Array(script_js_1.Script.encode(asm.slice(verifyIndex + 1)));
462
462
  let multisig;
463
463
  try {
464
464
  multisig = MultisigTapscript.decode(multisigScript);
@@ -509,7 +509,7 @@ var CLTVMultisigTapscript;
509
509
  "CHECKLOCKTIMEVERIFY",
510
510
  "DROP",
511
511
  ];
512
- const timelockedScript = script_1.Script.encode(asm);
512
+ const timelockedScript = script_js_1.Script.encode(asm);
513
513
  const script = new Uint8Array([
514
514
  ...timelockedScript,
515
515
  ...MultisigTapscript.encode(params).script,
@@ -525,7 +525,7 @@ var CLTVMultisigTapscript;
525
525
  if (script.length === 0) {
526
526
  throw new Error("Failed to decode: script is empty");
527
527
  }
528
- const asm = script_1.Script.decode(script);
528
+ const asm = script_js_1.Script.decode(script);
529
529
  if (asm.length < 3) {
530
530
  throw new Error(`Invalid script: too short (expected at least 3)`);
531
531
  }
@@ -536,7 +536,7 @@ var CLTVMultisigTapscript;
536
536
  if (asm[1] !== "CHECKLOCKTIMEVERIFY" || asm[2] !== "DROP") {
537
537
  throw new Error("Invalid script: expected CHECKLOCKTIMEVERIFY DROP");
538
538
  }
539
- const multisigScript = new Uint8Array(script_1.Script.encode(asm.slice(3)));
539
+ const multisigScript = new Uint8Array(script_js_1.Script.encode(asm.slice(3)));
540
540
  let multisig;
541
541
  try {
542
542
  multisig = MultisigTapscript.decode(multisigScript);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VHTLC = void 0;
4
- const btc_signer_1 = require("@scure/btc-signer");
4
+ const script_js_1 = require("@scure/btc-signer/script.js");
5
5
  const tapscript_1 = require("./tapscript");
6
6
  const base_1 = require("@scure/base");
7
7
  const base_2 = require("./base");
@@ -158,5 +158,5 @@ var VHTLC;
158
158
  }
159
159
  })(VHTLC || (exports.VHTLC = VHTLC = {}));
160
160
  function preimageConditionScript(preimageHash) {
161
- return btc_signer_1.Script.encode(["HASH160", preimageHash, "EQUAL"]);
161
+ return script_js_1.Script.encode(["HASH160", preimageHash, "EQUAL"]);
162
162
  }
@@ -36,10 +36,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.TreeSignerSession = exports.ErrMissingAggregateKey = exports.ErrMissingVtxoGraph = void 0;
37
37
  exports.validateTreeSigs = validateTreeSigs;
38
38
  const musig2 = __importStar(require("../musig2"));
39
- const btc_signer_1 = require("@scure/btc-signer");
39
+ const script_js_1 = require("@scure/btc-signer/script.js");
40
+ const transaction_js_1 = require("@scure/btc-signer/transaction.js");
40
41
  const base_1 = require("@scure/base");
41
42
  const secp256k1_js_1 = require("@noble/curves/secp256k1.js");
42
- const utils_1 = require("@scure/btc-signer/utils");
43
+ const utils_js_1 = require("@scure/btc-signer/utils.js");
43
44
  const unknownFields_1 = require("../utils/unknownFields");
44
45
  exports.ErrMissingVtxoGraph = new Error("missing vtxo graph");
45
46
  exports.ErrMissingAggregateKey = new Error("missing aggregate key");
@@ -53,7 +54,7 @@ class TreeSignerSession {
53
54
  this.rootSharedOutputAmount = null;
54
55
  }
55
56
  static random() {
56
- const secretKey = (0, utils_1.randomPrivateKeyBytes)();
57
+ const secretKey = (0, utils_js_1.randomPrivateKeyBytes)();
57
58
  return new TreeSignerSession(secretKey);
58
59
  }
59
60
  init(tree, scriptRoot, rootInputAmount) {
@@ -131,7 +132,7 @@ class TreeSignerSession {
131
132
  prevoutScripts.push(prevout.script);
132
133
  }
133
134
  const message = g.root.preimageWitnessV1(0, // always first input
134
- prevoutScripts, btc_signer_1.SigHash.DEFAULT, prevoutAmounts);
135
+ prevoutScripts, transaction_js_1.SigHash.DEFAULT, prevoutAmounts);
135
136
  return musig2.sign(myNonce.secNonce, this.secretKey, aggNonce.pubNonce, cosigners, message, {
136
137
  taprootTweak: this.scriptRoot,
137
138
  sortKeys: true,
@@ -154,7 +155,7 @@ async function validateTreeSigs(finalAggregatedKey, sharedOutputAmount, vtxoTree
154
155
  const prevout = getPrevOutput(finalAggregatedKey, vtxoTree, sharedOutputAmount, g.root);
155
156
  // Calculate the message that was signed
156
157
  const message = g.root.preimageWitnessV1(0, // always first input
157
- [prevout.script], btc_signer_1.SigHash.DEFAULT, [prevout.amount]);
158
+ [prevout.script], transaction_js_1.SigHash.DEFAULT, [prevout.amount]);
158
159
  // Verify the signature
159
160
  const isValid = secp256k1_js_1.schnorr.verify(input.tapKeySig, message, finalAggregatedKey);
160
161
  if (!isValid) {
@@ -164,8 +165,8 @@ async function validateTreeSigs(finalAggregatedKey, sharedOutputAmount, vtxoTree
164
165
  }
165
166
  function getPrevOutput(finalKey, graph, sharedOutputAmount, tx) {
166
167
  // generate P2TR script from musig2 final key
167
- const pkScript = btc_signer_1.Script.encode(["OP_1", finalKey.slice(1)]);
168
- const txid = base_1.hex.encode((0, utils_1.sha256x2)(tx.toBytes(true)).reverse());
168
+ const pkScript = script_js_1.Script.encode(["OP_1", finalKey.slice(1)]);
169
+ const txid = base_1.hex.encode((0, utils_js_1.sha256x2)(tx.toBytes(true)).reverse());
169
170
  // if the input is the root input, return the shared output amount
170
171
  if (txid === graph.txid) {
171
172
  return {
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TxTree = void 0;
4
- const btc_signer_1 = require("@scure/btc-signer");
4
+ const transaction_js_1 = require("@scure/btc-signer/transaction.js");
5
5
  const base_1 = require("@scure/base");
6
6
  const base_2 = require("@scure/base");
7
- const utils_1 = require("@scure/btc-signer/utils");
7
+ const utils_js_1 = require("@scure/btc-signer/utils.js");
8
8
  /**
9
9
  * TxTree is a graph of bitcoin transactions.
10
10
  * It is used to represent batch tree created during settlement session
@@ -22,7 +22,7 @@ class TxTree {
22
22
  const chunksByTxid = new Map();
23
23
  for (const chunk of chunks) {
24
24
  const decodedChunk = decodeNode(chunk);
25
- const txid = base_2.hex.encode((0, utils_1.sha256x2)(decodedChunk.tx.toBytes(true)).reverse());
25
+ const txid = base_2.hex.encode((0, utils_js_1.sha256x2)(decodedChunk.tx.toBytes(true)).reverse());
26
26
  chunksByTxid.set(txid, decodedChunk);
27
27
  }
28
28
  // Find the root chunks (the ones that aren't referenced as a child)
@@ -91,7 +91,7 @@ class TxTree {
91
91
  }
92
92
  child.validate();
93
93
  const childInput = child.root.getInput(0);
94
- const parentTxid = base_2.hex.encode((0, utils_1.sha256x2)(this.root.toBytes(true)).reverse());
94
+ const parentTxid = base_2.hex.encode((0, utils_js_1.sha256x2)(this.root.toBytes(true)).reverse());
95
95
  // verify the input of the child is the output of the parent
96
96
  if (!childInput.txid ||
97
97
  base_2.hex.encode(childInput.txid) !== parentTxid ||
@@ -126,7 +126,7 @@ class TxTree {
126
126
  return leaves;
127
127
  }
128
128
  get txid() {
129
- return base_2.hex.encode((0, utils_1.sha256x2)(this.root.toBytes(true)).reverse());
129
+ return base_2.hex.encode((0, utils_js_1.sha256x2)(this.root.toBytes(true)).reverse());
130
130
  }
131
131
  find(txid) {
132
132
  if (txid === this.txid) {
@@ -188,6 +188,6 @@ function buildGraph(rootTxid, chunksByTxid) {
188
188
  return new TxTree(rootTx, children);
189
189
  }
190
190
  function decodeNode(chunk) {
191
- const tx = btc_signer_1.Transaction.fromPSBT(base_1.base64.decode(chunk.tx));
191
+ const tx = transaction_js_1.Transaction.fromPSBT(base_1.base64.decode(chunk.tx));
192
192
  return { tx, children: chunk.children };
193
193
  }
@@ -4,9 +4,9 @@ exports.ErrMissingCosignersPublicKeys = exports.ErrWrongCommitmentTxid = exports
4
4
  exports.validateConnectorsTxGraph = validateConnectorsTxGraph;
5
5
  exports.validateVtxoTxGraph = validateVtxoTxGraph;
6
6
  const base_1 = require("@scure/base");
7
- const btc_signer_1 = require("@scure/btc-signer");
7
+ const transaction_js_1 = require("@scure/btc-signer/transaction.js");
8
8
  const base_2 = require("@scure/base");
9
- const utils_1 = require("@scure/btc-signer/utils");
9
+ const utils_js_1 = require("@scure/btc-signer/utils.js");
10
10
  const musig2_1 = require("../musig2");
11
11
  const unknownFields_1 = require("../utils/unknownFields");
12
12
  const ErrInvalidSettlementTx = (tx) => new Error(`invalid settlement transaction: ${tx}`);
@@ -28,10 +28,10 @@ function validateConnectorsTxGraph(settlementTxB64, connectorsGraph) {
28
28
  if (connectorsGraph.root.inputsLength !== 1)
29
29
  throw exports.ErrNumberOfInputs;
30
30
  const rootInput = connectorsGraph.root.getInput(0);
31
- const settlementTx = btc_signer_1.Transaction.fromPSBT(base_2.base64.decode(settlementTxB64));
31
+ const settlementTx = transaction_js_1.Transaction.fromPSBT(base_2.base64.decode(settlementTxB64));
32
32
  if (settlementTx.outputsLength <= BATCH_OUTPUT_CONNECTORS_INDEX)
33
33
  throw exports.ErrInvalidSettlementTxOutputs;
34
- const expectedRootTxid = base_1.hex.encode((0, utils_1.sha256x2)(settlementTx.toBytes(true)).reverse());
34
+ const expectedRootTxid = base_1.hex.encode((0, utils_js_1.sha256x2)(settlementTx.toBytes(true)).reverse());
35
35
  if (!rootInput.txid)
36
36
  throw exports.ErrWrongSettlementTxid;
37
37
  if (base_1.hex.encode(rootInput.txid) !== expectedRootTxid)
@@ -58,7 +58,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
58
58
  throw exports.ErrEmptyTree;
59
59
  }
60
60
  const rootInput = graph.root.getInput(0);
61
- const commitmentTxid = base_1.hex.encode((0, utils_1.sha256x2)(roundTransaction.toBytes(true)).reverse());
61
+ const commitmentTxid = base_1.hex.encode((0, utils_js_1.sha256x2)(roundTransaction.toBytes(true)).reverse());
62
62
  if (!rootInput.txid ||
63
63
  base_1.hex.encode(rootInput.txid) !== commitmentTxid ||
64
64
  rootInput.index !== BATCH_OUTPUT_VTXO_INDEX) {
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildOffchainTx = buildOffchainTx;
4
- const btc_signer_1 = require("@scure/btc-signer");
4
+ const transaction_js_1 = require("@scure/btc-signer/transaction.js");
5
5
  const tapscript_1 = require("../script/tapscript");
6
6
  const base_1 = require("../script/base");
7
7
  const anchor_1 = require("./anchor");
8
8
  const base_2 = require("@scure/base");
9
- const utils_1 = require("@scure/btc-signer/utils");
9
+ const utils_js_1 = require("@scure/btc-signer/utils.js");
10
10
  const unknownFields_1 = require("./unknownFields");
11
11
  /**
12
12
  * Builds an offchain transaction with checkpoint transactions.
@@ -45,7 +45,7 @@ function buildVirtualTx(inputs, outputs) {
45
45
  }
46
46
  }
47
47
  }
48
- const tx = new btc_signer_1.Transaction({
48
+ const tx = new transaction_js_1.Transaction({
49
49
  version: 3,
50
50
  allowUnknown: true,
51
51
  allowUnknownOutputs: true,
@@ -55,7 +55,7 @@ function buildVirtualTx(inputs, outputs) {
55
55
  tx.addInput({
56
56
  txid: input.txid,
57
57
  index: input.vout,
58
- sequence: lockTime ? btc_signer_1.DEFAULT_SEQUENCE - 1 : undefined,
58
+ sequence: lockTime ? transaction_js_1.DEFAULT_SEQUENCE - 1 : undefined,
59
59
  witnessUtxo: {
60
60
  script: base_1.VtxoScript.decode(input.tapTree).pkScript,
61
61
  amount: BigInt(input.value),
@@ -91,7 +91,7 @@ function buildCheckpointTx(vtxo, serverUnrollScript) {
91
91
  const collaborativeLeafProof = checkpointVtxoScript.findLeaf(base_2.hex.encode(collaborativeClosure.script));
92
92
  // create the checkpoint input that will be used as input of the virtual tx
93
93
  const checkpointInput = {
94
- txid: base_2.hex.encode((0, utils_1.sha256x2)(checkpointTx.toBytes(true)).reverse()),
94
+ txid: base_2.hex.encode((0, utils_js_1.sha256x2)(checkpointTx.toBytes(true)).reverse()),
95
95
  vout: 0,
96
96
  value: vtxo.value,
97
97
  tapLeafScript: collaborativeLeafProof,