Skip to content

Commit 7fe2d95

Browse files
committed
ref: move Tx.createPkhScript(pubKeyHash) to public export
1 parent e873d51 commit 7fe2d95

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

1130+
/**
1131+
* @param {Hex} pubKeyHash
1132+
* @returns {Hex}
1133+
*/
1134+
Tx.createPkhScript = function (pubKeyHash) {
1135+
let lockScript = `${OP_DUP}${OP_HASH160}${PKH_SIZE}${pubKeyHash}${OP_EQUALVERIFY}${OP_CHECKSIG}`;
1136+
return lockScript;
1137+
};
1138+
11291139
Tx.serialize = function (
11301140
{
11311141
version = CURRENT_VERSION,
@@ -2187,6 +2197,12 @@ if ("object" === typeof module) {
21872197
* @param {Uint32} inputIndex - create hashable tx for this input
21882198
*/
21892199

2200+
/**
2201+
* @callback TxCreatePkhScript
2202+
* @param {Hex} pubKeyHash
2203+
* @returns {Hex} - ${OP_DUP}${OP_HASH160}${PKH_SIZE}${pubKeyHash}${OP_EQUALVERIFY}${OP_CHECKSIG}
2204+
*/
2205+
21902206
/**
21912207
* @callback TxCreateRaw
21922208
* @param {Object} opts

0 commit comments

Comments
 (0)