def get_account_id(account_name): key = '?account_id_%s' % unicodedata.normalize( 'NFKD', account_name).encode('ascii', 'ignore') account_id = mc.get(key) if not account_id: tmp = rpc.db_get_account_by_name(account_name) print 'MIRALO VIEN TMP => ', tmp account_id = tmp['id'] mc.set(key, account_id) return account_id
def register(): try: req = request.json name = ACCOUNT_PREFIX + str( req.get('name') ) if req.get('secret') == 'cdc1ddb0cd999dbc5ba8d7717e3837f5438af8198d48c12722e63a519e73a38c': name = str( req.get('name') ) owner = str( req.get('owner') ) active = str( req.get('active') ) memo = str( req.get('memo') ) if not bts2helper_is_valid_name(name): return jsonify({'error': 'is_not_valid_name'}) if not bts2helper_is_cheap_name(name): return jsonify({'error': 'is_not_cheap_name'}) acc = rpc.db_get_account_by_name(name) if acc is not None: return jsonify({'error': 'already_taken'}) rop = register_account_op( PROPUESTA_PAR_ID, GOBIERO_PAR_ID, 10000, name, { 'weight_threshold' : 1, 'account_auths' : [[GOBIERO_PAR_ID,1]], 'key_auths' : [[owner,1]], 'address_auths' : [] }, { 'weight_threshold' : 1, 'account_auths' : [], 'key_auths' : [[active,1]], 'address_auths' : [] }, memo, GOBIERO_PAR_ID, ) rop[1]['fee'] = rpc.db_get_required_fees([rop], '1.3.0')[0] ref_block_num, ref_block_prefix = ref_block(rpc.db_get_dynamic_global_properties()['head_block_id']) tx = build_tx([rop], ref_block_num, ref_block_prefix) #print tx to_sign = bts2helper_tx_digest(json.dumps(tx), CHAIN_ID) wif = REGISTER_PRIVKEY #signature = sign_compact2(to_sign, b.encode_privkey(k, 'wif')) signature = bts2helper_sign_compact(to_sign, wif) tx['signatures'] = [signature] p = rpc.network_broadcast_transaction_sync(tx) return jsonify({'ok':'ok', 'coco':p}) except Exception as e: logging.error(traceback.format_exc()) return make_response(jsonify({'error': ERR_UNKNWON_ERROR}), 500)
def get_account(account): return jsonify( rpc.db_get_account_by_name(ACCOUNT_PREFIX+account) )
def get_account(account): if str(account) != str('gobierno-par'): account = ACCOUNT_PREFIX + account return jsonify(rpc.db_get_account_by_name(account))
def resolve_blacklisted_by(self, args, context, info): return self.account['id'] in rpc.db_get_account_by_name( args.get('account'))['blacklisted_accounts']