-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
55 lines (43 loc) · 1.69 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from flask import Flask, redirect
from flask import render_template, request
from stellar_base.keypair import Keypair
from stellar_base.asset import Asset
from stellar_base.horizon import horizon_testnet
from stellar_base.operation import ChangeTrust
import json
import requests
app = Flask(__name__)
@app.route("/gen_address")
def gen_address():
kp = Keypair.random()
publickey = kp.address().decode()
seed = kp.seed().decode()
return json.dumps({'publickey': publickey, 'seed': seed})
def fund_account(address):
r = requests.get('https://horizon-testnet.stellar.org/friendbot?addr=' + address)
return r.text
def create_asset(code, issuer_address):
asset = Asset(code, issuer_address)
return asset
def connect_horizon():
horizon = horizon_testnet()
return horizon
def opr_change_trust(asset_object, receiver_address, receiver_seed, horizon):
op = ChangeTrust({
'source': receiver_address,
'asset': asset_object,
'limit': '5000'
})
sequence = horizon.account(receiver_address).get('sequence')
print(sequence)
if __name__ == '__main__':
ISSUER_ADDRESS = 'GDKQWW4VYWIPWRGDFZO2DDMX7NNVCSB2T6AWFNT72XHMYZACAUYFGW66'
ISSUER_SEED = 'SAKIXIIAMGLKGZF2BSRUJHNE5ZAP6X7UWIUWCGU3LKP6CDRAJW7DFCNK'
# result = fund_account(ISSUER_ADDRESS)
ASSET_CODE = 'RAITCOIN'
CUSTOMER_ADDRESS = 'GDTZPBMS6FK7BLNOLTW5CLKLP2YOVWBX5S5P46HFVLRBASI34QMBN45F'
CUSTOMER_SEED = 'SDOWS44HIDFFNTOBDRL3OENAVKK7PW5AY3AUC4C2BYPZBWR5DZ2NSND2'
new_asset = create_asset(ASSET_CODE,ISSUER_ADDRESS)
result = fund_account(CUSTOMER_ADDRESS)
horizon = connect_horizon()
opr_change_trust(new_asset,CUSTOMER_ADDRESS,CUSTOMER_SEED, horizon)