Skip to content

Commit a252431

Browse files
committed
ref: move Tx.createPkhScript(pubKeyHash) to public export
1 parent 8ec0b47 commit a252431

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

dashtx.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* @prop {TxCreateInputRaw} createInputRaw
2525
* @prop {TxCreateForSig} createForSig
2626
* @prop {TxCreateInputForSig} createInputForSig
27+
* @prop {TxCreatePkhScript} createPkhScript
2728
* @prop {TxCreateSigned} createSigned
2829
* @prop {TxGetId} getId - only useful for fully signed tx
2930
* @prop {TxCreateLegacyTx} createLegacyTx
@@ -1122,7 +1123,7 @@ var DashTx = ("object" === typeof module && exports) || {};
11221123
`signable input must have either 'pubKeyHash' or 'script'`,
11231124
);
11241125
}
1125-
lockScript = `${OP_DUP}${OP_HASH160}${PKH_SIZE}${input.pubKeyHash}${OP_EQUALVERIFY}${OP_CHECKSIG}`;
1126+
lockScript = Tx.createPkhScript(input.pubKeyHash);
11261127
}
11271128
return {
11281129
txId: input.txId || input.txid,
@@ -1134,6 +1135,15 @@ var DashTx = ("object" === typeof module && exports) || {};
11341135
};
11351136
};
11361137

1138+
/**
1139+
* @param {Hex} pubKeyHash
1140+
* @returns {Hex}
1141+
*/
1142+
Tx.createPkhScript = function (pubKeyHash) {
1143+
let lockScript = `${OP_DUP}${OP_HASH160}${PKH_SIZE}${pubKeyHash}${OP_EQUALVERIFY}${OP_CHECKSIG}`;
1144+
return lockScript;
1145+
};
1146+
11371147
Tx.serialize = function (
11381148
{
11391149
version = CURRENT_VERSION,
@@ -2195,6 +2205,12 @@ if ("object" === typeof module) {
21952205
* @param {Uint32} inputIndex - create hashable tx for this input
21962206
*/
21972207

2208+
/**
2209+
* @callback TxCreatePkhScript
2210+
* @param {Hex} pubKeyHash
2211+
* @returns {Hex} - ${OP_DUP}${OP_HASH160}${PKH_SIZE}${pubKeyHash}${OP_EQUALVERIFY}${OP_CHECKSIG}
2212+
*/
2213+
21982214
/**
21992215
* @callback TxCreateRaw
22002216
* @param {Object} opts

0 commit comments

Comments
 (0)