コード例 #1
0
ファイル: bpp.py プロジェクト: jsbitcoin/bpp-client
def newbppid():
    if bppclient.cfgmain["priv_seed"] == "":
        QtGui.QMessageBox.critical(bppclient, 'Registration', "No seed in config file to generate password.", QtGui.QMessageBox.Ok)
        return
    bppid, ok = QtGui.QInputDialog.getText(bppclient, 'Create a new BPP ID', 'Enter your new BPP ID: (like [email protected])')
    if ok and bppid != '':
        password = Btclib.bip32_ckd(bppclient.mpkbpp, Btclib.decode(Btclib.sha256(bppid)[0:6],16))[-28:]
        bppclient.bppcnx = BPPxmpp(bppid, password)
        bppclient.bppcnx.register_plugin('xep_0030') # Service Discovery
        bppclient.bppcnx.register_plugin('xep_0004') # Data forms
        bppclient.bppcnx.register_plugin('xep_0066') # Out-of-band Data
        bppclient.bppcnx.register_plugin('xep_0077') # In-band Registration
        bppclient.bppcnx.register_plugin('xep_0054') # Vcard
        bppclient.bppcnx['xep_0077'].force_registration = True
	bppclient.bppcnx.connect(reattempt=False)
        bppclient.bppcnx.process()
        mutex.lock()
        waitCondition.wait(mutex)
        mutex.unlock()
        if bppclient.bppcnx.regstatus == 1:
            bppclient.cfgbpp.append({"bppid" : str(bppid), "password" : password})
            save_cfg()
            bppclient.ui.bppidcb.addItem(str(bppid))
            bppclient.ui.bppidcb.setCurrentIndex(bppclient.ui.bppidcb.count()-1)
            QtGui.QMessageBox.warning(bppclient, 'Registration', "Your BPP ID have been created.", QtGui.QMessageBox.Ok)
	    user = bppid.split('@')[0]
    	    sec = Btclib.hex_to_b58check(Btclib.privkey_to_pubkey(bppclient.keysign)[2:32])[1:]
    	    if user == sec:
        	bppclient.ui.bppidsec.setText(bppid)
    	    else:
        	bppclient.ui.bppidsec.setText(bppid + '&' + sec)
        elif bppclient.bppcnx.regstatus == 2:
            QtGui.QMessageBox.warning(bppclient, 'Registration', "This BPP ID is already in use.", QtGui.QMessageBox.Ok)
        elif bppclient.bppcnx.regstatus == 3:
            QtGui.QMessageBox.warning(bppclient, 'Registration', "No response frome the server. TimeOut.", QtGui.QMessageBox.Ok)
コード例 #2
0
ファイル: bpp.py プロジェクト: jsbitcoin/bpp-client
def bppidcnt():
    if len(bppclient.cfgbpp) == 0:
	QtGui.QMessageBox.warning(bppclient, 'Connection', "You must first create or add a new BPP ID.", QtGui.QMessageBox.Ok)
	return
    bppid = bppclient.ui.bppidcb.currentText()
    password = next(x["password"] for x in bppclient.cfgbpp if x["bppid"] == bppid)
    if bppclient.bppcnx != None: bppclient.bppcnx.disconnect()
    bppclient.bppcnx = BPPxmpp(bppid, password)
    bppclient.bppcnx.register_plugin('xep_0054')
    bppclient.bppcnx.connect()
    bppclient.bppcnx.process()
    user = bppid.split('@')[0]
    sec = Btclib.hex_to_b58check(Btclib.privkey_to_pubkey(bppclient.keysign)[2:32])[1:]
    if user == sec:
        bppclient.ui.bppidsec.setText(bppid)
    else:
        bppclient.ui.bppidsec.setText(bppid + '&' + sec)