mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 11:45:50 +00:00
Improvements on writing style, implementation & output
This commit is contained in:
@@ -1,37 +1,46 @@
|
||||
from xrpl.clients import JsonRpcClient
|
||||
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.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
|
||||
test_wallet = generate_faucet_wallet(client=client)
|
||||
myAddr = test_wallet.classic_address
|
||||
if __name__ == "__main__":
|
||||
# Connect to a testnet node
|
||||
print("Connecting to Testnet...")
|
||||
JSON_RPC_URL = "https://s.altnet.rippletest.net:51234/"
|
||||
client = JsonRpcClient(JSON_RPC_URL)
|
||||
|
||||
# Construct AccountSet transaction
|
||||
tx = AccountSet(
|
||||
account=myAddr,
|
||||
set_flag=1 # Numerical Value: 1 = asfRequireDest
|
||||
)
|
||||
# Generate a wallet and request faucet
|
||||
print("Requesting address from the Testnet faucet...")
|
||||
test_wallet = generate_faucet_wallet(client=client)
|
||||
myAddr = test_wallet.classic_address
|
||||
|
||||
# Sign the transaction locally and submit to a node
|
||||
my_tx_payment_signed = safe_sign_and_submit_transaction(tx, wallet=test_wallet, client=client)
|
||||
my_tx_payment_signed = my_tx_payment_signed.result["engine_result"]
|
||||
# Construct AccountSet transaction
|
||||
tx = AccountSet(
|
||||
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
|
||||
get_acc_flag = AccountInfo(
|
||||
account=myAddr
|
||||
)
|
||||
print(f"Enabling Require Destination Tag flag (asfRequireDest) on {myAddr}")
|
||||
submit_transaction = submit_transaction(client=client, transaction=my_tx_payment_signed)
|
||||
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:
|
||||
print("Require Destination Tag is enabled.")
|
||||
else:
|
||||
print("Require Destination Tag is DISABLED.")
|
||||
# Verify Account Settings
|
||||
get_acc_flag = AccountInfo(
|
||||
account=myAddr
|
||||
)
|
||||
|
||||
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.")
|
||||
|
||||
Reference in New Issue
Block a user