Skip to content

Commit 87aa4e5

Browse files
committed
ref: move Tx.createPkhScript(pubKeyHash) to public export
1 parent dc88afa commit 87aa4e5

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
@@ -1115,7 +1116,7 @@ var DashTx = ("object" === typeof module && exports) || {};
11151116
`signable input must have either 'pubKeyHash' or 'script'`,
11161117
);
11171118
}
1118-
lockScript = `${OP_DUP}${OP_HASH160}${PKH_SIZE}${input.pubKeyHash}${OP_EQUALVERIFY}${OP_CHECKSIG}`;
1119+
lockScript = Tx.createPkhScript(input.pubKeyHash);
11191120
}
11201121
return {
11211122
txId: input.txId || input.txid,
@@ -1127,6 +1128,15 @@ var DashTx = ("object" === typeof module && exports) || {};
11271128
};
11281129
};
11291130

1131+
/**
1132+
* @param {Hex} pubKeyHash
1133+
* @returns {Hex}
1134+
*/
1135+
Tx.createPkhScript = function (pubKeyHash) {
1136+
let lockScript = `${OP_DUP}${OP_HASH160}${PKH_SIZE}${pubKeyHash}${OP_EQUALVERIFY}${OP_CHECKSIG}`;
1137+
return lockScript;
1138+
};
1139+
11301140
Tx.serialize = function (
11311141
{
11321142
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)