From 9e4d3a19291f196eb381410c30ebf285922a9ffe Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 19 Apr 2024 02:14:36 -0600 Subject: [PATCH 1/3] chore: minor fix for type hint / check --- dashtx.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/dashtx.js b/dashtx.js index 2594705..eca3f19 100644 --- a/dashtx.js +++ b/dashtx.js @@ -55,7 +55,7 @@ /** * @callback TxCreate - * @param {TxDeps} myUtils + * @param {TxDeps} keyUtils * @returns {tx} */ @@ -230,10 +230,10 @@ var DashTx = ("object" === typeof module && exports) || {}; return sats; }; - Tx.create = function (myUtils) { + Tx.create = function (_keyUtils) { let txInst = {}; - txInst._utils = Object.assign({}, Tx.utils, myUtils); + txInst._utils = Object.assign({}, Tx.utils, _keyUtils); /** @type {TxHashAndSignAll} */ txInst.hashAndSignAll = async function (txInfo, keys) { @@ -746,11 +746,11 @@ var DashTx = ("object" === typeof module && exports) || {}; }; /** - * @param {TxDeps} myUtils + * @param {TxDeps} keyUtils * @param {Array} keys */ - Tx._createKeyUtils = function (myUtils, keys) { - let _getPublicKey = myUtils.getPublicKey || getPublicKey; + Tx._createKeyUtils = function (keyUtils, keys) { + let _getPublicKey = keyUtils.getPublicKey || getPublicKey; let _utils = { /** @type {TxGetPrivateKey} */ getPrivateKey: async function (_, i) { @@ -759,16 +759,16 @@ var DashTx = ("object" === typeof module && exports) || {}; }, /** @type {TxGetPublicKey} */ getPublicKey: _getPublicKey, - sign: myUtils.sign, + sign: keyUtils.sign, }; /** @type {TxGetPublicKey} */ async function getPublicKey(txInput, i, txInputs) { let privKey = keys[i]; - if (!myUtils.toPublicKey) { + if (!keyUtils.toPublicKey) { throw new Error("type assert: missing 'toPublicKey'"); } - let pubKey = myUtils.toPublicKey(privKey); + let pubKey = keyUtils.toPublicKey(privKey); if ("string" === typeof pubKey) { console.warn( "oops, you gave a publicKey as hex (deprecated) rather than a buffer", @@ -778,7 +778,7 @@ var DashTx = ("object" === typeof module && exports) || {}; return pubKey; } - return Object.assign(_utils, myUtils); + return Object.assign(_utils, keyUtils); }; /** @@ -903,7 +903,7 @@ var DashTx = ("object" === typeof module && exports) || {}; * TODO _param {Array} txInfo.outputs * TODO _param {Uint32} [txInfo.version] * TODO _param {Boolean} [txInfo._debug] - bespoke debug output - * @param {TxDeps} myUtils + * @param {TxDeps} keyUtils * @returns {Promise} */ Tx._hashAndSignAll = async function (txInfo, keyUtils) { @@ -937,6 +937,8 @@ var DashTx = ("object" === typeof module && exports) || {}; inputs: [], outputs: txInfo.outputs, version: txInfo.version || CURRENT_VERSION, + locktime: txInfo.locktime || 0x00, + transaction: "", }; // temp shim From 7166d9928a5a75479d802fb567979e0fdd02cabf Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 19 Apr 2024 03:21:03 -0600 Subject: [PATCH 2/3] chore: update deps --- README.md | 1 + package-lock.json | 27 +++++++++++++++------------ package.json | 4 ++-- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index d71f77d..6da465c 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ Server and browser compatible. Vanilla JS. 0 Dependencies. ```sh npm install --save @dashincubator/secp256k1 +npm install --save dashkeys npm install --save dashtx ``` diff --git a/package-lock.json b/package-lock.json index 5dc6338..6f0db75 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,29 +13,31 @@ }, "devDependencies": { "@dashincubator/secp256k1": "^1.7.1-5", - "@types/node": "^20.11.30", - "dashkeys": "^1.0.1", + "@types/node": "^20.12.7", + "dashkeys": "^1.1.0", "zora": "^5.2.0" } }, "node_modules/@dashincubator/secp256k1": { "version": "1.7.1-5", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/@dashincubator/secp256k1/-/secp256k1-1.7.1-5.tgz", + "integrity": "sha512-3iA+RDZrJsRFPpWhlYkp3EdoFAlKjdqkNFiRwajMrzcpA/G/IBX0AnC1pwRLkTrM+tUowcyGrkJfT03U4ETZeg==", + "dev": true }, "node_modules/@types/node": { - "version": "20.11.30", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.30.tgz", - "integrity": "sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==", + "version": "20.12.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.7.tgz", + "integrity": "sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==", "dev": true, "dependencies": { "undici-types": "~5.26.4" } }, "node_modules/dashkeys": { - "version": "1.0.1", - "dev": true, - "license": "SEE LICENSE IN LICENSE" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/dashkeys/-/dashkeys-1.1.0.tgz", + "integrity": "sha512-Xk4G2DCqmEG/VoESseaoFGMUPS/PndnwHOfjH/TsQWtv9ewroAfQf5QPoKPzKmpSsN1AC3+qYmBXxo8SwwfEMw==", + "dev": true }, "node_modules/undici-types": { "version": "5.26.5", @@ -45,8 +47,9 @@ }, "node_modules/zora": { "version": "5.2.0", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/zora/-/zora-5.2.0.tgz", + "integrity": "sha512-FSZOvfJVfMWhk/poictNsDBCXq/Z+2Zu2peWs6d8OhWWb9nY++czw95D47hdw06L/kfjasLevwrbUtnXyWLAJw==", + "dev": true } } } diff --git a/package.json b/package.json index 845e543..6c2de67 100644 --- a/package.json +++ b/package.json @@ -47,8 +47,8 @@ "homepage": "https://github.com/dashhive/dashtx.js#readme", "devDependencies": { "@dashincubator/secp256k1": "^1.7.1-5", - "@types/node": "^20.11.30", - "dashkeys": "^1.0.1", + "@types/node": "^20.12.7", + "dashkeys": "^1.1.0", "zora": "^5.2.0" } } From 8b1048acf9801a01e680bed56d030e4ea120e2ee Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 19 Apr 2024 04:42:05 -0600 Subject: [PATCH 3/3] doc: fix secp256k1 typos --- README.md | 2 +- dashtx.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6da465c..b628b49 100644 --- a/README.md +++ b/README.md @@ -479,7 +479,7 @@ Tx.create({ sign, getPrivateKey }); * These may or may not be the default options, depending * on the library used. * - * We recommend @dashincubator/secp246k1 and @noble/secp246k1. + * We recommend @dashincubator/secp256k1 and @noble/secp256k1. * * @param {Uint8Array} privateKey - an input's corresponding key * @param {Uint8Array} txHashBytes - the (not reversed) 2x-sha256-hash diff --git a/dashtx.js b/dashtx.js index eca3f19..1a3e638 100644 --- a/dashtx.js +++ b/dashtx.js @@ -392,7 +392,7 @@ var DashTx = ("object" === typeof module && exports) || {}; } if (!hasEntropy) { let err = new Error( - "secp265k1 implementation does not use signature entropy", + "secp256k1 implementation does not use signature entropy", ); Object.assign(err, { code: "E_NO_ENTROPY" }); throw err;