src/controllers/erc20.js
/**
   * Function responsible for convert address compartible with address system simple
   */
Function responsible for convert address compartible with address system simple
Function responsible for convert address compartible with address system simple
checksumAddress(req, res) {
    if (isNullOrUndefined.isNullOrUndefined(req.body.wallet)) {
      let error = {
        isError: true,
        msg: "Error read Wallet Json"
      };
      res.status(400).json(error);
    }
    if (isNullOrUndefined.isNullOrUndefined(req.body.password)) {
      let error = {
        isError: true,
        msg: "Error read parameter <password>"
      };
      res.status(400).json(error);
    }
    let walletJson = JSON.stringify(req.body.wallet);
    let ks = Lightwallet.keystore.deserialize(walletJson);
    let password = req.body.password.toString();
    ks.keyFromPassword(password, function(err, pwDerivedKey) {
      if (ks.isDerivedKeyCorrect(pwDerivedKey)) {
        let checksumAddress = web3.toChecksumAddress(
          ks.getAddresses()[0].toString()
        );
        let data = {
          isError: false,
          address: checksumAddress
        };
        res.status(200).json(data);
      } else {
        let error = {
          isError: true,
          msg: "Senha Invalida"
        };
      }
    });
  }
checksumAddress ( req , res ) { if ( isNullOrUndefined . isNullOrUndefined ( req . body . wallet ) ) { let error = { isError : true , msg : "Error read Wallet Json" } ; res . status ( 400 ) . json ( error ) ; } if ( isNullOrUndefined . isNullOrUndefined ( req . body . password ) ) { let error = { isError : true , msg : "Error read parameter <password>" } ; res . status ( 400 ) . json ( error ) ; } let walletJson = JSON . stringify ( req . body . wallet ) ; let ks = Lightwallet . keystore . deserialize ( walletJson ) ; let password = req . body . password . toString ( ) ; ks . keyFromPassword ( password , function ( err , pwDerivedKey ) { if ( ks . isDerivedKeyCorrect ( pwDerivedKey ) ) { let checksumAddress = web3 . toChecksumAddress ( ks . getAddresses ( ) [ 0 ] . toString ( ) ) ; let data = { isError : false , address : checksumAddress } ; res . status ( 200 ) . json ( data ) ; } else { let error = { isError : true , msg : "Senha Invalida" } ; } } ) ; }
Function responsible for convert address compartible with address system simple
Function responsible for convert address compartible with address system simple