Wallet tutorial: docs thru step 5

This commit is contained in:
mDuo13
2022-01-20 17:21:24 -08:00
parent 4dba0cf70f
commit 0dd06fac41
14 changed files with 218 additions and 26 deletions

View File

@@ -1,4 +1,6 @@
# "Build a Wallet" tutorial, step 1: slightly more than "Hello World"
# This step demonstrates a simple GUI and XRPL connectivity.
# License: MIT. https://github.com/XRPLF/xrpl-dev-portal/blob/master/LICENSE
import xrpl
import wx

View File

@@ -1,4 +1,7 @@
# "Build a Wallet" tutorial, step 2: Watch ledger closes from a worker thread.
# This step builds an app architecture that keeps the GUI responsive while
# showing realtime updates to the XRP Ledger.
# License: MIT. https://github.com/XRPLF/xrpl-dev-portal/blob/master/LICENSE
import xrpl
import wx

View File

@@ -1,4 +1,7 @@
# "Build a Wallet" tutorial, step 3: Take account input & show account info
# This step demonstrates how to parse user input into account information and
# look up that information on the XRP Ledger.
# License: MIT. https://github.com/XRPLF/xrpl-dev-portal/blob/master/LICENSE
import xrpl
import wx

View File

@@ -1,4 +1,8 @@
# "Build a Wallet" tutorial, step 4: Show transaction history
# This step adds a tab that summarizes transactions the user's account has been
# affected by recently, including transactions sent, received, or otherwise
# impacting the user's account.
# License: MIT. https://github.com/XRPLF/xrpl-dev-portal/blob/master/LICENSE
import xrpl
import wx
@@ -310,8 +314,7 @@ class TWaXLFrame(wx.Frame):
if reserve_xrp != None:
self.st_reserve.SetLabel(str(reserve_xrp))
@staticmethod
def displayable_amount(a):
def displayable_amount(self, a):
"""
Convert an arbitrary amount value from the XRPL to a string to be
displayed to the user:

View File

@@ -1,5 +1,7 @@
# "Build a Wallet" tutorial, step 5: Send XRP button.
# This step finally introduces events from the GUI to the worker thread.
# This step allows the user to send XRP payments, with a pop-up dialog to enter
# the relevant details.
# License: MIT. https://github.com/XRPLF/xrpl-dev-portal/blob/master/LICENSE
import xrpl
import wx
@@ -98,9 +100,15 @@ class XRPLMonitorThread(Thread):
async def send_xrp(self, paydata):
"""
Prepare, sign, and send an XRP payment with the provided parameters.
Expects a dictionary with:
{
"dtag": Destination Tag, as a string, optional
"to": Destination address (classic or X-address)
"amt": Amount of decimal XRP to send, as a string
}
"""
dtag = paydata.get("dtag")
if dtag.strip() == "":
if dtag and dtag.strip() == "":
dtag = None
if dtag is not None:
try:
@@ -180,12 +188,22 @@ class SendXRPDialog(wx.Dialog):
self.txt_dtag.Bind(wx.EVT_TEXT, self.on_dest_tag_edit)
self.txt_to.Bind(wx.EVT_TEXT, self.on_to_edit)
def get_payment_data(self):
"""
Construct a dictionary with the relevant payment details to pass to the
worker thread for making a payment. Called after the user clicks "Send".
"""
return {
"to": self.txt_to.GetValue().strip(),
"dtag": self.txt_dtag.GetValue().strip(),
"amt": self.txt_amt.GetValue(),
}
def on_to_edit(self, event):
"""
When the user edits the "To" field, check that the address is well-
formatted. If it's an X-address, fill in the destination tag and disable
it. Also, start a background check to confirm more details about the
address.
it.
"""
v = self.txt_to.GetValue().strip()
@@ -207,17 +225,6 @@ class SendXRPDialog(wx.Dialog):
self.txt_dtag.ChangeValue(v) # SetValue would generate another EVT_TEXT
self.txt_dtag.SetInsertionPointEnd()
def get_payment_data(self):
"""
Construct a dictionary with the relevant payment details to pass to the
worker thread for making a payment. Called after the user clicks "Send".
"""
return {
"to": self.txt_to.GetValue().strip(),
"dtag": self.txt_dtag.GetValue().strip(),
"amt": self.txt_amt.GetValue(),
}
class TWaXLFrame(wx.Frame):
"""
@@ -432,8 +439,7 @@ class TWaXLFrame(wx.Frame):
self.sxb.Enable()
self.sxb.SetToolTip("")
@staticmethod
def displayable_amount(a):
def displayable_amount(self, a):
"""
Convert an arbitrary amount value from the XRPL to a string to be
displayed to the user:

View File

@@ -1,6 +1,8 @@
# "Build a Wallet" tutorial, step 6: Verification and Polish
# This step adds sanity checks to the Send XRP dialog, along with some other
# small improvements.
# small improvements including account domain verification.
# License: MIT. https://github.com/XRPLF/xrpl-dev-portal/blob/master/LICENSE
import xrpl
import wx
import wx.dataview
@@ -155,6 +157,12 @@ class XRPLMonitorThread(Thread):
async def send_xrp(self, paydata):
"""
Prepare, sign, and send an XRP payment with the provided parameters.
Expects a dictionary with:
{
"dtag": Destination Tag, as a string, optional
"to": Destination address (classic or X-address)
"amt": Amount of decimal XRP to send, as a string
}
"""
dtag = paydata.get("dtag")
if dtag.strip() == "":
@@ -582,8 +590,7 @@ class TWaXLFrame(wx.Frame):
self.sxb.Enable()
self.sxb.SetToolTip("")
@staticmethod
def displayable_amount(a):
def displayable_amount(self, a):
"""
Convert an arbitrary amount value from the XRPL to a string to be
displayed to the user:

View File

@@ -1,3 +1,7 @@
# Domain verification of XRP Ledger accounts using xrp-ledger.toml file.
# For information on this process, see:
# https://xrpl.org/xrp-ledger-toml.html#account-verification
# License: MIT. https://github.com/XRPLF/xrpl-dev-portal/blob/master/LICENSE
import requests
import toml