mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-27 07:23:25 +00:00
support for remote wallet
This commit is contained in:
parent
180059355d
commit
ac7bff3aa0
3 changed files with 36 additions and 2 deletions
|
@ -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("-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("-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("-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()
|
options, args = parser.parse_args()
|
||||||
|
|
||||||
interface = Interface()
|
interface = Interface()
|
||||||
wallet = Wallet(interface)
|
wallet = Wallet(interface)
|
||||||
wallet.set_path(options.wallet_path)
|
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:
|
if len(args)==0:
|
||||||
url = None
|
url = None
|
||||||
cmd = 'gui'
|
cmd = 'gui'
|
||||||
|
|
|
@ -150,7 +150,7 @@ class Interface:
|
||||||
wallet.status[addr] = blk_hash
|
wallet.status[addr] = blk_hash
|
||||||
is_new = True
|
is_new = True
|
||||||
|
|
||||||
if is_new:
|
if is_new or wallet.remote_url:
|
||||||
wallet.synchronize()
|
wallet.synchronize()
|
||||||
wallet.update_tx_history()
|
wallet.update_tx_history()
|
||||||
wallet.save()
|
wallet.save()
|
||||||
|
|
|
@ -262,8 +262,8 @@ class Wallet:
|
||||||
self.tx_history = {}
|
self.tx_history = {}
|
||||||
|
|
||||||
self.imported_keys = {}
|
self.imported_keys = {}
|
||||||
|
|
||||||
self.interface = interface
|
self.interface = interface
|
||||||
|
self.remote_url = None
|
||||||
|
|
||||||
|
|
||||||
def set_path(self, wallet_path):
|
def set_path(self, wallet_path):
|
||||||
|
@ -456,6 +456,7 @@ class Wallet:
|
||||||
|
|
||||||
|
|
||||||
def synchronize(self):
|
def synchronize(self):
|
||||||
|
|
||||||
is_new = False
|
is_new = False
|
||||||
while True:
|
while True:
|
||||||
if self.change_addresses == []:
|
if self.change_addresses == []:
|
||||||
|
@ -481,6 +482,23 @@ class Wallet:
|
||||||
self.create_new_address(False)
|
self.create_new_address(False)
|
||||||
is_new = True
|
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):
|
def is_found(self):
|
||||||
return (len(self.change_addresses) > 1 ) or ( len(self.addresses) > self.gap_limit )
|
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:
|
if self.seed_version != SEED_VERSION:
|
||||||
raise BaseException(upgrade_msg)
|
raise BaseException(upgrade_msg)
|
||||||
|
|
||||||
|
if self.remote_url: assert self.master_public_key.encode('hex') == self.get_remote_mpk()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_new_address(self):
|
def get_new_address(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue