Skip to content

Commit

Permalink
ref: move Tx.createPkhScript(pubKeyHash) to public export
Browse files Browse the repository at this point in the history
  • Loading branch information
coolaj86 committed Aug 23, 2024
1 parent 07882bc commit 8a0e532
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion dashtx.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -2194,6 +2204,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
Expand Down

0 comments on commit 8a0e532

Please sign in to comment.