示例#1
0
 def get_missed(self, name=''):
     try:
         if name:
             w = Witness(name)
             m = w.json()['total_missed']
         else:
             w = Witness(self.conf.d['owner'])
             m = w.json()['total_missed']
     except WitnessDoesNotExistsException:
         return False
     return m
示例#2
0
 def print_witness(self, name=''):
     if name:
         try:
             w = Witness(name)
         except WitnessDoesNotExistsException:
             self.log.log("Witness does not exist.", 2)
             return False
         self.conf.print_json(w.json())
     else:
         try:
             w = Witness(self.conf.d['owner'])
         except WitnessDoesNotExistsException:
             self.log.log("Witness does not exist.", 2)
             return False
         self.conf.print_json(w.json())
示例#3
0
    def test_export(self, node_param):
        if node_param == "normal":
            bts = self.bts
        else:
            bts = self.steemit
        owner = "gtg"
        if bts.rpc.get_use_appbase():
            witness = bts.rpc.find_witnesses({'owners': [owner]},
                                             api="database")['witnesses']
            if len(witness) > 0:
                witness = witness[0]
        else:
            witness = bts.rpc.get_witness_by_account(owner)

        w = Witness(owner, steem_instance=bts)
        keys = list(witness.keys())
        json_witness = w.json()
        exclude_list = [
            'votes', 'virtual_last_update', 'virtual_scheduled_time',
            'last_aslot', 'last_confirmed_block_num'
        ]
        for k in keys:
            if k not in exclude_list:
                if isinstance(witness[k], dict) and isinstance(
                        json_witness[k], list):
                    self.assertEqual(list(witness[k].values()),
                                     json_witness[k])
                else:
                    self.assertEqual(witness[k], json_witness[k])
示例#4
0
 def witness_json(self, name):
     try:
         w = Witness(name)
     except WitnessDoesNotExistsException:
         self.log.log("Witness does not exist.", 2)
         return False
     return w.json()
示例#5
0
文件: config.py 项目: bobinson/pywit
 def check_config(self, name):
     self.d['owner'] = name
     try:
         w = Witness(name)
     except WitnessDoesNotExistsException:
         return False
     wj = w.json()
     self.d['props'] = wj['props']
     self.d['url'] = wj['url']
     self.write_config()
     return True
示例#6
0
	node=["https://peer.vit.tube/"],
	bundle=True,
	blocking="head",
	nobroadcast=NO_BROADCAST, #set True for testing	
	custom_chains=CUSTOM_CHAINS,
	keys={'active': WIF},
)

#stm.wallet.unlock(UNLOCK)

while True:
  try:
    set_shared_steem_instance(stm)
    currentdatetime = datetime.datetime.now()
    w1 = Witness(ACCT)
    json_string = json.dumps(w1.json(), indent=4)
    data = json.loads(json_string)
    total_missed = data["total_missed"]
    if total_missed >= THRESHOLD:
	  #Disable witness.
      tx = TransactionBuilder(steem_instance=stm)
      update_witness = {
        "owner": ACCT,
        "url": "No website yet", 
        "block_signing_key": NATIVE_PREFIX + '1111111111111111111111111111111114T1Anm', 
        "props": {
          "account_creation_fee": Amount("0.100 %s" % (NATIVE_SYMBOL)),
          "maximum_block_size":131072, 
        },
      "fee": Amount("0.000 %s" % (NATIVE_SYMBOL)),
      "prefix": NATIVE_PREFIX,
示例#7
0
        witness = sys.argv[1]
    stm = Steem()
    witness = Witness(witness, steem_instance=stm)

    witness_schedule = stm.get_witness_schedule()
    config = stm.get_config()
    if "VIRTUAL_SCHEDULE_LAP_LENGTH2" in config:
        lap_length = int(config["VIRTUAL_SCHEDULE_LAP_LENGTH2"])
    else:
        lap_length = int(config["STEEM_VIRTUAL_SCHEDULE_LAP_LENGTH2"])
    witnesses = WitnessesRankedByVote(limit=250, steem_instance=stm)
    vote_sum = witnesses.get_votes_sum()

    virtual_time_to_block_num = int(
        witness_schedule["num_scheduled_witnesses"]) / (lap_length /
                                                        (vote_sum + 1))
    while True:
        witness.refresh()
        witness_schedule = stm.get_witness_schedule(use_stored_data=False)

        witness_json = witness.json()
        virtual_diff = int(witness_json["virtual_scheduled_time"]) - int(
            witness_schedule['current_virtual_time'])
        block_diff_est = virtual_diff * virtual_time_to_block_num

        time_diff_est = convert_block_diff_to_time_string(block_diff_est)

        sys.stdout.write("\r Next block for %s in %s" %
                         (witness["owner"], time_diff_est))
        sleep(30)
示例#8
0
                    help="Blocksize to advertise as a witness",
                    type=int)
parser.add_argument('--interestrate',
                    help="Interest rate to advertise as a witness",
                    type=int)
args = parser.parse_args()
if (args.operation[0] == "update"):
    if checkwit(args.account[0]):
        if not checkkey(args.account[0], args.privateactivekey[0], "active"):
            sys.exit("Private active key " + args.privateactivekey[0] +
                     " doesn't prove authority for user " + args.account[0])
        wit = Witness(args.account[0], steem_instance=stmf)
        #Witness exists
        #take stuff from blockchain, if the user doesn't provide the args
        if not args.publicownerkey:
            my_publickey = str(wit.json()["signing_key"])
        else:
            try:
                PublicKey(args.publicownerkey, prefix="EUR")
            except:
                sys.exit("Wrong public key syntax " + args.publicownerkey)
            else:
                my_publickey = str(args.publicownerkey)

        if not args.url:
            my_url = str(wit.json()["url"])
        else:
            my_url = str(args.url)

        if not args.creationfee:
            my_fee = str(wit.json()["props"]["account_creation_fee"])
示例#9
0
 def get_missed(self):
     w = Witness(self.conf.d['owner'])
     m = w.json()['total_missed']
     return m
示例#10
0
 def get_price_feed(self):
     w = Witness(self.conf.d['owner'])
     p = Amount(w.json()['sbd_exchange_rate']['base']).amount
     return p