1+ const { ADDRESS_PREFIX , ADDRESS_PREFIX_BYTE } = require ( "./address" ) ;
12const base64EncodeToString = require ( "../lib/code" ) . base64EncodeToString ;
23const { base64DecodeFromString, hexStr2byteArray} = require ( "../lib/code" ) ;
34const { encode58, decode58} = require ( "../lib/base58" ) ;
@@ -6,10 +7,6 @@ const { keccak256 } = require('js-sha3');
67const jsSHA = require ( "../lib/sha256" ) ;
78const { byte2hexStr, byteArray2hexStr } = require ( "./bytes" ) ;
89
9- const add_pre_fix = 'a0' ; //a0 + address ,a0 is version
10- const add_pre_fix_byte = 0xa0 ; //a0 + address ,a0 is version
11-
12-
1310/**
1411 * Sign A Transaction by priKey.
1512 * signature is 65 bytes, r[32] || s[32] || id[1](<27)
@@ -84,7 +81,7 @@ function computeAddress(pubBytes) {
8481
8582 var hash = keccak256 ( pubBytes ) . toString ( ) ;
8683 var addressHex = hash . substring ( 24 ) ;
87- addressHex = add_pre_fix + addressHex ;
84+ addressHex = ADDRESS_PREFIX + addressHex ;
8885 var addressBytes = hexStr2byteArray ( addressHex ) ;
8986 return addressBytes ;
9087}
@@ -140,7 +137,7 @@ function isAddressValid(base58Sting) {
140137 if ( address . length != 25 ) {
141138 return false ;
142139 }
143- if ( address [ 0 ] != add_pre_fix_byte ) {
140+ if ( address [ 0 ] != ADDRESS_PREFIX_BYTE ) {
144141 return false ;
145142 }
146143 var checkSum = address . slice ( 21 ) ;
0 commit comments