def do(self, network, op): tx = Transaction(self.source, sequence=1) tx.add_operation(op) envelope = Te(tx, network_id=network) signer = Keypair.from_seed(self.seed) envelope.sign(signer) envelope_b64 = envelope.xdr() return envelope_b64
def do(self, network, opts): tx = Transaction(self.source, **opts) tx.add_operation(Inflation()) envelope = Te(tx, network_id=network) signer = Keypair.from_seed(self.seed) envelope.sign(signer) envelope_b64 = envelope.xdr() print(envelope_b64) return envelope_b64
def make_envelope(self, network, *args, **kwargs): opts = {'sequence': 2, 'fee': 100 * len(args)} for opt, value in kwargs.items(): opts[opt] = value tx = Transaction(self.address, **opts) for count, op in enumerate(args): tx.add_operation(op) envelope = Te(tx, network_id=network) signer = Keypair.from_seed(self.seed) envelope.sign(signer) envelope_b64 = envelope.xdr() print(envelope_b64) return envelope_b64
async def make_envelope(network, horizon, address, seed, *args, **kwargs): opts = { 'sequence': int((await horizon.account(address))['sequence']) + 1, 'fee': 100 * len(args) } for opt, value in kwargs.items(): opts[opt] = value tx = Transaction(address, **opts) for count, op in enumerate(args): tx.add_operation(op) envelope = Te(tx, network_id=network) signer = Keypair.from_seed(seed) envelope.sign(signer) envelope_xdr = envelope.xdr() return envelope_xdr
async def create_payout_xdr(payout_info, start_date, end_date, src_wallet, write_directory, digital_service_id_kin_2, kin_2_amount, sequence_increment = 0): operations = [] for ix, row in payout_info.iterrows(): if row['digital_service_id'] == digital_service_id_kin_2: amt = str(round(row['total_payout'], 2) - kin_2_amount) else: amt = str(round(row['total_payout'], 2)) payment_op = Payment( destination=row['wallet'], amount=amt, asset=Asset.native() ) operations.append(payment_op) async with Horizon(horizon_uri='https://horizon.kinfederation.com') as horizon: total_fee = len(payout_info.index) * 100 network_id = "PUBLIC" account_result = await horizon.account(src_wallet) sequence = int(account_result['sequence']) + 1 tx = Transaction( source = src_wallet, sequence = int(sequence) + sequence_increment, time_bounds = {'minTime': 0, 'maxTime': 0}, fee = total_fee, operations = operations, memo = None ) envelope = Te(tx=tx, network_id="PUBLIC") xdr = envelope.xdr() f = open(write_directory + "/xdr" + str(sequence_increment) + ".xdr", "w") f.write(xdr.decode("utf-8")) f.close() print(xdr.decode("utf-8"))
set_home_domain_op = SetOptions(home_domain='fed.network') # create a memo msg = TextMemo('Buy yourself a beer!') # get sequence of Alice # Python 3 sequence = horizon.account(Alice.address().decode('utf-8')).get('sequence') # Python 2 # sequence = horizon.account(Alice.address()).get('sequence') operations = [payment_op, set_home_domain_op] # construct Tx tx = Transaction( source=Alice.address().decode(), sequence=int(sequence), # time_bounds = {'minTime': 1531000000, 'maxTime': 1531234600}, memo=msg, fee=100 * len(operations), operations=operations, ) # build envelope envelope = Te(tx=tx, network_id="TESTNET") # envelope = Te(tx=tx, network_id="PUBLIC") for LIVENET # sign envelope.sign(Alice) # submit xdr = envelope.xdr() response = horizon.submit(xdr) print(response)