Merge branch 'master' of gitorious.org:electrum/electrum
This commit is contained in:
commit
b9de843b51
|
@ -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'
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)<num:
|
||||
self.create_new_address(False)
|
||||
|
||||
def get_remote_number(self):
|
||||
import jsonrpclib
|
||||
server = jsonrpclib.Server(self.remote_url)
|
||||
out = server.getnum(self.remote_password)
|
||||
return out
|
||||
|
||||
def get_remote_mpk(self):
|
||||
import jsonrpclib
|
||||
server = jsonrpclib.Server(self.remote_url)
|
||||
out = server.getkey(self.remote_password)
|
||||
return out
|
||||
|
||||
def is_found(self):
|
||||
return (len(self.change_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):
|
||||
|
|
Loading…
Reference in New Issue