Skip to content

Commit 7e870a4

Browse files
committed
ref: consolidate txInst._utils
1 parent 957b22b commit 7e870a4

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

dashtx.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -203,34 +203,31 @@ var DashTx = ("object" === typeof module && exports) || {};
203203
};
204204

205205
Tx.create = function (myUtils) {
206-
myUtils = Object.assign({}, Tx.utils, myUtils);
206+
let txInst = {};
207+
208+
txInst._utils = Object.assign({}, Tx.utils, myUtils);
207209

208210
/** @type {TxHashAndSignAll} */
209-
async function hashAndSignAll(txInfo, keys) {
210-
let _myUtils = myUtils;
211+
txInst.hashAndSignAll = async function (txInfo, keys) {
211212
if (keys) {
212213
//@ts-ignore
213214
if (keys.getPrivateKey) {
214215
//@ts-ignore
215-
_myUtils.getPrivateKey = keys.getPrivateKey;
216+
txInst._utils.getPrivateKey = keys.getPrivateKey;
216217
}
217218
//@ts-ignore
218219
else if (keys.length !== txInfo.inputs.length) {
219220
throw new Error(
220221
`the number and order of 'keys' must match number of 'inputs' - each 'utxo' of the provided private key must be matched to that private key`,
221222
);
222223
} else {
223-
_myUtils = Tx._createKeyUtils(myUtils, keys);
224+
txInst._utils = Tx._createKeyUtils(txInst._utils, keys);
224225
}
225226
}
226227

227-
return await Tx._hashAndSignAll(txInfo, _myUtils);
228-
}
229-
230-
let txInst = {
231-
_utils: myUtils,
232-
hashAndSignAll: hashAndSignAll,
228+
return await Tx._hashAndSignAll(txInfo, txInst._utils);
233229
};
230+
234231
return txInst;
235232
};
236233

0 commit comments

Comments
 (0)