Fixes & Improvements

This commit is contained in:
Wo Jake
2022-11-15 09:54:12 +00:00
committed by GitHub
parent 9a0de3d622
commit d89160b363

View File

@@ -31,6 +31,7 @@ def create_wallet():
return address, seed return address, seed
def sign_transaction(_xrp_amount, _destination, _ledger_seq, _wallet_seq, password): def sign_transaction(_xrp_amount, _destination, _ledger_seq, _wallet_seq, password):
""" """
Signs transaction and returns signed transaction blob in QR code Signs transaction and returns signed transaction blob in QR code
@@ -56,8 +57,6 @@ def sign_transaction(_xrp_amount, _destination, _ledger_seq, _wallet_seq, passwo
# Decrypts the wallet's private key # Decrypts the wallet's private key
_seed = crypt.decrypt(_seed) _seed = crypt.decrypt(_seed)
# Initialize XRPL wallet using decrypted private key
_wallet = wallet.Wallet(seed=_seed.decode(), sequence=0) _wallet = wallet.Wallet(seed=_seed.decode(), sequence=0)
validated_seq = _ledger_seq validated_seq = _ledger_seq
@@ -68,7 +67,8 @@ def sign_transaction(_xrp_amount, _destination, _ledger_seq, _wallet_seq, passwo
account=_wallet.classic_address, account=_wallet.classic_address,
amount=xrp_to_drops(xrp=_xrp_amount), amount=xrp_to_drops(xrp=_xrp_amount),
destination=_destination, destination=_destination,
last_ledger_sequence=validated_seq + 100, # +100 to catch up with the ledger when we transmit the signed tx blob to Machine 2 last_ledger_sequence=validated_seq + 100,
# +100 to catch up with the ledger when we transmit the signed tx blob to Machine 2
sequence=_wallet.sequence, sequence=_wallet.sequence,
fee="10" fee="10"
) )
@@ -131,7 +131,8 @@ def main():
amount = float(input("\n Enter XRP To Send: ")) amount = float(input("\n Enter XRP To Send: "))
destination = input("\n Enter Destination: ") destination = input("\n Enter Destination: ")
wallet_sequence = int(input("\n Enter Wallet Sequence: ")) wallet_sequence = int(input("\n Enter Wallet Sequence: "))
ledger_sequence = int(input("\n Enter Ledger Sequence: ")) ledger_sequence = int(input("Look up the latest ledger sequence on testnet.xrpl.org and enter it below!"
"\n Enter Ledger Sequence: "))
sign_transaction(_xrp_amount=amount, sign_transaction(_xrp_amount=amount,
_destination=destination, _destination=destination,
@@ -143,7 +144,7 @@ def main():
del destination, amount, wallet_sequence, ledger_sequence del destination, amount, wallet_sequence, ledger_sequence
if ask == 2: if ask == 2:
_pub, _priv, _seed = create_wallet() _pub, _seed = create_wallet()
if ask == 3: if ask == 3:
with open(get_path("/Wallet/public.txt"), "r") as f: with open(get_path("/Wallet/public.txt"), "r") as f:
@@ -154,15 +155,12 @@ def main():
else: else:
# If the Wallet's folder does not exist, create one and store wallet data (encrypted private key, encrypted seed, account address) # If the Wallet's folder does not exist, create one and store wallet data (encrypted private key, encrypted seed, account address)
pub, priv, seed = create_wallet() pub, seed = create_wallet()
os.makedirs(File) os.makedirs(File)
img = qrcode.make(pub) img = qrcode.make(pub)
img.save(get_path("/Wallet/public.png")) img.save(get_path("/Wallet/public.png"))
openimg = Image.open(get_path("/Wallet/public.png"))
openimg.show()
password = str(input("\n Enter Password: ")) password = str(input("\n Enter Password: "))
salt = os.urandom(16) salt = os.urandom(16)
@@ -193,6 +191,9 @@ def main():
with open(get_path("/Wallet/public.txt"), "w") as f: with open(get_path("/Wallet/public.txt"), "w") as f:
f.write(pub) f.write(pub)
openimg = Image.open(get_path("/Wallet/public.png"))
openimg.show()
print("Re-run this script!") print("Re-run this script!")