Ejemplo n.º 1
0
    def _write(self):
        if threading.currentThread().isDaemon():
            self.print_error('warning: daemon thread cannot write wallet')
            return
        if not self.modified:
            return
        s = json.dumps(self.data, indent=4, sort_keys=True)
        if self.pubkey:
            s = bitcoin.encrypt_message(zlib.compress(s), self.pubkey)

        temp_path = "%s.tmp.%s" % (self.path, os.getpid())
        with open(temp_path, "w") as f:
            f.write(s)
            f.flush()
            os.fsync(f.fileno())

        mode = os.stat(self.path).st_mode if os.path.exists(self.path) else stat.S_IREAD | stat.S_IWRITE
        # perform atomic write on POSIX systems
        try:
            os.rename(temp_path, self.path)
        except:
            os.remove(self.path)
            os.rename(temp_path, self.path)
        os.chmod(self.path, mode)
        self.print_error("saved", self.path)
        self.modified = False
Ejemplo n.º 2
0
 def encrypt(self, pubkey, message):
     return bitcoin.encrypt_message(message, pubkey)
Ejemplo n.º 3
0
 def encrypt(self, pubkey, message):
     """Encrypt a message with a public key. Use quotes if the message contains whitespaces."""
     return bitcoin.encrypt_message(message, pubkey)
Ejemplo n.º 4
0
 def encrypt(self, pubkey, message):
     """Encrypt a message with a public key. Use quotes if the message contains whitespaces."""
     return bitcoin.encrypt_message(message, pubkey)
Ejemplo n.º 5
0
 def encrypt(self, pubkey, message):
     return bitcoin.encrypt_message(message, pubkey)