From 87aa4e581c62eb8983bf9f14d0881c74cbde39a4 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 22 Aug 2024 23:17:44 -0600 Subject: [PATCH] ref: move Tx.createPkhScript(pubKeyHash) to public export --- dashtx.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/dashtx.js b/dashtx.js index aed8c42..f34c0ec 100644 --- a/dashtx.js +++ b/dashtx.js @@ -24,6 +24,7 @@ * @prop {TxCreateInputRaw} createInputRaw * @prop {TxCreateForSig} createForSig * @prop {TxCreateInputForSig} createInputForSig + * @prop {TxCreatePkhScript} createPkhScript * @prop {TxCreateSigned} createSigned * @prop {TxGetId} getId - only useful for fully signed tx * @prop {TxCreateLegacyTx} createLegacyTx @@ -1115,7 +1116,7 @@ var DashTx = ("object" === typeof module && exports) || {}; `signable input must have either 'pubKeyHash' or 'script'`, ); } - lockScript = `${OP_DUP}${OP_HASH160}${PKH_SIZE}${input.pubKeyHash}${OP_EQUALVERIFY}${OP_CHECKSIG}`; + lockScript = Tx.createPkhScript(input.pubKeyHash); } return { txId: input.txId || input.txid, @@ -1127,6 +1128,15 @@ var DashTx = ("object" === typeof module && exports) || {}; }; }; + /** + * @param {Hex} pubKeyHash + * @returns {Hex} + */ + Tx.createPkhScript = function (pubKeyHash) { + let lockScript = `${OP_DUP}${OP_HASH160}${PKH_SIZE}${pubKeyHash}${OP_EQUALVERIFY}${OP_CHECKSIG}`; + return lockScript; + }; + Tx.serialize = function ( { version = CURRENT_VERSION, @@ -2195,6 +2205,12 @@ if ("object" === typeof module) { * @param {Uint32} inputIndex - create hashable tx for this input */ +/** + * @callback TxCreatePkhScript + * @param {Hex} pubKeyHash + * @returns {Hex} - ${OP_DUP}${OP_HASH160}${PKH_SIZE}${pubKeyHash}${OP_EQUALVERIFY}${OP_CHECKSIG} + */ + /** * @callback TxCreateRaw * @param {Object} opts