def signAssertFile(wltPath, assertFile): wlt = PyBtcWallet().readWalletFile(wltPath) if not wlt.hasAddr(signAddress): print 'Supplied wallet does not have the correct signing key' exit(1) if wlt.useEncryption and wlt.isLocked: print 'Must unlock wallet to sign the assert file...' passcnt = 0 while True: passwd = SecureBinaryData(getpass.getpass('Wallet passphrase: ')) if not wlt.verifyPassphrase(passwd): print 'Invalid passphrase!' if passcnt == 2: print 'Too many password attempts. Exiting.' exit(1) passcnt += 1 continue break wlt.unlock(securePassphrase=passwd) passwd.destroy() addrObj = wlt.getAddrByHash160(addrStr_to_hash160(signAddress)[1]) def doSignFile(inFile, outFile): with open(inFile, 'rb') as f: try: sigBlock = ASv1CS(addrObj.binPrivKey32_Plain.toBinStr(), f.read()) except: print 'Error with call to sigBlock' exit(1) with open(outFile, 'wb') as f: f.write(sigBlock) doSignFile(assertFile, '%s.sig' % assertFile)