def on_receive(self):
        if self.wallet.use_encryption:
            password = self.win.password_dialog('An encrypted transaction was retrieved from cosigning pool.\nPlease enter your password to decrypt it.')
            if not password:
                return
        else:
            password = None
            if not self.win.question(_("An encrypted transaction was retrieved from cosigning pool.\nDo you want to open it now?")):
                return

        message = self.listener.message
        key = self.listener.keyname
        xprv = self.wallet.get_master_private_key(key, password)
        if not xprv:
            return
        try:
            k = bitcoin.deserialize_xkey(xprv)[-1].encode('hex')
            EC = bitcoin.EC_KEY(k.decode('hex'))
            message = EC.decrypt_message(message)
        except Exception as e:
            traceback.print_exc(file=sys.stdout)
            self.win.show_message(str(e))
            return

        self.listener.clear()
        tx = transaction.Transaction(message)
        show_transaction(tx, self.win, prompt_if_unsaved=True)
Exemple #2
0
    def on_receive(self, keyhash, message):
        self.print_error("signal arrived for", keyhash)
        for key, _hash, window in self.keys:
            if _hash == keyhash:
                break
        else:
            self.print_error("keyhash not found")
            return

        wallet = window.wallet
        if wallet.use_encryption:
            password = window.password_dialog('An encrypted transaction was retrieved from cosigning pool.\nPlease enter your password to decrypt it.')
            if not password:
                return
        else:
            password = None
            if not window.question(_("An encrypted transaction was retrieved from cosigning pool.\nDo you want to open it now?")):
                return

        xprv = wallet.get_master_private_key(key, password)
        if not xprv:
            return
        try:
            k = bitcoin.deserialize_xkey(xprv)[-1].encode('hex')
            EC = bitcoin.EC_KEY(k.decode('hex'))
            message = EC.decrypt_message(message)
        except Exception as e:
            traceback.print_exc(file=sys.stdout)
            window.show_message(str(e))
            return

        self.listener.clear(keyhash)
        tx = transaction.Transaction(message)
        show_transaction(tx, window, prompt_if_unsaved=True)
Exemple #3
0
def make_billing_address(wallet, num):
    long_id, short_id = wallet.get_user_id()
    xpub = make_xpub(billing_xpub, long_id)
    _, _, _, c, cK = deserialize_xkey(xpub)
    cK, c = bitcoin.CKD_pub(cK, c, num)
    address = public_key_to_bc_address( cK )
    return address
Exemple #4
0
 def f(xprv):
     from electrum.bitcoin import deserialize_xkey, bip32_private_key, regenerate_key, is_compressed
     _, _, _, c, k = deserialize_xkey(xprv)
     pk = bip32_private_key([0, 0], k, c)
     key = regenerate_key(pk)
     compressed = is_compressed(pk)
     sig = key.sign_message(message, compressed)
     return base64.b64encode(sig)
Exemple #5
0
 def load_wallet(self, wallet):
     self.wallet = wallet
     if not self.is_available():
         return
     mpk = self.wallet.get_master_public_keys()
     self.cosigner_list = []
     for key, xpub in mpk.items():
         keyname = key + '/' # fixme
         K = bitcoin.deserialize_xkey(xpub)[-1].encode('hex')
         _hash = bitcoin.Hash(K).encode('hex')
         if self.wallet.master_private_keys.get(keyname):
             self.listener.set_key(keyname, _hash)
         else:
             self.cosigner_list.append((xpub, K, _hash))
 def load_wallet(self, wallet, window):
     self.wallet = wallet
     if not self.is_available():
         return
     if self.listener is None:
         self.listener = Listener(self)
         self.listener.start()
     self.cosigner_list = []
     for key, xpub in self.wallet.master_public_keys.items():
         K = bitcoin.deserialize_xkey(xpub)[-1].encode('hex')
         _hash = bitcoin.Hash(K).encode('hex')
         if self.wallet.master_private_keys.get(key):
             self.listener.set_key(key, _hash)
         else:
             self.cosigner_list.append((xpub, K, _hash))
Exemple #7
0
 def update(self, window):
     wallet = window.wallet
     if wallet.wallet_type not in ['2of2', '2of3']:
         return
     if self.listener is None:
         self.print_error("starting listener")
         self.listener = Listener(self)
         self.listener.start()
     elif self.listener:
         self.print_error("shutting down listener")
         self.listener.stop()
         self.listener = None
     self.keys = []
     self.cosigner_list = []
     for key, xpub in wallet.master_public_keys.items():
         K = bitcoin.deserialize_xkey(xpub)[-1].encode('hex')
         _hash = bitcoin.Hash(K).encode('hex')
         if wallet.master_private_keys.get(key):
             self.keys.append((key, _hash, window))
         else:
             self.cosigner_list.append((window, xpub, K, _hash))
     if self.listener:
         self.listener.set_keyhashes([t[1] for t in self.keys])
Exemple #8
0
 def update(self, window):
     wallet = window.wallet
     if type(wallet) != Multisig_Wallet:
         return
     if self.listener is None:
         self.print_error("starting listener")
         self.listener = Listener(self)
         self.listener.start()
     elif self.listener:
         self.print_error("shutting down listener")
         self.listener.stop()
         self.listener = None
     self.keys = []
     self.cosigner_list = []
     for key, keystore in wallet.keystores.items():
         xpub = keystore.get_master_public_key()
         K = bitcoin.deserialize_xkey(xpub)[-1].encode('hex')
         _hash = bitcoin.Hash(K).encode('hex')
         if not keystore.is_watching_only():
             self.keys.append((key, _hash, window))
         else:
             self.cosigner_list.append((window, xpub, K, _hash))
     if self.listener:
         self.listener.set_keyhashes([t[1] for t in self.keys])
Exemple #9
0
def make_xpub(xpub, s):
    _, _, _, c, cK = deserialize_xkey(xpub)
    cK2, c2 = bitcoin._CKD_pub(cK, c, s)
    xpub2 = ("0488B21E" + "00" + "00000000" + "00000000").decode("hex") + c2 + cK2
    return EncodeBase58Check(xpub2)