electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 684390a47960420af9d1018c85c82c04ea3e0126
parent 87486e94874f83780921855d836f3fa3e1e36965
Author: SomberNight <somber.night@protonmail.com>
Date:   Fri, 29 Jun 2018 11:58:12 +0200

labels plugin: fix it. and extend to cli/daemon.

Diffstat:
Mlib/daemon.py | 2++
Mplugins/labels/__init__.py | 2+-
Aplugins/labels/cmdline.py | 11+++++++++++
Mplugins/labels/labels.py | 5+++--
4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/lib/daemon.py b/lib/daemon.py @@ -41,6 +41,7 @@ from .storage import WalletStorage from .commands import known_commands, Commands from .simple_config import SimpleConfig from .exchange_rate import FxThread +from .plugins import run_hook def get_lockfile(config): @@ -175,6 +176,7 @@ class Daemon(DaemonThread): wallet = self.load_wallet(path, config.get('password')) if wallet is not None: self.cmd_runner.wallet = wallet + run_hook('load_wallet', wallet, None) response = wallet is not None elif sub == 'close_wallet': path = config.get_wallet_path() diff --git a/plugins/labels/__init__.py b/plugins/labels/__init__.py @@ -5,5 +5,5 @@ description = ' '.join([ _("Save your wallet labels on a remote server, and synchronize them across multiple devices where you use Electrum."), _("Labels, transactions IDs and addresses are encrypted before they are sent to the remote server.") ]) -available_for = ['qt', 'kivy'] +available_for = ['qt', 'kivy', 'cmdline'] diff --git a/plugins/labels/cmdline.py b/plugins/labels/cmdline.py @@ -0,0 +1,11 @@ +from .labels import LabelsPlugin +from electrum.plugins import hook + +class Plugin(LabelsPlugin): + + @hook + def load_wallet(self, wallet, window): + self.start_wallet(wallet) + + def on_pulled(self, wallet): + self.print_error('labels pulled from server') diff --git a/plugins/labels/labels.py b/plugins/labels/labels.py @@ -9,6 +9,7 @@ import base64 import electrum from electrum.plugins import BasePlugin, hook +from electrum.crypto import aes_encrypt_with_iv, aes_decrypt_with_iv from electrum.i18n import _ @@ -21,14 +22,14 @@ class LabelsPlugin(BasePlugin): def encode(self, wallet, msg): password, iv, wallet_id = self.wallets[wallet] - encrypted = electrum.bitcoin.aes_encrypt_with_iv(password, iv, + encrypted = aes_encrypt_with_iv(password, iv, msg.encode('utf8')) return base64.b64encode(encrypted).decode() def decode(self, wallet, message): password, iv, wallet_id = self.wallets[wallet] decoded = base64.b64decode(message) - decrypted = electrum.bitcoin.aes_decrypt_with_iv(password, iv, decoded) + decrypted = aes_decrypt_with_iv(password, iv, decoded) return decrypted.decode('utf8') def get_nonce(self, wallet):