Exemplo n.º 1
0
 def chooseSSLKeys(self,tx):
     keydir = os.path.join(g("Directories","agent_base_dir"),\
     '_'.join([tx.getRole(self.uniqID()),tx.uniqID(),"banksession"]),"keys")
     print ("You have chosen to send ssl keys to the escrow."
     "Do this carefully. Check the folder: ", keydir ," and "
     "decide which key number or numbers to send by looking at the "
     "corresponding html in the html directory, then enter those "
     "numbers here one by one at the prompt. When finished, type 0.")
     #get a listing of all valid key files
     all_keys = os.listdir(keydir)
     requested_keys=[]
     while True:
         choice = shared.get_validated_input("Enter a number (0 to quit)",int)
         if choice == 0:
             if not any(requested_keys):
                 print "Error, you must select at least one key."
             else:
                 print "Keys will now be sent to escrow."
                 break
         else:
             if str(choice)+'.key' not in all_keys:
                 print "That number does not correspond to an existing \
                     key, please try again."
             else:
                 requested_keys.append(os.path.join(keydir,str(choice)+'.key'))
                 
     self.sendSSLKeys(tx,requested_keys)  
Exemplo n.º 2
0
    def chooseSSLKeys(self, tx):
        keydir = os.path.join(g("Directories","agent_base_dir"),\
        '_'.join([tx.getRole(self.uniqID()),tx.uniqID(),"banksession"]),"keys")
        print(
            "You have chosen to send ssl keys to the escrow."
            "Do this carefully. Check the folder: ", keydir, " and "
            "decide which key number or numbers to send by looking at the "
            "corresponding html in the html directory, then enter those "
            "numbers here one by one at the prompt. When finished, type 0.")
        #get a listing of all valid key files
        all_keys = os.listdir(keydir)
        requested_keys = []
        while True:
            choice = shared.get_validated_input("Enter a number (0 to quit)",
                                                int)
            if choice == 0:
                if not any(requested_keys):
                    print "Error, you must select at least one key."
                else:
                    print "Keys will now be sent to escrow."
                    break
            else:
                if str(choice) + '.key' not in all_keys:
                    print "That number does not correspond to an existing \
                        key, please try again."

                else:
                    requested_keys.append(
                        os.path.join(keydir,
                                     str(choice) + '.key'))

        self.sendSSLKeys(tx, requested_keys)
Exemplo n.º 3
0
def changeEscrow(specific=None):
    shared.debug(0, ["Current escrow:", g("Escrow", "escrow_id")])
    if specific:
        c = specific
    else:
        for i, e in enumerate(getEscrowList()):
            print "[" + str(i + 1) + "] " + e[0]
        c = shared.get_validated_input("Choose an escrow", int)

    if c not in range(1, len(escrowList) + 1):
        shared.debug(0, ["Invalid choice from escrow list"])
    else:
        #rewrite the settings file and reset the escrow
        #TODO: persist changes to config file
        shared.config.set("Escrow", "escrow_id", value=escrowList[c - 1][0])
        shared.config.set("Escrow",
                          "escrow_pubkey",
                          value=escrowList[c - 1][2])
        shared.config.set("Escrow", "escrow_host", value=escrowList[c - 1][1])
        shared.debug(2, [
            "Set the escrow to host:",
            g("Escrow", "escrow_host"), "id:",
            g("Escrow", "escrow_id"), "pubkey:",
            g("Escrow", "escrow_pubkey")
        ])

    Msg.closeConnection()
    time.sleep(1)
    Msg.instantiateConnection(un='client1', pw='client1', chanIndex=0)
Exemplo n.º 4
0
 def editWorkingContract(self):
     while True:
         print "current working contract:\n"
         for k,v in self.workingContract.text.iteritems():
             print k,v
         for addr,sig in self.workingContract.signatures.iteritems():
             print "Signed by: ",addr[:5],"..."
             print "Signature: ",sig
         kchoice = shared.get_validated_input("Choose a parameter",str)   
         if kchoice not in self.workingContract.text.keys():
             break
         vchoice = shared.get_validated_input("Set the value:",str)
         self.contractLock.acquire()
         try:
             self.workingContract.modify(kchoice,vchoice)
         finally:
             self.contractLock.release()        
Exemplo n.º 5
0
 def editWorkingContract(self):
     while True:
         print "current working contract:\n"
         for k, v in self.workingContract.text.iteritems():
             print k, v
         for addr, sig in self.workingContract.signatures.iteritems():
             print "Signed by: ", addr[:5], "..."
             print "Signature: ", sig
         kchoice = shared.get_validated_input("Choose a parameter", str)
         if kchoice not in self.workingContract.text.keys():
             break
         vchoice = shared.get_validated_input("Set the value:", str)
         self.contractLock.acquire()
         try:
             self.workingContract.modify(kchoice, vchoice)
         finally:
             self.contractLock.release()
Exemplo n.º 6
0
 def printPendingContracts(self):
     print "Counterparty \t Amount"
     print "**********************"
     for k,v in self.pendingContracts.iteritems():
         print "["+k[:5]+"..] \t"+v.text['mBTC Amount']
     cchoice = shared.get_validated_input("Choose a counterparty identified by 5 characters:",str)
     for x in self.pendingContracts.keys():
         if x.startswith(cchoice):
             self.contractLock.acquire()
             try:
                 self.workingContract = self.pendingContracts[x]
                 print "Contract chosen: " + x
             finally:
                 self.contractLock.release()
             break
Exemplo n.º 7
0
 def printPendingContracts(self):
     print "Counterparty \t Amount"
     print "**********************"
     for k, v in self.pendingContracts.iteritems():
         print "[" + k[:5] + "..] \t" + v.text['mBTC Amount']
     cchoice = shared.get_validated_input(
         "Choose a counterparty identified by 5 characters:", str)
     for x in self.pendingContracts.keys():
         if x.startswith(cchoice):
             self.contractLock.acquire()
             try:
                 self.workingContract = self.pendingContracts[x]
                 print "Contract chosen: " + x
             finally:
                 self.contractLock.release()
             break
Exemplo n.º 8
0
def changeEscrow(specific=None):
    shared.debug(0,["Current escrow:",g("Escrow","escrow_id")])
    if specific:
        c = specific
    else:
        for i,e in enumerate(getEscrowList()):
            print "["+str(i+1)+"] "+e[0]    
        c = shared.get_validated_input("Choose an escrow",int)
        
    if c not in range(1,len(escrowList)+1):
        shared.debug(0,["Invalid choice from escrow list"])
    else:
        #rewrite the settings file and reset the escrow
        #TODO: persist changes to config file
        shared.config.set("Escrow","escrow_id",value=escrowList[c-1][0])
        shared.config.set("Escrow","escrow_pubkey",value=escrowList[c-1][2])
        shared.config.set("Escrow","escrow_host",value=escrowList[c-1][1])
        shared.debug(2,["Set the escrow to host:",g("Escrow","escrow_host"),"id:",g("Escrow","escrow_id"),"pubkey:",g("Escrow","escrow_pubkey")])
        
    Msg.closeConnection()
    time.sleep(1)
    Msg.instantiateConnection(un='client1',pw='client1',chanIndex=0)
Exemplo n.º 9
0
 except:
     #necessary because empty queue raises Exception
     pass        
 if RE:
     print """You are on RE. Please choose an option:
     [1] Show current transactions and choose one 
     [2] Pay mBTC to be transferred into multisig (seller)
     [3] Request banking session (buyer)
     [4] Dispute receipt of funds (seller)
     [5] Confirm receipt of funds (buyer)
     [6] Show transaction details
     [7] Specify ssl keys as proof of transfer (buyer)
     [8] Exit
     """
     
     choice = shared.get_validated_input("Enter an integer:",int)
     
     if choice in [2,3,4,5,6] and txRE is None:
         print "You need to specify a transaction first"
         continue 
     
     if choice==1:
         if not myself.synchronizeTransactions():
             shared.debug(0,["Error synchronizing transactions"])                              
         tnum = shared.get_validated_input("Choose a transaction:",int)
         print "got ",str(tnum)
         if tnum not in range(0,len(myself.transactions)):
             shared.debug(0,["Invalid choice"])
             continue
         txRE = tnum
         print "set txre to",str(txRE)
Exemplo n.º 10
0
        except:
            #necessary because empty queue raises Exception
            pass
        if RE:
            print """You are on RE. Please choose an option:
            [1] Show current transactions and choose one 
            [2] Pay mBTC to be transferred into multisig (seller)
            [3] Request banking session (buyer)
            [4] Dispute receipt of funds (seller)
            [5] Confirm receipt of funds (buyer)
            [6] Show transaction details
            [7] Specify ssl keys as proof of transfer (buyer)
            [8] Exit
            """

            choice = shared.get_validated_input("Enter an integer:", int)

            if choice in [2, 3, 4, 5, 6] and txRE is None:
                print "You need to specify a transaction first"
                continue

            if choice == 1:
                if not myself.synchronizeTransactions():
                    shared.debug(0, ["Error synchronizing transactions"])
                tnum = shared.get_validated_input("Choose a transaction:", int)
                print "got ", str(tnum)
                if tnum not in range(0, len(myself.transactions)):
                    shared.debug(0, ["Invalid choice"])
                    continue
                txRE = tnum
                print "set txre to", str(txRE)
Exemplo n.º 11
0
 #initialise multisig
 #multisig.initialise(p,d) #TODO remove this "initialize" thing
 multisig.msd=d
 #need a connection to an escrow to do anything
 Msg.instantiateConnection()
 adjudicator = AdjudicatorAgent(d,myEscrow,txStore=False)
 while True:
     print """Please choose an option:
     [1] Read message from queue
     [2] Choose transaction
     [3] Adjudicate transaction
     [4] Review adjudicator applications
     [5] Exit
     
     """
     choice = shared.get_validated_input("Enter an integer:",int)
     
     
     if choice==1:
         msg = adjudicator.getSingleMessage(prefix='ADJ')
         print msg
         
     elif choice==2:
         print "todo"
     elif choice==3:
         print "todo"
     
     elif choice==4:
         with open(g("Escrow","adjudicator_store")) as f:
             lines = f.readlines()
         applications = [x for x in lines if 'ADJUDICATOR_APPLICATION' in x]
Exemplo n.º 12
0
    #initialise multisig
    #multisig.initialise(p,d) #TODO remove this "initialize" thing
    multisig.msd = d
    #need a connection to an escrow to do anything
    Msg.instantiateConnection()
    adjudicator = AdjudicatorAgent(d, myEscrow, txStore=False)
    while True:
        print """Please choose an option:
        [1] Read message from queue
        [2] Choose transaction
        [3] Adjudicate transaction
        [4] Review adjudicator applications
        [5] Exit
        
        """
        choice = shared.get_validated_input("Enter an integer:", int)

        if choice == 1:
            msg = adjudicator.getSingleMessage(prefix='ADJ')
            print msg

        elif choice == 2:
            print "todo"
        elif choice == 3:
            print "todo"

        elif choice == 4:
            with open(g("Escrow", "adjudicator_store")) as f:
                lines = f.readlines()
            applications = [x for x in lines if 'ADJUDICATOR_APPLICATION' in x]
            print '''