Package: teos-client
teos-clientteos-clientis an example command line client to interact with the Eye of Satoshi watchtower server, written in
Python3. It has commands to register a user to the watchtower (generating user keys if necessary), to add an
appointment and to retrieve information about appointments.DependenciesRefer toDEPENDENCIES.mdInstallationRefer toINSTALL.mdUsageteos-client [global options] command [command options] [arguments]Global options--apiconnect:	API server where to send the requests. Defaults to 'localhost' (modifiable in conf file).--apiport:	API port where to send the requests. Defaults to '9814' (modifiable in conf file).-h --help: 	shows a list of commands or help for a specific command.CommandsThe client has four commands:register: registers your user with the tower.add_appointment: sends a json formatted appointment to the tower.get_appointment: gets json formatted data about an appointment from the tower.help: shows a list of commands or help for a specific command.registerThis commands serves as registration. It sends your public key to the tower to create a subscription (free at the moment) and returns a number of available appointment slots in the tower. Topping up the subscription can be done by simply sending a register message again.Notice that you need to be registered before sending any other type of request to the tower.Usageteos-client register tower_idadd_appointmentThis command is used to send appointments to the watchtower. Appointmentsmustbejsonencoded, and match the following format:{ "tx": tx,
  "tx_id": tx_id,
  "to_self_delay": d }txmustbe the raw penalty transaction that will be encrypted before being sent to the watchtower.type(tx) = hex encoded strtx_idmustmatch thecommitment transaction id, and will be used to encrypt thepenalty transactionandgenerate the locator.type(tx_id) = hex encoded strto_self_delayis the time the watchtower would have to respond with thepenalty transactiononce thedispute transactionis seen in the blockchain.dmust match with theOP_CSVspecified in the dispute transaction. If the to_self_delay does not match theOP_CSV, the watchtower will try to respond with the penalty transaction anyway, but success is not guaranteed.dis measured in blocks and should be at least20.type(d) = intThe API will return aapplication/jsonHTTP response code200/OKif the appointment is accepted, with the locator encoded in the response text, or a400/Bad Requestif the appointment is rejected, with the rejection reason encoded in the response text.Usageteos-client add_appointment [command options] <appointment>/<path_to_appointment_file>if-f, --fileisspecified, then the command expects a path to a json file instead of a json encoded string as parameter.Options-f, --file path_to_json_fileloads the appointment data from the specified json file instead of command line.get_appointmentThis command is used to get information about a specific appointment from the Eye of Satoshi.Appointment can be in three states:not_found: meaning the locator is not recognised by the tower. This can either mean the locator is wrong, or the appointment has already been fulfilled (the tower does not keep track of completed appointments for now).being_watched: the appointment has been accepted by the tower and it's being watched at the moment. This stage means that the dispute transaction has not been seen yet, and therefore no penalty transaction has been broadcast.dispute_responded: the dispute was found by the watcher and the corresponding penalty transaction has been broadcast by the node. In this stage the tower is actively monitoring until the penalty transaction reaches enough confirmations and making sure no fork occurs in the meantime.Response formatsnot_found{
	"locator": l,
	"status": "not_found"
}being_watched{
	"locator": l,
	"status": "being_watched",
	"appointment":
		{
			"encrypted_blob": eb,
			"locator": appointment_locator,
			"status": "being_watched",
			"to_self_delay": d
		}
}dispute_responded{
	"locator": l,
	"status": "dispute_responded",
	"appointment":
		{
			"dispute_txid": dispute_txid,
			"locator": appointment_locator,
			"penalty_rawtx": penalty_rawtx,
			"penalty_txid": penalty_txid,
			"status": "dispute_responded"
		}
}Usageteos-client get_appointment <appointment_locator>ExampleRegister with the tower. A tower with the given id should be running (replace the id with the one you'll be using).teos-client register 03a3a3e196def1950f332556d046648d960102da33f61665a910febe38a1c3f825Generate a new dummy appointment.Note:this appointment will never be fulfilled (it will eventually expire) since it does not correspond to a valid transaction. However it can be used to interact with the Eye of Satoshi's API.echo '{"tx": "4615a58815475ab8145b6bb90b1268a0dbb02e344ddd483f45052bec1f15b1951c1ee7f070a0993da395a5ee92ea3a1c184b5ffdb2507164bf1f8c1364155d48bdbc882eee0868ca69864a807f213f538990ad16f56d7dfb28a18e69e3f31ae9adad229e3244073b7d643b4597ec88bf247b9f73f301b0f25ae8207b02b7709c271da98af19f1db276ac48ba64f099644af1ae2c90edb7def5e8589a1bb17cc72ac42ecf07dd29cff91823938fd0d772c2c92b7ab050f8837efd46197c9b2b3f", "tx_id": "0b9510d92a50c1d67c6f7fc5d47908d96b3eccdea093d89bcbaf05bcfebdd951", "to_self_delay": 20}' > dummy_appointment_data.jsonThat will create a json file that follows the appointment data structure filled with dummy data and store it indummy_appointment_data.json.Send the appointment to the tower API. Which will then start monitoring for matching transactions.teos-client add_appointment -f dummy_appointment_data.jsonThis returns an appointment locator that can be used to get updates about this appointment from the tower.Test that the tower is still watching the appointment by replacing the appointment locator received into the following command:pteos-client get_appointment <appointment_locator>Try our live instanceBy default,teos-clientwill connect to your local instance (running on localhost). There are also a couple of live instances running, one for mainet and one for testnet:testnet endpoint =teos-testnet.pisa.watch:443mainnet endpoint =teos.pisa.watch:443ortheeyeofsatoshi.pisa.watch:443tower_idis03a3a3e196def1950f332556d046648d960102da33f61665a910febe38a1c3f825for both.Connecting to the mainnet instanceAdd--apiconnect  --apiport 443to your calls, for example:teos-client --apiconnect=https://teos.pisa.watch --apiport=443 add_appointment   -f dummy_appointment_data.jsonYou can also change the config file to avoid specifying the server every time:api_connect = https://teos.pisa.watch
api_port = 443