Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
37 lines (27 sloc) 1.33 KB
""" Example of logging in a watch only user with GreenAddress """
from gacommon.utils import *
from login_authenticate import do_login
import sys
if __name__ == "__main__":
mnemonic = sys.argv[1]
# First, login a full user to create the watch only account
conn, wallet, login_data = do_login(mnemonic)
# Find out if we have a watch only account already set up
sync_data ='addressbook.get_sync_status')
have_watch_only = sync_data['username'] is not None
# For example purposes, create a user/password based on the mnemonic.
watch_only_username = h(sha256(bytearray(mnemonic, 'ascii')))[:15]
watch_only_password = h(sha256(bytearray(mnemonic + 'dummy', 'ascii')))[:15]
# Create the watch only user if we don't already have one
if not have_watch_only:
ret ='addressbook.sync_custom',
watch_only_username, watch_only_password)
assert ret
# Login the watch only user
watch_only_conn = GAConnection(GAConnection.REGTEST_URI)
token = {'username': watch_only_username,
'password': watch_only_password}
login_data ='login.watch_only_v2', 'custom', token,
# The watch only user can now be used to fetch addresses etc