async def create( config: Dict, private_key: ExtendedPrivateKey, root_path: Path, name: str = None, override_constants: Dict = {}, local_test: bool = False, ): self = WalletNode() self.config = config self.constants = consensus_constants.copy() self.root_path = root_path self.local_test = local_test for key, value in override_constants.items(): self.constants[key] = value if name: self.log = logging.getLogger(name) else: self.log = logging.getLogger(__name__) db_path_key_suffix = str( private_key.get_public_key().get_fingerprint()) path = path_from_root( self.root_path, f"{config['database_path']}-{db_path_key_suffix}") mkdir(path.parent) self.wallet_state_manager = await WalletStateManager.create( private_key, config, path, self.constants) self.wallet_state_manager.set_pending_callback( self._pending_tx_handler) # Normal operation data self.cached_blocks = {} self.future_block_hashes = {} # Sync data self._shut_down = False self.proof_hashes = [] self.header_hashes = [] self.header_hashes_error = False self.short_sync_threshold = 15 self.potential_blocks_received = {} self.potential_header_hashes = {} self.server = None self.tasks = [] return self
def add_private_key(self, key: ExtendedPrivateKey): """ Adds an extended private key to the keychain. This is used for old keys from keys.yaml. The new method is adding a seed (which can be converted into a mnemonic) instead. """ key_bytes = bytes(key) index = self._get_free_private_key_index() if key.get_public_key().get_fingerprint() in [ epk.get_public_key().get_fingerprint() for epk in self.get_all_public_keys() ]: # Prevents duplicate add return keyring.set_password( self._get_service(), self._get_private_key_user(index), key_bytes.hex() )