update code

This commit is contained in:
ddawson
2023-06-21 12:12:33 -07:00
parent dc0e3ca191
commit a0fef7a975
12 changed files with 644 additions and 388 deletions

View File

@@ -11,68 +11,75 @@ testnet_url = "https://s.altnet.rippletest.net:51234"
# create_trust_line #
#####################
def create_trust_line(_seed, _issuer, _currency, _amount):
def create_trust_line(seed, issuer, currency, amount):
"""create_trust_line"""
# Get the client
receiving_wallet = Wallet(_seed, sequence = 16237283)
receiving_wallet = Wallet(seed, sequence = 16237283)
client = JsonRpcClient(testnet_url)
# Define the trust line transaction
trustline_tx = xrpl.models.transactions.TrustSet(
account = receiving_wallet.classic_address,
limit_amount = xrpl.models.amounts.IssuedCurrencyAmount(
currency = _currency,
issuer = _issuer,
value = int(_amount)
trustline_tx=xrpl.models.transactions.TrustSet(
account=receiving_wallet.classic_address,
limit_amount=xrpl.models.amounts.IssuedCurrencyAmount(
currency=currency,
issuer=issuer,
value=int(amount)
)
)
# Sign and fill the transaction
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
trustline_tx, receiving_wallet, client)
trustline_tx, receiving_wallet, client)
# Submit the transaction and get results
reply = ""
try:
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
reply = response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
response = f"Submit failed: {e}"
return response.result
reply = f"Submit failed: {e}"
return reply
#################
# send_currency #
#################
def send_currency(_seed, _destination, _currency, _amount):
def send_currency(seed, destination, currency, amount):
"""send_currency"""
# Get the client
sending_wallet = Wallet(_seed, sequence = 16237283)
client = JsonRpcClient(testnet_url)
sending_wallet=Wallet(seed, sequence=16237283)
client=JsonRpcClient(testnet_url)
# Define the payment transaction.
send_currency_tx = xrpl.models.transactions.Payment(
account = sending_wallet.classic_address,
amount = xrpl.models.amounts.IssuedCurrencyAmount(
currency = _currency,
value = int(_amount),
issuer = sending_wallet.classic_address
send_currency_tx=xrpl.models.transactions.Payment(
account=sending_wallet.classic_address,
amount=xrpl.models.amounts.IssuedCurrencyAmount(
currency=currency,
value=int(amount),
issuer=sending_wallet.classic_address
),
destination=_destination
destination=destination
)
# Sign and fill the transaction
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
send_currency_tx, sending_wallet, client)
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
send_currency_tx, sending_wallet, client)
# Submit the transaction and get results
reply = ""
try:
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
response=xrpl.transaction.send_reliable_submission(signed_tx,client)
reply = response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
response = f"Submit failed: {e}"
return response.result
reply = f"Submit failed: {e}"
return reply
###############
# get_balance #
###############
def get_balance(_sb_account_id, _op_account_id):
JSON_RPC_URL = 'wss://s.altnet.rippletest.net:51234'
client = JsonRpcClient(JSON_RPC_URL)
balance = xrpl.models.requests.GatewayBalances(
account=_sb_account_id,
def get_balance(sb_account_id, op_account_id):
"""get_balance"""
JSON_RPC_URL='wss://s.altnet.rippletest.net:51234'
client=JsonRpcClient(JSON_RPC_URL)
balance=xrpl.models.requests.GatewayBalances(
account=sb_account_id,
ledger_index="validated",
hotwallet=[_op_account_id]
hotwallet=[op_account_id]
)
response = client.request(balance)
return response.result
@@ -81,29 +88,32 @@ def get_balance(_sb_account_id, _op_account_id):
# configure_account #
#####################
def configure_account(_seed, _default_setting):
def configure_account(seed, default_setting):
"""configure_account"""
# Get the client
wallet = Wallet(_seed, sequence = 16237283)
client = JsonRpcClient(testnet_url)
wallet=Wallet(seed, sequence = 16237283)
client=JsonRpcClient(testnet_url)
# Create transaction
if (_default_setting.get()):
setting_tx = xrpl.models.transactions.AccountSet(
account = wallet.classic_address,
if (default_setting):
setting_tx=xrpl.models.transactions.AccountSet(
account=wallet.classic_address,
set_flag=xrpl.models.transactions.AccountSetFlag.ASF_DEFAULT_RIPPLE
)
else:
setting_tx = xrpl.models.transactions.AccountSet(
account = wallet.classic_address,
clear_flag = xrpl.models.transactions.AccountSetFlag.ASF_DEFAULT_RIPPLE
setting_tx=xrpl.models.transactions.AccountSet(
account=wallet.classic_address,
clear_flag=xrpl.models.transactions.AccountSetFlag.ASF_DEFAULT_RIPPLE
)
# Sign and fill the transaction
signed_tx = xrpl.transaction.safe_sign_and_autofill_transaction(
setting_tx, wallet, client)
signed_tx=xrpl.transaction.safe_sign_and_autofill_transaction(
setting_tx, wallet, client)
# Submit the transaction and get results
reply = ""
try:
response = xrpl.transaction.send_reliable_submission(signed_tx,client)
reply = response.result
except xrpl.transaction.XRPLReliableSubmissionException as e:
response.result = f"Submit failed: {e}"
return response.result
reply = f"Submit failed: {e}"
return reply