This commit is contained in:
Wo Jake
2022-09-05 07:50:27 +00:00
committed by GitHub
parent b581f53728
commit c43c5445d4

View File

@@ -1,16 +1,12 @@
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_transaction, send_reliable_submission from xrpl.transaction import safe_sign_and_autofill_transaction, send_reliable_submission
from xrpl.account import get_next_valid_seq_number
from xrpl.ledger import get_latest_validated_ledger_sequence
from xrpl.wallet import Wallet from xrpl.wallet import Wallet
from xrpl.core import keypairs
myAddr = "r31FLxNkfFJwRXbJw82RYB6Fa7jmfA3ix1" myAddr = "rM4vA4uRpc2MtCoc4vdhhTwWqsWcncwaLL"
mySeed = "sn51LT5QeaPYhjM1HL9-----------" mySeed = "ssJ4QYQLXomJLSKBT----------"
# Derive and initialize wallet # Derive and initialize wallet
public, private = keypairs.derive_keypair(mySeed)
wallet_from_seed = Wallet(mySeed, 0) wallet_from_seed = Wallet(mySeed, 0)
# Connect to a testnet node # Connect to a testnet node
@@ -19,14 +15,12 @@ client = JsonRpcClient(JSON_RPC_URL)
# Construct AccountSet transaction # Construct AccountSet transaction
tx = AccountSet( tx = AccountSet(
account=myAddr, account=myAddr
fee="10",
sequence=get_next_valid_seq_number(address=myAddr, client=client),
last_ledger_sequence=get_latest_validated_ledger_sequence(client=client)+20,
) )
# Sign the transaction locally & submit transaction and verify its validity on the ledger # Sign the transaction locally
my_tx_payment_signed = safe_sign_transaction(transaction=tx, wallet=wallet_from_seed) my_tx_payment_signed = safe_sign_and_autofill_transaction(transaction=tx, wallet=wallet_from_seed, client=client)
# Submit transaction and verify its validity on the ledger
response = send_reliable_submission(transaction=my_tx_payment_signed, client=client) response = send_reliable_submission(transaction=my_tx_payment_signed, client=client)
result = response.result["meta"]["TransactionResult"] result = response.result["meta"]["TransactionResult"]