def test_address_from_base58addr(self): #TESTNET addr1 = BitcoinAddress.from_base58addr( "n4MsBRWD7VxKGsqYRSLaFZC6hQrsrKLaZo") self.assertEquals(hexstr(addr1.get_hash160()), 'fa92e151722c0ebca07059a505252218b4c50e7a') self.assertEquals(addr1.get_addr_version(), AddressVersion(PUBKEY_ADDRESS_TEST)) #TESTNET script address addr2 = BitcoinAddress.from_base58addr( "2NG68seqhTqLnniguW6efUDKyCHm4LYEFRa") self.assertEquals(hexstr(addr2.get_hash160()), 'fa92e151722c0ebca07059a505252218b4c50e7a') self.assertEquals(addr2.get_addr_version(), AddressVersion(SCRIPT_ADDRESS_TEST)) #MAIN addr2 = BitcoinAddress.from_base58addr( "1PqutNREJUX4VmMvhsNCRdymqRGAzifdsx") self.assertEquals(hexstr(addr2.get_hash160()), 'fa92e151722c0ebca07059a505252218b4c50e7a') self.assertEquals(addr2.get_addr_version(), AddressVersion(PUBKEY_ADDRESS_MAIN)) #MAIN Script address addr2 = BitcoinAddress.from_base58addr( "3QXvouufrNqSaw4Mpy2nrGLhywYtXx6wsi") self.assertEquals(hexstr(addr2.get_hash160()), 'fa92e151722c0ebca07059a505252218b4c50e7a') self.assertEquals(addr2.get_addr_version(), AddressVersion(SCRIPT_ADDRESS_MAIN))
def _read_names(self): for key, key_cursor, value, value_cursor in self._read_entries("name"): address_bytestr, _ = self.varstr_serializer.deserialize( key, key_cursor) name, _ = self.varstr_serializer.deserialize(value, value_cursor) address = BitcoinAddress.from_base58addr(address_bytestr) self.names[address] = WalletName(name, address)
def on_select_send_value(self, event): base58addrstr = self.wallet_view.send_view.address() amount_str = self.wallet_view.send_view.amount() if not BitcoinAddress.is_valid(base58addrstr, self.account.wallet.runmode): self.messages_view.error("Incorrect bitcoin address: %s" % (base58addrstr)) return if not is_float(amount_str): self.messages_view.error("Incorrect amount: %s" % (amount_str)) return planned_tx = self.account.create_transaction( int(float(amount_str) * COIN), BitcoinAddress.from_base58addr(base58addrstr), 0) self.wallet_view.send_view.close() passphrases = [] try: if self.account.is_passphrase_required(planned_tx): passphrase = yield self.wallet_view.enter_passphrase_view.get_passphrase( ) passphrases.append(passphrase) self.account.send_transaction(planned_tx, passphrases) except KeyDecryptException as e: self.messages_view.error( "Unable to decrypt the private keys: please verify the passphrase and try again." ) except ActionCancelledException: pass except Exception as e: traceback.print_exc() self.messages_view.error("Error while sending transaction: %s" % (str(e)))
def test_address_from_base58addr(self): #TESTNET addr1 = BitcoinAddress.from_base58addr("n4MsBRWD7VxKGsqYRSLaFZC6hQrsrKLaZo") self.assertEquals(hexstr(addr1.get_hash160()), 'fa92e151722c0ebca07059a505252218b4c50e7a') self.assertEquals(addr1.get_addr_version(), AddressVersion(PUBKEY_ADDRESS_TEST)) #TESTNET script address addr2 = BitcoinAddress.from_base58addr("2NG68seqhTqLnniguW6efUDKyCHm4LYEFRa") self.assertEquals(hexstr(addr2.get_hash160()), 'fa92e151722c0ebca07059a505252218b4c50e7a') self.assertEquals(addr2.get_addr_version(), AddressVersion(SCRIPT_ADDRESS_TEST)) #MAIN addr2 = BitcoinAddress.from_base58addr("1PqutNREJUX4VmMvhsNCRdymqRGAzifdsx") self.assertEquals(hexstr(addr2.get_hash160()), 'fa92e151722c0ebca07059a505252218b4c50e7a') self.assertEquals(addr2.get_addr_version(), AddressVersion(PUBKEY_ADDRESS_MAIN)) #MAIN Script address addr2 = BitcoinAddress.from_base58addr("3QXvouufrNqSaw4Mpy2nrGLhywYtXx6wsi") self.assertEquals(hexstr(addr2.get_hash160()), 'fa92e151722c0ebca07059a505252218b4c50e7a') self.assertEquals(addr2.get_addr_version(), AddressVersion(SCRIPT_ADDRESS_MAIN))
def set_receive_label(self, address_base58, label): address = BitcoinAddress.from_base58addr(address_base58) self.wallet.begin_updates() public_key, is_crypted = self.wallet.addresses[address] # decode_base58check(address)[1:] self.wallet.allocate_key(public_key, label) self.wallet.commit_updates() new_description = self.wallet.get_address_description(public_key) self.fire(self.EVT_NEW_ADDRESS_DESCRIPTION, public_key=public_key, description=new_description)
def set_receive_label(self, address_base58, label): address = BitcoinAddress.from_base58addr(address_base58) self.wallet.begin_updates() public_key, is_crypted = self.wallet.addresses[ address] #decode_base58check(address)[1:] self.wallet.allocate_key(public_key, label) self.wallet.commit_updates() new_description = self.wallet.get_address_description(public_key) self.fire(self.EVT_NEW_ADDRESS_DESCRIPTION, public_key=public_key, description=new_description)
def _read_names(self): for key, key_cursor, value, value_cursor in self._read_entries("name"): address_bytestr, _ = self.varstr_serializer.deserialize(key, key_cursor) name, _ = self.varstr_serializer.deserialize(value, value_cursor) address = BitcoinAddress.from_base58addr(address_bytestr) self.names[address] = WalletName(name, address)