Improvements on writing style, implementation & output

This commit is contained in:
Wo Jake
2022-09-08 14:04:51 +00:00
committed by GitHub
parent 8d21ab02c0
commit 40baf3e021

View File

@@ -1,37 +1,46 @@
from xrpl.clients import JsonRpcClient from xrpl.clients import JsonRpcClient
from xrpl.models.transactions import AccountSet from xrpl.models.transactions import AccountSet
from xrpl.transaction import safe_sign_and_submit_transaction from xrpl.transaction import safe_sign_and_autofill_transaction, submit_transaction
from xrpl.wallet import generate_faucet_wallet from xrpl.wallet import generate_faucet_wallet
from xrpl.models.requests import AccountInfo from xrpl.models.requests import AccountInfo
# Connect to a testnet node
JSON_RPC_URL = "https://s.altnet.rippletest.net:51234/"
client = JsonRpcClient(JSON_RPC_URL)
# Generate a wallet and request faucet if __name__ == "__main__":
test_wallet = generate_faucet_wallet(client=client) # Connect to a testnet node
myAddr = test_wallet.classic_address print("Connecting to Testnet...")
JSON_RPC_URL = "https://s.altnet.rippletest.net:51234/"
client = JsonRpcClient(JSON_RPC_URL)
# Construct AccountSet transaction # Generate a wallet and request faucet
tx = AccountSet( print("Requesting address from the Testnet faucet...")
account=myAddr, test_wallet = generate_faucet_wallet(client=client)
set_flag=1 # Numerical Value: 1 = asfRequireDest myAddr = test_wallet.classic_address
)
# Sign the transaction locally and submit to a node # Construct AccountSet transaction
my_tx_payment_signed = safe_sign_and_submit_transaction(tx, wallet=test_wallet, client=client) tx = AccountSet(
my_tx_payment_signed = my_tx_payment_signed.result["engine_result"] account=myAddr,
set_flag=1 # Numerical Value: 1 = asfRequireDest
)
print(f"Prepared transaction: {tx}")
print(f"Transaction result: {my_tx_payment_signed}") # Sign the transaction locally and submit to a node
my_tx_payment_signed = safe_sign_and_autofill_transaction(tx, wallet=test_wallet, client=client)
print(f"Transaction Hash: {my_tx_payment_signed.txn_signature}")
# Verify Account Settings print(f"Enabling Require Destination Tag flag (asfRequireDest) on {myAddr}")
get_acc_flag = AccountInfo( submit_transaction = submit_transaction(client=client, transaction=my_tx_payment_signed)
account=myAddr submit_transaction = submit_transaction.result["engine_result"]
)
response = client.request(get_acc_flag) print(f"Transaction result: {submit_transaction}!")
if response.result['account_data']['Flags'] == 131072: # Verify Account Settings
print("Require Destination Tag is enabled.") get_acc_flag = AccountInfo(
else: account=myAddr
print("Require Destination Tag is DISABLED.") )
response = client.request(get_acc_flag)
if response.result['account_data']['Flags'] == 131072:
print("Require Destination Tag is enabled.")
else:
print("Require Destination Tag is DISABLED.")