def test_pathPayment_min(self, setup): result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAZAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAQAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAAAIAAAAAAAAAAACYloAAAAAAra4WiCvFr/vydTiUbSQF0HwkqErP8wc6BUQav3qSQI4AAAAAAAAAAACYloAAAAAAAAAAAAAAAAHNPhNjAAAAQI1tBUmMqDa497gw9JJVgucfaiKr2e8VNWg/Pw9jM1d9qNWHBvEHxTLtBDyFKuJEguV1KVS7vBjFznlVCnKC3AI=' assert (result == self.do( setup.network, op=PathPayment( source=self.source, destination=self.dest, send_asset=Asset.native(), dest_asset=Asset.native(), send_max=self.amount, dest_amount=self.amount, path=[], )))
def test_pathPayment_min(self, setup): result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAZAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAQAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAAAIAAAAAAAAAAAABhqAAAAAAra4WiCvFr/vydTiUbSQF0HwkqErP8wc6BUQav3qSQI4AAAAAAAAAAAABhqAAAAAAAAAAAAAAAAHNPhNjAAAAQGWG1c11+P5HUofw6Wm0X1JpLtlTUA/z3keudcwVFBt0rjqi2xNHcBdon2yeVDrAdJy6ekEfUIrSW+WopWlUlAw=' generated_result = self.do( setup.network, op=PathPayment( source=self.source, destination=self.dest, send_asset=Asset.native(), dest_asset=Asset.native(), send_max=self.amount, dest_amount=self.amount, path=[], )) assert result == generated_result
def test_double_payment(self, setup): result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAyAAAAAAAAAACAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAlMoegcSS0iHsTrJ5XNJH1ri4rO05uVmRHX6dbOj22fgAAAAAAAAAAAvrwgAAAAAAAAAAAQAAAABNqbPPMcFohrLf2BM4UPn/CB/t1jVq0x9DBET5ki/XaAAAAAAAAAAAF9eEAAAAAAAAAAABzT4TYwAAAEAC/EENKQWCZFsKcNMEpWi7TVstQF0JbmBj/+QwkQXW8q/isCHX+UikrhxXJpI5NDKdagnH0godVShWxK1PENAC' assert (result == self.make_envelope( setup.network, Payment( destination=self.accounts[0]['address'], asset=Asset.native(), amount=self.amount, ), Payment( destination=self.accounts[1]['address'], asset=Asset.native(), amount="40", ), ))
def test_double_payment(self, setup): result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAyAAAAAAAAAACAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAlMoegcSS0iHsTrJ5XNJH1ri4rO05uVmRHX6dbOj22fgAAAAAAAAAAAAehIAAAAAAAAAAAQAAAABNqbPPMcFohrLf2BM4UPn/CB/t1jVq0x9DBET5ki/XaAAAAAAAAAAAAD0JAAAAAAAAAAABzT4TYwAAAEB5lgq+jygYUAHyPNvDyhImdNJEInQ1H3dkWOMNX9x7s99Us+o23nx2yWDQAJcDOFMgwM2tbaFKijY3HQEopigI' generated_result = self.make_envelope( setup.network, Payment( destination=self.accounts[0]['address'], asset=Asset.native(), amount=self.amount, ), Payment( destination=self.accounts[1]['address'], asset=Asset.native(), amount="40", ), ) assert result == generated_result
def test_payment_min(self, setup): result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAZAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAQAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAAAEAAAAAra4WiCvFr/vydTiUbSQF0HwkqErP8wc6BUQav3qSQI4AAAAAAAAAAACYloAAAAAAAAAAAc0+E2MAAABAlw7SoaRvm53xhs7ztskutJ3MlhBJ0ME2+uSBLiSCNV+wSolCAIIlWlMF376ciT5V9J6iWMcW1hVrZAQSI4cjDw==' assert (result == self.do( setup.network, op=Payment( source=self.source, destination=self.dest, asset=Asset.native(), amount=self.amount, )))
def test_mix_1(self, setup): result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAADhAAAAAAAAAACAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAlMoegcSS0iHsTrJ5XNJH1ri4rO05uVmRHX6dbOj22fgAAAAAAB6EgAAAAAAAAAABAAAAAE2ps88xwWiGst/YEzhQ+f8IH+3WNWrTH0MERPmSL9doAAAAAAAAAAAAHoSAAAAAAAAAAAIAAAAAAAAAAAAehIAAAAAAoEATyhnfBjtgSGL5Fr4oHlw/X4bIYnH44zIpor2MQbUAAAAAAAAAAAAehIAAAAAAAAAAAAAAAAMAAAABYmVlcgAAAACUyh6BxJLSIexOsnlc0kfWuLis7Tm5WZEdfp1s6PbZ+AAAAAFiZWVyAAAAAE2ps88xwWiGst/YEzhQ+f8IH+3WNWrTH0MERPmSL9doAAAAAACYloAABMsvAAGGoAAAAAAAAAABAAAAAAAAAAQAAAABYmVlcgAAAABNqbPPMcFohrLf2BM4UPn/CB/t1jVq0x9DBET5ki/XaAAAAAFiZWVyAAAAAKBAE8oZ3wY7YEhi+Ra+KB5cP1+GyGJx+OMyKaK9jEG1AAAAAACYloAABMsvAAGGoAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAABYmVlcgAAAACUyh6BxJLSIexOsnlc0kfWuLis7Tm5WZEdfp1s6PbZ+H//////////AAAAAAAAAAcAAAAAlMoegcSS0iHsTrJ5XNJH1ri4rO05uVmRHX6dbOj22fgAAAABYmVlcgAAAAEAAAAAAAAACAAAAACUyh6BxJLSIexOsnlc0kfWuLis7Tm5WZEdfp1s6PbZ+AAAAAAAAAABzT4TYwAAAEA2ATIf8i+oHGbZqbzRrz9la4N83uIIvlkDwzvSG3P9IQnDnmu3SsvmmE62ldxqLAOmkNDzsARFno2ki3ZS8jIE' generated_result = self.make_envelope( setup.network, CreateAccount( destination=self.accounts[0]['address'], starting_balance=self.amount, ), Payment( destination=self.accounts[1]['address'], asset=Asset.native(), amount=self.amount, ), PathPayment( destination=self.accounts[2]['address'], send_asset=Asset.native(), dest_asset=Asset.native(), send_max=self.amount, dest_amount=self.amount, path=[], ), ManageOffer( selling=Asset('beer', self.accounts[0]['address']), buying=Asset('beer', self.accounts[1]['address']), amount="100", price=3.14159, offer_id=1, ), CreatePassiveOffer( selling=Asset('beer', self.accounts[1]['address']), buying=Asset('beer', self.accounts[2]['address']), amount="100", price=3.14159, ), SetOptions(), ChangeTrust( asset=Asset('beer', self.accounts[0]['address']), ), AllowTrust( trustor=self.accounts[0]['address'], asset_code='beer', authorize=True, ), AccountMerge(destination=self.accounts[0]['address'], )) assert result == generated_result
def test_payment_min(self, setup): result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAAAZAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAQAAAADTUozdcK3X4scPuMNM5il78cYpIOhCjIvUltQ5zT4TYwAAAAEAAAAAra4WiCvFr/vydTiUbSQF0HwkqErP8wc6BUQav3qSQI4AAAAAAAAAAAABhqAAAAAAAAAAAc0+E2MAAABA38jqPW3m8yeamMmzG65hUsjz5PqJwi4zW5LwOcs7vJVk+lPGOSpG5Qvbe0m7eZN9glfZQRfj5UYyB6bWJgxXAw==' generated_result = self.do( setup.network, op=Payment( source=self.source, destination=self.dest, asset=Asset.native(), amount=self.amount, )) assert result == generated_result
def test_mix_1(self, setup): result = b'AAAAANNSjN1wrdfixw+4w0zmKXvxxikg6EKMi9SW1DnNPhNjAAADhAAAAAAAAAACAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAlMoegcSS0iHsTrJ5XNJH1ri4rO05uVmRHX6dbOj22fgAAAAAC+vCAAAAAAAAAAABAAAAAE2ps88xwWiGst/YEzhQ+f8IH+3WNWrTH0MERPmSL9doAAAAAAAAAAAL68IAAAAAAAAAAAIAAAAAAAAAAAvrwgAAAAAAoEATyhnfBjtgSGL5Fr4oHlw/X4bIYnH44zIpor2MQbUAAAAAAAAAAAvrwgAAAAAAAAAAAAAAAAMAAAABYmVlcgAAAACUyh6BxJLSIexOsnlc0kfWuLis7Tm5WZEdfp1s6PbZ+AAAAAFiZWVyAAAAAE2ps88xwWiGst/YEzhQ+f8IH+3WNWrTH0MERPmSL9doAAAAADuaygAABMsvAAGGoAAAAAAAAAABAAAAAAAAAAQAAAABYmVlcgAAAABNqbPPMcFohrLf2BM4UPn/CB/t1jVq0x9DBET5ki/XaAAAAAFiZWVyAAAAAKBAE8oZ3wY7YEhi+Ra+KB5cP1+GyGJx+OMyKaK9jEG1AAAAADuaygAABMsvAAGGoAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAABYmVlcgAAAACUyh6BxJLSIexOsnlc0kfWuLis7Tm5WZEdfp1s6PbZ+H//////////AAAAAAAAAAcAAAAAlMoegcSS0iHsTrJ5XNJH1ri4rO05uVmRHX6dbOj22fgAAAABYmVlcgAAAAEAAAAAAAAACAAAAACUyh6BxJLSIexOsnlc0kfWuLis7Tm5WZEdfp1s6PbZ+AAAAAAAAAABzT4TYwAAAEAY0YGZzC1qiKatKCWaCttK1fEs3P4DpVWw2AQCdvVBS4dkCyfxu7N7tpQPEZ4WqXzAiR0D7r5L6f848pmNsgIL' assert (result == self.make_envelope( setup.network, CreateAccount( destination=self.accounts[0]['address'], starting_balance=self.amount, ), Payment( destination=self.accounts[1]['address'], asset=Asset.native(), amount=self.amount, ), PathPayment( destination=self.accounts[2]['address'], send_asset=Asset.native(), dest_asset=Asset.native(), send_max=self.amount, dest_amount=self.amount, path=[], ), ManageOffer( selling=Asset('beer', self.accounts[0]['address']), buying=Asset('beer', self.accounts[1]['address']), amount="100", price=3.14159, offer_id=1, ), CreatePassiveOffer( selling=Asset('beer', self.accounts[1]['address']), buying=Asset('beer', self.accounts[2]['address']), amount="100", price=3.14159, ), SetOptions(), ChangeTrust( asset=Asset('beer', self.accounts[0]['address']), ), AllowTrust( trustor=self.accounts[0]['address'], asset_code='beer', authorize=True, ), AccountMerge(destination=self.accounts[0]['address'], )))
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"))
def test_native(self): assert 'XLM' == Asset.native().code assert Asset.native().issuer is None assert 'native' == Asset.native().type
def _load_operations(): amount = "1" return [("create_account_min", CreateAccount(source=SOURCE, destination=DEST, starting_balance=amount)), ("payment_min", Payment( source=SOURCE, destination=DEST, asset=Asset.native(), amount=amount, )), ("payment_short_asset", Payment( source=SOURCE, destination=DEST, asset=Asset('USD4', SOURCE), amount=amount, )), ("payment_long_asset", Payment( source=SOURCE, destination=DEST, asset=Asset('SNACKS789ABC', SOURCE), amount=amount, )), ("path_payment_min", PathPayment( source=SOURCE, destination=DEST, send_asset=Asset.native(), dest_asset=Asset.native(), send_max=amount, dest_amount=amount, path=[], )), ("allow_trust_short_asset", AllowTrust( source=SOURCE, trustor=DEST, asset_code='beer', authorize=True, )), ("allow_trust_long_asset", AllowTrust( source=SOURCE, trustor=DEST, asset_code='pocketknives', authorize=True, )), ("manage_offer_min", ManageOffer( selling=Asset('beer', SOURCE), buying=Asset('beer', DEST), amount="100", price=3.14159, offer_id=1, )), ("manage_offer_dict_price", ManageOffer( selling=Asset('beer', SOURCE), buying=Asset('beer', DEST), amount="100", price={ 'n': 314159, 'd': 100000 }, offer_id=1, )), ("create_passive_offer_min", CreatePassiveOffer( selling=Asset('beer', SOURCE), buying=Asset('beer', DEST), amount="100", price=3.14159, )), ("set_options_empty", SetOptions()), ("change_trust_min", ChangeTrust(source=SOURCE, asset=Asset('beer', DEST), limit='100')), ("change_trust_default_limit", ChangeTrust(source=SOURCE, asset=Asset('beer', DEST))), ("account_merge_min", AccountMerge( source=SOURCE, destination=DEST, )), ("inflation", Inflation(source=SOURCE)), ("manage_data", ManageData( source=SOURCE, data_name='1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY', data_value=SOURCE, )), ("bump_sequence", BumpSequence(bump_to=23333114514))]