<s> from basehandler import BaseHandler <EOL> from password_db import LockedPasswordTransaction <EOL> import json <EOL> import logging <EOL> import datetime <EOL> class TimelockCreateHandler ( BaseHandler ) : <EOL> def __init__ ( self , oracle ) : <EOL> self . oracle = oracle <EOL> self . btc = oracle . btc <EOL> def handle_request ( self , request ) : <EOL> message = request . message <EOL> if not self . try_prepare_raw_transaction ( message ) : <EOL> logging . debug ( '<STR_LIT>' ) <EOL> return <EOL> pwtxid = self . oracle . btc . add_multisig_address ( message [ '<STR_LIT>' ] , message [ '<STR_LIT>' ] ) <EOL> if LockedPasswordTransaction ( self . oracle . db ) . get_by_pwtxid ( pwtxid ) : <EOL> logging . debug ( '<STR_LIT>' ) <EOL> return <EOL> reply_msg = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : pwtxid , <EOL> '<STR_LIT>' : message [ '<STR_LIT>' ] } <EOL> logging . debug ( '<STR_LIT>' ) <EOL> self . oracle . broadcast_with_fastcast ( json . dumps ( reply_msg ) ) <EOL> LockedPasswordTransaction ( self . oracle . db ) . save ( { '<STR_LIT>' : pwtxid , '<STR_LIT>' : json . dumps ( message ) } ) <EOL> locktime = int ( message [ '<STR_LIT>' ] ) <EOL> logging . debug ( "<STR_LIT>" % datetime . datetime . fromtimestamp ( locktime ) . strftime ( '<STR_LIT>' ) ) <EOL> message [ '<STR_LIT>' ] = pwtxid <EOL> self . oracle . task_queue . save ( { <EOL> "<STR_LIT>" : '<STR_LIT>' , <EOL> "<STR_LIT>" : json . dumps ( message ) , <EOL> "<STR_LIT>" : <NUM_LIT:0> , <EOL> "<STR_LIT>" : int ( locktime ) <EOL> } ) <EOL> def handle_task ( self , task ) : <EOL> message = json . loads ( task [ '<STR_LIT>' ] ) <EOL> future_transaction = self . try_prepare_raw_transaction_full_node ( message ) <EOL> assert ( future_transaction is not None ) <EOL> logging . debug ( '<STR_LIT>' ) <EOL> self . oracle . signer . sign ( future_transaction , message [ '<STR_LIT>' ] , message [ '<STR_LIT>' ] , message [ '<STR_LIT>' ] ) </s>
