Skip to content

Commit bc4aa28

Browse files
authored
Merge pull request #970 from CoolBitX-Technology/feature/export-script-type-from-zen
feat(zen): export script type from zen
2 parents d23c26f + 1b4fe9d commit bc4aa28

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

packages/coin-zen/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/coin-zen/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coolwallet/zen",
3-
"version": "2.0.0-beta.0",
3+
"version": "2.0.0-beta.1",
44
"description": "Coolwallet Horizen sdk",
55
"main": "lib/index.js",
66
"scripts": {

packages/coin-zen/src/index.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { signTransaction } from './sign';
33
import * as types from './config/types';
44
import * as params from './config/params';
55
import * as txUtil from './utils/transactionUtil';
6-
export default class BTC extends COIN.ECDSACoin implements COIN.Coin {
6+
7+
export const ScriptType = types.ScriptType;
8+
9+
export default class ZEN extends COIN.ECDSACoin implements COIN.Coin {
710
public addressToOutScript: (address: string) => { scriptType: types.ScriptType; outScript: Buffer; outHash?: Buffer };
811

912
constructor() {
@@ -40,7 +43,16 @@ export default class BTC extends COIN.ECDSACoin implements COIN.Coin {
4043
addressIndex: number,
4144
scriptType: types.ScriptType
4245
): Promise<{ address: string; outScript: Buffer }> {
43-
const publicKey = await this.getAddressPublicKey(accPublicKey, accChainCode, addressIndex);
46+
return this.getAddressAndOutScriptByAccountKeySync(accPublicKey, accChainCode, addressIndex, scriptType);
47+
}
48+
49+
getAddressAndOutScriptByAccountKeySync(
50+
accPublicKey: string,
51+
accChainCode: string,
52+
addressIndex: number,
53+
scriptType: types.ScriptType
54+
): { address: string; outScript: Buffer } {
55+
const publicKey = this.getAddressPublicKey(accPublicKey, accChainCode, addressIndex);
4456
return txUtil.pubkeyToAddressAndOutScript(Buffer.from(publicKey, 'hex'), scriptType);
4557
}
4658

0 commit comments

Comments
 (0)