def comment(): messages = [{ 'parent_author': '', 'parent_permlink': 'common-post', 'author': 'user011', 'permlink': 'post-028', 'title': 'post', 'body': 'post', 'json_metadata': '{"tags":["tag00"],"app":"steemit/0.1","format":"markdown"}' }] tb = TransactionBuilder(no_broadcast=False, steemd_instance=custom_instance, wallet_instance=wallet_instance) ops = [operations.Comment(**x) for x in messages] tb.appendOps(ops) tb.appendSigner('user011', 'posting') tb.sign() tx = tb.broadcast() print(tx)
def cancelorder(cardid): # ermittele die market_id r = requests.get('https://steemmonsters.com/market/for_sale') data = r.json() for card in data: uid = card['uid'] market_id = card['market_id'] if cardid == uid: trxid = market_id #baue die Transaktion auf json = {"trx_id": trxid} print(json) ops = [ operations.CustomJson( **{ "from": user, "id": "sm_cancel_sell", "json": json, "required_auths": [], "required_posting_auths": [user], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(user, "posting") tb.sign() tb.broadcast()
def buy_upvote(author, upvote_bot, amount, permlink): transfers = [{ 'from': author, 'to': upvote_bot, 'amount': '{0:.3f} SBD'.format(amount), 'memo': 'https://steemit.com/@{}/{}'.format(author, permlink) }] print("\n\n") print("Buying " + upvote_bot + " " + str(amount) + " vote for author " + author + "\n and permalink " + permlink) print("\n\n") tb = TransactionBuilder() operation = [operations.Transfer(**x) for x in transfers] tb.appendOps(operation) tb.appendSigner(author, 'active') tb.sign() try: tx = tb.broadcast() print("** Vote success") except Exception as error: print(repr(error))
def tx_build(op, steemd_instance, wallet_instance, account): tx = TransactionBuilder(steemd_instance=steemd_instance, wallet_instance=wallet_instance, no_broadcast=False) tx.appendOps(op) tx.appendSigner(account, 'posting') tx.sign() # print("txsign",tx) # re = tx.broadcast() return tx
def payout(transfers, account): print("Paying out winners") tb = TransactionBuilder(no_broadcast=False) operation = [operations.Transfer(**x) for x in transfers] tb.appendOps(operation) tb.appendSigner(account, 'active') tb.sign() tx = tb.broadcast() print("Payout succes")
def transfer(_from, _to, amount): messages = [{'from': _from, 'to': _to, 'amount': amount, 'memo': ''}] tb = TransactionBuilder(no_broadcast=False, steemd_instance=custom_instance, wallet_instance=wallet_instance) ops = [operations.Transfer(**x) for x in messages] tb.appendOps(ops) tb.appendSigner(_from, 'posting') tb.sign() tx = tb.broadcast() print(tx)
def cancel_match(): ops = [ operations.CustomJson(**{ "from": user, "id": "sm_cancel_match", "json": '{"app":"steemmonsters/0.4.4.1"}', "required_auths": [], "required_posting_auths": [user], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(user, "posting") tb.sign()
def smshowteam(show_json): ops = [ operations.CustomJson(**{ "from": user, "id": "sm_team_reveal", "json": show_json, "required_auths": [], "required_posting_auths": [user], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(user, "posting") tb.sign() tb.broadcast()
def smfindmatch(): ops = [ operations.CustomJson(**{ "from": user, "id": "sm_find_match", "json": '{"match_type":"Ranked"}', "required_auths": [], "required_posting_auths": [user], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(user, "posting") tb.sign() tb.broadcast()
def start_quest(): json = '{"type":"daily"}' ops = [ operations.CustomJson(**{ "from": user, "id": "sm_start_quest", "json": json, "required_auths": [], "required_posting_auths": [user], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(user, "posting") tb.sign() tb.broadcast()
def cancel_content_order(owner, order_id): messages = [ { 'owner': owner, 'order_id': order_id, 'json_metadata': '' }] tb = TransactionBuilder(no_broadcast=False, steemd_instance=custom_instance, wallet_instance=wallet_instance) ops = [operations.ContentOrderCancel(**x) for x in messages] tb.appendOps(ops) tb.appendSigner(owner, 'active') tb.sign() tx = tb.broadcast() print(tx)
def post_encrypted_content(owner, author, permlink, price, msg, enc_msg, order_id): nonce = unix_time_seconds(datetime.utcnow()) if owner == '': cipher, check, msg_len = encrypt(priv1, priv1.pubkey, nonce, enc_msg) plaintext, check2 = decrypt(priv1, priv1.pubkey, nonce, cipher) apply_order = False new_permlink = permlink else: cipher, check, msg_len = encrypt(priv2, priv1.pubkey, nonce, enc_msg) plaintext, check2 = decrypt(priv2, priv1.pubkey, nonce, cipher) apply_order = True new_permlink = permlink + '-' + str(nonce) if check != check2: return messages = [{ 'parent_author': '', 'parent_permlink': 'category', 'author': author, 'permlink': new_permlink, 'title': new_permlink, 'body': msg, 'json_metadata': '', 'encrypted_message': cipher, 'sent_time': nonce, 'message_size': msg_len, 'checksum': check, 'price': price, 'owner': owner, 'order_id': order_id, 'apply_order': apply_order }] tb = TransactionBuilder(no_broadcast=False, steemd_instance=custom_instance, wallet_instance=wallet_instance) ops = [operations.EncryptedContent(**x) for x in messages] tb.appendOps(ops) tb.appendSigner(author, 'posting') tb.sign() tx = tb.broadcast() print(tx)
def withdraw(): with open("config/config_withdraw.json", 'r') as load_f: input_args = json.load(load_f) for i in range(len(input_args)): args = input_args[i] key = args['key'] withdraw_vesting_object = args['withdraw_vesting'] account_name = withdraw_vesting_object['account'] steem = Steem(nodes=nodes_remote, keys=key) # now we can construct the transaction # we will set no_broadcast to True because # we don't want to really send funds, just testing. tb = TransactionBuilder() # lets serialize our transfers into a format Steem can understand operationsList = [] operationsList.append( operations.WithdrawVesting(**withdraw_vesting_object)) # do SetWithdrawVestingRoute if 'SetWithdrawVestingRouteList' in args: SetWithdrawVestingRouteList = args['SetWithdrawVestingRouteList'] len_item = len(SetWithdrawVestingRouteList) for i in range(len_item): set_route_parameters = SetWithdrawVestingRouteList[i] operationsList.append( operations.SetWithdrawVestingRoute(**set_route_parameters)) # tell TransactionBuilder to use our serialized transfers tb.appendOps(operationsList) # we need to tell TransactionBuilder about # everyone who needs to sign the transaction. tb.appendSigner(account_name, 'active') # sign the transaction tb.sign() # broadcast the transaction (publish to steem) # since we specified no_broadcast=True earlier # this method won't actually do anything tx = tb.broadcast()
def create_content_order(author, permlink, owner, price): messages = [ { 'author': author, 'permlink': permlink, 'owner': owner, 'price': price, 'json_metadata': '' }] tb = TransactionBuilder(no_broadcast=False, steemd_instance=custom_instance, wallet_instance=wallet_instance) ops = [operations.ContentOrderCreate(**x) for x in messages] tb.appendOps(ops) tb.appendSigner(owner, 'active') tb.sign() tx = tb.broadcast() print(tx)
def create_account(new_account_name): key1 = PrivateKey() key2 = PrivateKey() key3 = PrivateKey() key4 = PrivateKey() messages = [{ 'fee': '10.000 BMT', 'creator': 'initminer', 'new_account_name': new_account_name, 'json_metadata': '', 'memo_key': str(key4.pubkey), 'owner': { 'account_auths': [], 'key_auths': [[str(key1.pubkey), 1]], 'weight_threshold': 1 }, 'active': { 'account_auths': [], 'key_auths': [[str(key2.pubkey), 1]], 'weight_threshold': 1 }, 'posting': { 'account_auths': [], 'key_auths': [[str(key3.pubkey), 1]], 'weight_threshold': 1 } }] tb = TransactionBuilder(no_broadcast=False, steemd_instance=custom_instance, wallet_instance=wallet_instance) ops = [operations.AccountCreate(**x) for x in messages] tb.appendOps(ops) tb.appendSigner('initminer', 'posting') tb.sign() tx = tb.broadcast() wallet_instance.addPrivateKey(wif=str(key1)) wallet_instance.addPrivateKey(wif=str(key2)) wallet_instance.addPrivateKey(wif=str(key3)) wallet_instance.addPrivateKey(wif=str(key4)) print(tx)
def vote(voter, author, permlink, weight): messages = [ { 'voter': voter, 'author': author, 'permlink': permlink, 'weight': weight, 'comment_bmchain': '' }] tb = TransactionBuilder(no_broadcast=False, steemd_instance=custom_instance, wallet_instance=wallet_instance) ops = [operations.Vote(**x) for x in messages] tb.appendOps(ops) tb.appendSigner(voter, 'posting') tb.sign() try: tx = tb.broadcast() print(tx) except ValueError: print("Can't vote")
def private_message(): msg_obj = OrderedDict([ ("subject", "python"), ("body", "Message from python script 00000000000000000000000000000000000015"), ]) json_enc = json.JSONEncoder() json_msg = json_enc.encode(msg_obj) nonce = unix_time_millis(datetime.utcnow()) priv1 = PrivateKey('5Kidmv7RHnXpaXSkiJQ61mnJZGcjLcPJn6WRmZzqCH13JJcBKfE') priv2 = PrivateKey('5KbqodapZuWe4R7cKux4YPPRw1vcvhRcguy89RUBXufutu5esEX') cipher, check, msg_len = encrypt(priv1, priv2.pubkey, nonce, json_msg) plaintext, check2 = decrypt(priv2, priv1.pubkey, nonce, cipher) if check != check2: return messages = [{ 'from': 'user011', 'to': 'user012', 'from_memo_key': 'BMT7unMyzVRmnZHTKg6gLXgZUYBAAbPQdGdixuxsX7ifWskpnGcPX', 'to_memo_key': 'BMT7hQntbAnehUp2xbrrGi8am2nV2jLS5pGGXTFi38KYwcyoLEjjL', 'sent_time': nonce, 'checksum': check, 'message_size': msg_len, 'encrypted_message': cipher }] tb = TransactionBuilder(no_broadcast=False, steemd_instance=custom_instance, wallet_instance=wallet_instance) ops = [operations.PrivateMessage(**x) for x in messages] tb.appendOps(ops) tb.appendSigner('user011', 'posting') tb.sign() tx = tb.broadcast() print(tx)
def delegate_vest(): with open("config/config_delegate_vest.json", 'r') as load_f: input_args = json.load(load_f) for i in range(len(input_args)): args = input_args[i] key = args['key'] operation_object = args['delegate_vest'] account_name = operation_object['delegator'] steem = Steem(nodes=nodes_remote, keys=key) # now we can construct the transaction # we will set no_broadcast to True because # we don't want to really send funds, just testing. tb = TransactionBuilder() # lets serialize our transfers into a format Steem can understand operationsList = [] operationsList.append( operations.DelegateVestingShares(**operation_object)) # tell TransactionBuilder to use our serialized transfers tb.appendOps(operationsList) # we need to tell TransactionBuilder about # everyone who needs to sign the transaction. # since all payments are made from `richguy`, # we just need to do this once tb.appendSigner(account_name, 'active') # sign the transaction tb.sign() # broadcast the transaction (publish to steem) # since we specified no_broadcast=True earlier # this method won't actually do anything tx = tb.broadcast() print(account_name + " done")
def dw_attack(enemy, unit, amount, account): ops = [ operations.CustomJson(**{ "from": account, "id": "dw-attack", "json": { "username" : account, "defender":enemy, "army":[{ "unit": unit, "amount":amount }] }, "required_auths": [], "required_posting_auths": [account], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(account, "posting") tb.sign() pprint.pprint(tb.broadcast())
def claimreward(): #get the claim id # get the current quest data r = requests.get('https://steemmonsters.com/players/quests?username='******'id'] json = '{"type":"quest","quest_id":"' + claimid +'"}' ops = [ operations.CustomJson(**{ "from": user, "id": "sm_claim_reward", "json": json, "required_auths": [], "required_posting_auths": [user], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(user, "posting") tb.sign() tb.broadcast()
def sell(cardid, price): json = [{ "cards": [cardid], "currency": "USD", "price": str(price), "fee_pct": 500 }] print(json) ops = [ operations.CustomJson( **{ "from": user, "id": "sm_sell_cards", "json": json, "required_auths": [], "required_posting_auths": [user], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(user, "posting") tb.sign() tb.broadcast()
ops = [ operations.CustomJson( **{ "from": account, "id": "dw-heist", "json": { "username": account, "amount": "100" }, "required_auths": [], "required_posting_auths": [account], }), ] tb = TransactionBuilder() tb.appendOps(ops) tb.appendSigner(account, "posting") tb.sign() tb.broadcast() #from steem import Steem #from steem.transactionbuilder import TransactionBuilder #from steembase import operations #s = Steem(nodes=["https://rpc.usesteem.com"], # keys=["<posting_key>"]) account = account_name ops = [ operations.CustomJson( **{ "from": account, "id": "dw-unit",
else: return False # end def while(count <= 10000): betTX = [] betTX.append({ 'from': accountname, 'to': 'epicdice', 'amount': (str(betAmount) + ' STEEM'), 'memo': (AboveOrBelow + ' ' + str(OverUnderNum)), }) tb = TransactionBuilder() ops = None ops = [operations.Transfer(**x) for x in betTX] tb.appendOps(ops) tb.appendSigner(accountname, "active") tb.sign() tb.broadcast() userAcct = Account(accountname) steemBalance = Amount(userAcct['balance']).amount print(" ") print("Balance: %s STEEM" % steemBalance) print ('bet # ' + str(count)) print((str(betAmount) + ' STEEM ') + ((AboveOrBelow + ' ' + str(OverUnderNum)))) if steemBalance <= stopLose: print("%s STEEM left, hit stopLose." % steemBalance) break elif steemBalance >= stopWin: print("%s STEEM left, hit stopWin." % steemBalance) break #if (didWin()):
] print(transfers) # now we can construct the transaction # we will set no_broadcast to True because # we don't want to really send funds, just testing. tb = TransactionBuilder() # lets serialize our transfers into a format Steem can understand operations = [operations.Transfer(**x) for x in transfers] print(operations) # tell TransactionBuilder to use our serialized transfers tb.appendOps(operations) print(tb) # we need to tell TransactionBuilder about # everyone who needs to sign the transaction. # since all payments are made from `richguy`, # we just need to do this once tb.appendSigner('runburgundy', 'active') # sign the transaction tb.sign() print(tb) print(type(tb)) # broadcast the transaction (publish to steem) # since we specified no_broadcast=True earlier # this method won't actually do anything tx = tb.broadcast()
def main(): # 假设不存在不可用节点(无法判断节点状态) k = 2 n =2 nodelist =[ 'http://101.76.212.247:8090', 'http://101.76.212.247:8094', 'http://101.76.221.115:8092' ] groupobj = PairingGroup('SS512') group_signature = GroupSignature(groupobj) L = group_signature.LGen(n, k) print(L) steembase.chains.known_chains['TEST'] = { 'chain_id': '18dcf0a285365fc58b71f18b3d3fec954aa0c141c44e4e5cb4cf777b9eab274e', 'prefix': 'TST', 'steem_symbol': 'TESTS', 'sbd_symbol': 'TBD', 'vests_symbol': 'VESTS' } vkliststr= [] uskliststr = [] vklist = [] usklist = [] h1str = "" clientlist = [] pk = {} count = 0 groupID = "computer" userID = "user" GID = group_signature.group.hash(groupID) UID = group_signature.group.hash(userID) print("uid") print(UID) #connect node and private posting key # 记录可用节点的编号!!!!!! #该循环仅获得gvki和uski 并通过gvki验证uski的正确性 for i in range(n): clientlist.append(steem.Steem(nodes=[nodelist[i]],keys=["5JHKRW4d7BTU1V1CXDQAPmDfBBFr6XqQoDDUpmPP1JW38s5NjeW"])) vkliststr.append(clientlist[i].get_vk()['vk']) vklist.append(group_signature.group.fromstr(vkliststr[i],10, G1)) uskliststr.append(clientlist[i].user_extract(userID)) usklist.append({}) usklist[i]['b0'] = group_signature.group.fromstr(uskliststr[i]['b0'], 10, G2) usklist[i]['b3'] = group_signature.group.fromstr(uskliststr[i]['b3'], 10, G2) usklist[i]['b4'] = group_signature.group.fromstr(uskliststr[i]['b4'], 10, G2) usklist[i]['b5'] = group_signature.group.fromstr(uskliststr[i]['b5'], 10, G1) print(usklist[i]) if h1str == "": h1str = clientlist[i].get_pk()['pk'] pk = group_signature.pkGen(h1str) if(group_signature.verifyUsk(usklist[i],vklist[i],pk,GID, UID)): count = count + 1 else: print("key is invalide\n\n") if count< k: print("there is not k admin\n") return #通过uski计算出最终的usk usk = group_signature.uskGen(usklist, pk, GID, UID, L,k) # print(pk) # ---------------------------------------------------commit 开始 account = 'initminer2' author = 'nya' title = "title" body = "body" #对title进行群签名得到sig sig = group_signature.sign(title,usk, pk,GID, UID,groupID) json_metadata = "abc" permlink = ''.join(random.choices(string.digits, k=4)) print("permlink is " + permlink) op = operations.CommitPaper( **{ "account":account, "author":"nya", "permlink":permlink, "title":title, "body":body, "json_metadata":json_metadata, "c0":str(sig['c0']), "c5":str(sig['c5']), "c6":str(sig['c6']), "e1":str(sig['e1']), "e2":str(sig['e2']), "e3":str(sig['e3']), "c":str(sig['c']), "s1":str(sig['s1']), "s2":str(sig['s2']), "s3":str(sig['s3']) } ) #该操作由第二个账户进行 tx = TransactionBuilder(steemd_instance=clientlist[1].steemd,wallet_instance = clientlist[0].wallet,no_broadcast = False) tx.appendOps(op) tx.appendSigner('initminer2','posting') tx.sign() re = tx.broadcast() #---------------------------------------------------commit 结束 # ---------------------------------------------------open 开始 okliststr=[] oklist = [] i = 0 for client in clientlist: okstr = client.get_ok(str(sig['e1']),str(sig['e2'])) #每个节点返回ok1和ok2 print(okstr) okliststr.append(okstr) i = i + 1 if i < k: print("the number of ok is not enough\n") return #通过ok1和ok2 计算lameda lam = group_signature.open(okliststr,L,k) E = (pk['n'] ** UID) * lam #计算出e3 即签名的e3 判断是否相等 print("e3",E) op = operations.ApplyOpen( **{ 'account':account, 'author':userID, 'lambda':str(lam), 'permlink':permlink, 'json_metadata':json_metadata } ) tx = TransactionBuilder(steemd_instance=clientlist[0].steemd,wallet_instance = clientlist[0].wallet,no_broadcast = False) tx.appendOps(op) tx.appendSigner('initminer2','posting') tx.sign() # time.sleep(5) re = tx.broadcast() print("re",re) # ---------------------------------------------------open 结束 return
hrl = ac.history_reverse(filter_by='transfer',raw_output=False) for op in hrl: if op['block'] <= lb: break block_num = op['block'] if op['block'] > mlb: mlb = op['block'] with open(block_file, 'a+') as f: f.write("%s\n" % str(mlb)) am = Amount(op['amount']) if am.amount==0.002 and am.asset=='SBD' and op['to']==username: if block_num not in block_witness: get_witness(block_num,block_witness,s) guess = op['memo'].strip('@') if guess == block_witness[block_num]: memo = 'Your guess was right! Witness for block '+str(block_num)+' was '+guess trx = {'memo':memo,'from':username,'to':op['from'],'amount':'0.021 SBD'} else: memo = 'Sorry, but for block '+str(block_num)+' the witness was '+block_witness[block_num]+' and not '+guess+' as you guessed. Try again!:)' trx = {'memo':memo,'from':username,'to':op['from'],'amount':'0.001 SBD'} transfers.append(trx) if transfers: tb = TransactionBuilder() operations = [operations.Transfer(**x) for x in transfers] tb.appendOps(operations) tb.appendSigner(username, 'active') tb.sign() tx = tb.broadcast() print(tx)