diff --git a/client/electrum b/client/electrum index 07352244b..7b3060b97 100755 --- a/client/electrum +++ b/client/electrum @@ -40,12 +40,26 @@ if __name__ == '__main__': parser.add_option("-f", "--fee", dest="tx_fee", default="0.005", help="set tx fee") parser.add_option("-s", "--fromaddr", dest="from_addr", default=None, help="set source address for payto/mktx. if it isn't in the wallet, it will ask for the private key unless supplied in the format public_key:private_key. It's not saved in the wallet.") parser.add_option("-c", "--changeaddr", dest="change_addr", default=None, help="set the change address for payto/mktx. default is a spare address, or the source address if it's not in the wallet") + parser.add_option("-r", "--remote", dest="remote_url", default=None, help="URL of a remote wallet") options, args = parser.parse_args() interface = Interface() wallet = Wallet(interface) wallet.set_path(options.wallet_path) + if options.remote_url: + m = re.match('^(.*?)@(.*?)$', options.remote_url) + # header authentication is not supported + if m: + wallet.remote_url = 'http://'+m.group(2) + wallet.remote_password = m.group(1) + else: + print "bad url" + sys.exit(1) + else: + wallet.remote_url = None + + if len(args)==0: url = None cmd = 'gui' diff --git a/client/interface.py b/client/interface.py index 336256730..bbd8232e1 100644 --- a/client/interface.py +++ b/client/interface.py @@ -150,7 +150,7 @@ class Interface: wallet.status[addr] = blk_hash is_new = True - if is_new: + if is_new or wallet.remote_url: wallet.synchronize() wallet.update_tx_history() wallet.save() diff --git a/client/wallet.py b/client/wallet.py index 32664a654..f8ac74e49 100644 --- a/client/wallet.py +++ b/client/wallet.py @@ -262,8 +262,8 @@ class Wallet: self.tx_history = {} self.imported_keys = {} - self.interface = interface + self.remote_url = None def set_path(self, wallet_path): @@ -456,6 +456,7 @@ class Wallet: def synchronize(self): + is_new = False while True: if self.change_addresses == []: @@ -481,6 +482,23 @@ class Wallet: self.create_new_address(False) is_new = True + if self.remote_url: + num = self.get_remote_number() + print num + while len(self.addresses) 1 ) or ( len(self.addresses) > self.gap_limit ) @@ -556,6 +574,8 @@ class Wallet: if self.seed_version != SEED_VERSION: raise BaseException(upgrade_msg) + if self.remote_url: assert self.master_public_key.encode('hex') == self.get_remote_mpk() + return True def get_new_address(self):