def __init__(self, *args, **kwargs): super(Bitcoin, self).__init__(*args, **kwargs) self.config_file = 'wgbitcoin.conf' self.required_config_vars = ['rpcpassword'] self.default_config_vars = {'rpcuser': '******', 'rpcssl': 0, 'rpcport': '8332', 'rpcurl': '127.0.0.1'} self.main_menu = { 0: { 'description': 'Genie, are you currently able to speak to the bitcoin network?', 'insert_before': '\n--- Bitcoin Functions ---\n', 'callback': self.print_diagnostics }, 1: { 'description': 'Genie, how many bitcoin do I have in my coffers?', 'callback': self.get_balance }, 2: { 'description': 'Genie, I wish to send bitcoin to an address.', 'callback': self.send_btc }, 3: { 'description': 'Genie, I wish to sign a message from an address I control.', 'callback': self.sign_message }, 4: { 'description': 'Genie, I wish to verify the origin of this signed message.', 'callback': self.verify_message }, 5: { 'description': 'Genie, I wish to add another private key to my wallet.', 'callback': self.import_privkey }, 6: { 'description': 'Genie, I wish to watch this external address. Keep track of it for me.', 'callback': self.import_watch_address }, 7: { 'description': 'Genie, I wish to create a new address into which I can receive more bitcoin.', 'callback': self.get_new_address }, 8: { 'description': 'Genie, I wish to unlock my wallet so you can perform some transactions on my behalf.', 'callback': lambda printsuccess=True, printerrors=True, modify_duration=True: self.unlock_wallet(printsuccess, printerrors, modify_duration) }, 9: { 'description': 'Genie, I wish to lock my wallet to keep my bitcoin safe from thieves.', 'callback': lambda printsuccess=True, printerrors=True: self.try_lock_wallet(printsuccess, printerrors) }, 10: { 'description': 'Genie, I wish to protect my bitcoin coffers with a magic phrase. Keep my bitcoin safe from thieves. TNO.', 'callback': self.encrypt_wallet }, 11: { 'description': 'Genie, I wish to change my magic phrase. There are scoundrels all around.', 'callback': self.change_passphrase } } self.selected_address = None self.selected_address_info = None # {isvalid, address, ismine, isscript, pubkey, iscompressed, account} self.encrypted_wallet = False wgc = WalletGenieConfig() self.rpcd = wgc.check_and_load(self.config_file, required_values=self.required_config_vars, default_values=self.default_config_vars) if self.rpcd is None: print('\nIt appears that {} does not yet exist. If this is your first time running the walletgenie_bitcoin plugin, you will need a configuration file detailing your RPC Connection information.\n'.format(self.config_file)) confvars = [(x, None) for x in self.required_config_vars if x not in self.default_config_vars.keys()] confvars += self.default_config_vars.items() wgc.set_from_coin_or_text( self.config_file, default_conf_loc='/home/bitcoin/.bitcoin/bitcoin.conf', config_vars=confvars ) self.rpcd = wgc.check_and_load(self.config_file, required_values=self.required_config_vars, default_values=self.default_config_vars, silent=False) if not self.rpcd: print('\n\nUnable to load configuration file: {}\nAborting Bitcoin plugin\n'.format(self.config_file)) raise WalletGenieConfigurationError(self.config_file) self.access = BitcoinRPCProxy( service_url='{}://{}:{}@{}:{}'.format( 'https' if int(self.rpcd['rpcssl']) else 'http', self.rpcd['rpcuser'], self.rpcd['rpcpassword'], self.rpcd['rpcurl'], self.rpcd['rpcport'] ) )
def __init__(self, *args, **kwargs): super(Counterparty, self).__init__(*args, **kwargs) if not self.require_plugin('walletgenie_bitcoin', autoload_if_available=True): print('Error loading Counterparty plugin') sys.exit(0) self.btc = self.active_plugins['walletgenie_bitcoin']['plugin_class'] self.config_file = 'wgcounterparty.conf' self.required_config_vars = ['rpc-password'] self.default_config_vars = {'rpcuser': '******', 'rpcssl': 0, 'rpcport': '4000', 'rpcurl': '127.0.0.1'} bitcoin_menu_height = sorted(self.btc.main_menu.iteritems(), key=lambda x: x[0])[-1][0] bitcoin_menu_height += 1 self.main_menu = self.btc.main_menu.copy() self.main_menu[bitcoin_menu_height] = { 'description': 'Genie, are you currently able to speak to the Counterparty network?', 'insert_before': '\n--- Counterparty Functions ---\n', 'callback': self.print_diagnostics } self.main_menu[bitcoin_menu_height + 1] = { 'description': 'Genie, I wish to see all of my Counterparty balances.', 'callback': self.print_all_balances } self.main_menu[bitcoin_menu_height + 2] = { 'description': 'Genie, I wish to send an asset from my active address to another address.', 'callback': self._prompt_send_asset } self.main_menu[bitcoin_menu_height + 3] = { 'description': 'Genie, I wish to choose an active address.', 'callback': self.choose_address } self.main_menu[bitcoin_menu_height + 4] = { 'description': 'Genie, I wish to create a new Counterpary asset to be owned by the active address.', 'callback': self._prompt_create_issuance } self.main_menu[bitcoin_menu_height + 5] = { 'description': 'Genie, I wish to issue additional tokens for an asset owned by the active address.', 'callback': self._prompt_issue_additional } self.main_menu[bitcoin_menu_height + 6] = { 'description': 'Genie, I wish to lock an asset in the active address so that no further issuances can be made.', 'callback': self._prompt_lock_asset } self.main_menu[bitcoin_menu_height + 7] = { 'description': 'Genie, I wish to transfer ownership of an asset from the active address to another address.', 'callback': self._prompt_transfer_asset } self.main_menu[bitcoin_menu_height + 8] = { 'description': 'Genie, I wish to change the description of an asset owned by the active address.', 'callback': self._prompt_change_asset_description } self.main_menu[bitcoin_menu_height + 9] = { 'description': 'Genie, I wish to make a broadcast on the Counterparty network.', 'callback': self._prompt_send_broadcast } wgc = WalletGenieConfig() self.rpcd = wgc.check_and_load(self.config_file, required_values=self.required_config_vars, default_values=self.default_config_vars) if self.rpcd is None: print('\nIt appears that {} does not yet exist. If this is your first time running the walletgenie_counterparty plugin, you will need a config file detailing your RPC Connection information.\n'.format(self.config_file)) confvars = [(x, None) for x in self.required_config_vars if x not in self.default_config_vars.keys()] confvars += self.default_config_vars.items() wgc.set_from_coin_or_text( self.config_file, default_conf_loc='/home/xcp/.config/counterparty/server.conf', coin_conf_header='Default', config_vars=confvars ) self.rpcd = wgc.check_and_load(self.config_file, required_values=self.required_config_vars, default_values=self.default_config_vars, silent=False) if not self.rpcd: print('\n\nUnable to load configuration file: {}\nAborting Counterparty plugin\n'.format(self.config_file)) raise WalletGenieConfigurationError(self.config_file) # note: even though we change url to https here, encrypted requests will not work (using HTTPBasicAuth) self.url = '{}://{}:{}/api/'.format( 'https' if int(self.rpcd['rpcssl']) else 'http', self.rpcd['rpcurl'], self.rpcd['rpcport'] ) self.auth = HTTPBasicAuth(self.rpcd['rpcuser'], self.rpcd['rpc-password'])
def __init__(self, *args, **kwargs): self.config_file = 'wglitecoin.conf' self.required_config_vars = ['rpcpassword'] self.default_config_vars = { 'rpcssl': 0, 'rpcuser': '******', 'rpcport': 9332, 'rpcurl': '127.0.0.1' } self.main_menu = { 0: { 'description': 'Genie, are you currently able to speak to the litecoin network?', 'insert_before': '\n--- litecoin Functions ---\n', 'callback': lambda: self._print_diagnostics('litecoin') }, 1: { 'description': 'Genie, how many bitcoin do I have in my coffers?', 'callback': lambda: self._prompt_get_balance('LTC') }, 2: { 'description': 'Genie, I wish to send litecoin to an address.', 'callback': lambda: self._prompt_send('LTC') }, 3: { 'description': 'Genie, I wish to sign a message from an address I control.', 'callback': self._prompt_sign_message }, 4: { 'description': 'Genie, I wish to verify the origin of this signed message.', 'callback': self._prompt_verify_message }, 5: { 'description': 'Genie, I wish to add another private key to my wallet.', 'callback': self.import_privkey }, 6: { 'description': 'Genie, I wish to watch this external address. Keep track of it for me.', 'callback': self.import_watch_address }, 7: { 'description': 'Genie, I wish to create a new address into which I can receive more litecoin.', 'callback': self._prompt_get_new_address }, 8: { 'description': 'Genie, I wish to unlock my wallet so you can perform some transactions on my behalf.', 'callback': lambda printsuccess=True, printerrors=True, modify_duration=True: self.unlock_wallet( printsuccess, printerrors, modify_duration) }, 9: { 'description': 'Genie, I wish to lock my wallet to keep my litecoin safe from thieves.', 'callback': lambda printsuccess=True, printerrors=True: self. try_lock_wallet(printsuccess, printerrors) }, 10: { 'description': 'Genie, I wish to protect my bitcoin coffers with a magic phrase. Keep my bitcoin safe from thieves. TNO.', 'callback': self._prompt_encrypt_wallet }, 11: { 'description': 'Genie, I wish to change my magic phrase. There are scoundrels all around.', 'callback': self._prompt_change_passphrase } } wgc = WalletGenieConfig() self.rpcd = wgc.check_and_load( self.config_file, required_values=self.required_config_vars, default_values=self.default_config_vars) if self.rpcd is None: print( '\nIt appears that {} does not yet exist. If this is your first time running the walletgenie_litecoin plugin, you will need a configuration file detailing your RPC Connection information.\n' .format(self.config_file)) confvars = [(x, None) for x in self.required_config_vars if x not in self.default_config_vars.keys()] confvars += self.default_config_vars.items() wgc.set_from_coin_or_text( self.config_file, default_conf_loc='/home/litecoin/.litecoin/litecoin.conf', config_vars=confvars) self.rpcd = wgc.check_and_load( self.config_file, required_values=self.required_config_vars, default_values=self.default_config_vars, silent=False) if not self.rpcd: print( '\n\nUnable to load configuration file: {}\nAborting Litecoin plugin\n' .format(self.config_file)) raise WalletGenieConfigurationError(self.config_file) super(Litecoin, self).__init__( '{}://{}:{}@{}:{}'.format( 'https' if int(self.rpcd['rpcssl']) else 'http', self.rpcd['rpcuser'], self.rpcd['rpcpassword'], self.rpcd['rpcurl'], self.rpcd['rpcport']), *args, **kwargs)