def pw_decode(s, password): if password is not None: secret = Hash(password) try: d = DecodeAES(secret, s).decode("utf8") except Exception: raise ParamsError('51001') return d else: return s
def pw_decode(s, password): """ >>> a = 'R09PQ7uCCH1tZXt04MbDQOHnjh7kOMaH0vf3EKleze97XIpcB/iwt1DwcEcPkDh7+d6mCxBxmHQ72UJ1YUzJueYnFW3zsR1SIddZSheSavw1ee3tcb3eCvqpOZae+lDW74UlTqrusj50O3deSayC0Q==' >>> pw_decode(a, '123') :param s: :param password: :return: """ if password is not None: secret = Hash(password) try: d = DecodeAES(secret, s).decode("utf8") except Exception: raise ParamsError('51001') return d else: return s
def tx_response(self, response): params, result = self.parse_response(response) if not params: return tx_hash, tx_height = params assert tx_hash == hash_encode(Hash(result.decode('hex'))) tx = Transaction(result) try: tx.deserialize() except Exception: log.info("cannot deserialize transaction, skipping: %s", tx_hash) return self.wallet.receive_tx_callback(tx_hash, tx, tx_height) self.requested_tx.remove((tx_hash, tx_height)) log.info("received tx %s height: %d bytes: %d", tx_hash, tx_height, len(tx.raw)) # callbacks self.network.trigger_callback('new_transaction', tx) if not self.requested_tx: self.network.trigger_callback('updated')