diff --git a/content/_code-samples/quickstart/py/lesson8-time-escrow.py b/content/_code-samples/quickstart/py/lesson8-time-escrow.py new file mode 100644 index 00000000000..0b25b539f0e --- /dev/null +++ b/content/_code-samples/quickstart/py/lesson8-time-escrow.py @@ -0,0 +1,251 @@ +import tkinter as tk +import xrpl +import json + +from mod1 import get_account, get_account_info, send_xrp +from mod8 import create_time_escrow, finish_time_escrow, get_escrows, cancel_time_escrow, get_transaction + + +############################################# +## Handlers ################################# +############################################# + +## Mod 8 Handlers + +def standby_create_time_escrow(): + results = create_time_escrow( + ent_standby_seed.get(), + ent_standby_amount.get(), + ent_standby_destination.get(), + ent_standby_escrow_finish.get(), + ent_standby_escrow_cancel.get() + ) + text_standby_results.delete("1.0", tk.END) + text_standby_results.insert("1.0", json.dumps(results, indent=4)) + +def operational_finish_time_escrow(): + results = finish_time_escrow( + ent_operational_seed.get(), + ent_operational_escrow_owner.get(), + ent_operational_sequence_number.get() + ) + text_operational_results.delete("1.0", tk.END) + text_operational_results.insert("1.0", json.dumps(results, indent=4)) + +def operational_get_escrows(): + results = get_escrows(ent_operational_account.get()) + text_operational_results.delete("1.0", tk.END) + text_operational_results.insert("1.0", json.dumps(results, indent=4)) + +def standby_cancel_time_escrow(): + results = cancel_time_escrow( + ent_standby_seed.get(), + ent_standby_escrow_owner.get(), + ent_standby_escrow_sequence_number.get() + ) + text_standby_results.delete("1.0", tk.END) + text_standby_results.insert("1.0", json.dumps(results, indent=4)) + +def operational_get_transaction(): + results = get_transaction(ent_operational_account.get(), + ent_operational_look_up.get()) + text_operational_results.delete("1.0", tk.END) + text_operational_results.insert("1.0", json.dumps(results, indent=4)) + +## Mod 1 Handlers + +def get_standby_account(): + new_wallet = get_account(ent_standby_seed.get()) + ent_standby_account.delete(0, tk.END) + ent_standby_seed.delete(0, tk.END) + ent_standby_account.insert(0, new_wallet.classic_address) + ent_standby_seed.insert(0, new_wallet.seed) + + +def get_standby_account_info(): + accountInfo = get_account_info(ent_standby_account.get()) + ent_standby_balance.delete(0, tk.END) + ent_standby_balance.insert(0,accountInfo['Balance']) + text_standby_results.delete("1.0", tk.END) + text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4)) + + +def standby_send_xrp(): + response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(), + ent_standby_destination.get()) + text_standby_results.delete("1.0", tk.END) + text_standby_results.insert("1.0",json.dumps(response.result, indent=4)) + get_standby_account_info() + get_operational_account_info() + + +def get_operational_account(): + new_wallet = get_account(ent_operational_seed.get()) + ent_operational_account.delete(0, tk.END) + ent_operational_account.insert(0, new_wallet.classic_address) + ent_operational_seed.delete(0, tk.END) + ent_operational_seed.insert(0, new_wallet.seed) + + +def get_operational_account_info(): + accountInfo = get_account_info(ent_operational_account.get()) + ent_operational_balance.delete(0, tk.END) + ent_operational_balance.insert(0,accountInfo['Balance']) + text_operational_results.delete("1.0", tk.END) + text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4)) + + +def operational_send_xrp(): + response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), + ent_operational_destination.get()) + text_operational_results.delete("1.0", tk.END) + text_operational_results.insert("1.0",json.dumps(response.result,indent=4)) + get_standby_account_info() + get_operational_account_info() + + +# Create a new window with the title "Time-based Escrow Example" +window = tk.Tk() +window.title("Time-based Escrow Example") + +# Form frame +frm_form = tk.Frame(relief=tk.SUNKEN, borderwidth=3) +frm_form.pack() + +# Create the Label and Entry widgets for "Standby Account" +lbl_standy_seed = tk.Label(master=frm_form, text="Standby Seed") +ent_standby_seed = tk.Entry(master=frm_form, width=50) +lbl_standby_account = tk.Label(master=frm_form, text="Standby Account") +ent_standby_account = tk.Entry(master=frm_form, width=50) +lbl_standy_amount = tk.Label(master=frm_form, text="Amount") +ent_standby_amount = tk.Entry(master=frm_form, width=50) +lbl_standby_destination = tk.Label(master=frm_form, text="Destination") +ent_standby_destination = tk.Entry(master=frm_form, width=50) +lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance") +ent_standby_balance = tk.Entry(master=frm_form, width=50) + +lbl_standby_escrow_finish = tk.Label(master=frm_form, text="Escrow Finish (seconds)") +ent_standby_escrow_finish = tk.Entry(master=frm_form, width=50) +lbl_standby_escrow_cancel = tk.Label(master=frm_form, text="Escrow Cancel (seconds)") +ent_standby_escrow_cancel = tk.Entry(master=frm_form, width=50) +lbl_standby_escrow_sequence_number = tk.Label(master=frm_form, text="Sequence Number") +ent_standby_escrow_sequence_number = tk.Entry(master=frm_form, width=50) +lbl_standby_escrow_owner = tk.Label(master=frm_form, text="Escrow Owner") +ent_standby_escrow_owner = tk.Entry(master=frm_form, width=50) +lbl_standby_results = tk.Label(master=frm_form, text="Results") +text_standby_results = tk.Text(master=frm_form, height = 20, width = 65) + +# Place fields in a grid. +lbl_standy_seed.grid(row=0, column=0, sticky="e") +ent_standby_seed.grid(row=0, column=1) +lbl_standby_account.grid(row=2, column=0, sticky="e") +ent_standby_account.grid(row=2, column=1) +lbl_standy_amount.grid(row=3, column=0, sticky="e") +ent_standby_amount.grid(row=3, column=1) +lbl_standby_destination.grid(row=4, column=0, sticky="e") +ent_standby_destination.grid(row=4, column=1) +lbl_standby_balance.grid(row=5, column=0, sticky="e") +ent_standby_balance.grid(row=5, column=1) +lbl_standby_escrow_finish.grid(row=6, column=0, sticky="e") +ent_standby_escrow_finish.grid(row=6, column=1) +lbl_standby_escrow_cancel.grid(row=7, column=0, sticky="e") +ent_standby_escrow_cancel.grid(row=7, column=1) +lbl_standby_escrow_sequence_number.grid(row=8, column=0, sticky="e") +ent_standby_escrow_sequence_number.grid(row=8, column=1) +lbl_standby_escrow_owner.grid(row=9, column=0, sticky="e") +ent_standby_escrow_owner.grid(row=9, column=1) +lbl_standby_results.grid(row=10, column=0, sticky="ne") +text_standby_results.grid(row=10, column=1, sticky="nw") + +############################################### +## Operational Account ######################## +############################################### + +# Create the Label and Entry widgets for "Operational Account" +lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed") +ent_operational_seed = tk.Entry(master=frm_form, width=50) +lbl_operational_account = tk.Label(master=frm_form, text="Operational Account") +ent_operational_account = tk.Entry(master=frm_form, width=50) +lbl_operational_amount = tk.Label(master=frm_form, text="Amount") +ent_operational_amount = tk.Entry(master=frm_form, width=50) +lbl_operational_destination = tk.Label(master=frm_form, text="Destination") +ent_operational_destination = tk.Entry(master=frm_form, width=50) +lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance") +ent_operational_balance = tk.Entry(master=frm_form, width=50) +lbl_operational_sequence_number = tk.Label(master=frm_form, text="Sequence Number") +ent_operational_sequence_number = tk.Entry(master=frm_form, width=50) +lbl_operational_escrow_owner=tk.Label(master=frm_form, text="Escrow Owner") +ent_operational_escrow_owner=tk.Entry(master=frm_form, width=50) +lbl_operational_look_up = tk.Label(master=frm_form, text="Transaction to Look Up") +ent_operational_look_up = tk.Entry(master=frm_form, width=50) +lbl_operational_results = tk.Label(master=frm_form,text='Results') +text_operational_results = tk.Text(master=frm_form, height = 20, width = 65) + + +#Place the widgets in a grid +lbl_operational_seed.grid(row=0, column=4, sticky="e") +ent_operational_seed.grid(row=0, column=5, sticky="w") +lbl_operational_account.grid(row=2,column=4, sticky="e") +ent_operational_account.grid(row=2,column=5, sticky="w") +lbl_operational_amount.grid(row=3, column=4, sticky="e") +ent_operational_amount.grid(row=3, column=5, sticky="w") +lbl_operational_destination.grid(row=4, column=4, sticky="e") +ent_operational_destination.grid(row=4, column=5, sticky="w") +lbl_operational_balance.grid(row=5, column=4, sticky="e") +ent_operational_balance.grid(row=5, column=5, sticky="w") +lbl_operational_sequence_number.grid(row=6, column=4, sticky="e") +ent_operational_sequence_number.grid(row=6, column=5, sticky="w") +lbl_operational_escrow_owner.grid(row=7, column=4, sticky="e") +ent_operational_escrow_owner.grid(row=7, column=5, sticky="w") +lbl_operational_look_up.grid(row=8, column=4, sticky="e") +ent_operational_look_up.grid(row=8, column=5, sticky="w") +lbl_operational_results.grid(row=10, column=4, sticky="ne") +text_operational_results.grid(row=10, column=5, sticky="nw") + +############################################# +## Buttons ################################## +############################################# + +# Create the Get Standby Account Buttons +btn_get_standby_account = tk.Button(master=frm_form, text="Get Standby Account", + command = get_standby_account) +btn_get_standby_account.grid(row = 0, column = 2, sticky = "nsew") +btn_get_standby_account_info = tk.Button(master=frm_form, + text="Get Standby Account Info", + command = get_standby_account_info) +btn_get_standby_account_info.grid(row = 1, column = 2, sticky = "nsew") +btn_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >", + command = standby_send_xrp) +btn_standby_send_xrp.grid(row = 2, column = 2, sticky = "nsew") + +btn_standby_create_escrow = tk.Button(master=frm_form, text="Create Time-based Escrow", + command = standby_create_time_escrow) +btn_standby_create_escrow.grid(row = 4, column = 2, sticky="nsew") +btn_standby_cancel_escrow = tk.Button(master=frm_form, text="Cancel Time-based Escrow", + command = standby_cancel_time_escrow) +btn_standby_cancel_escrow.grid(row=5,column = 2, sticky="nsew") + +# Create the Operational Account Buttons +btn_get_operational_account = tk.Button(master=frm_form, + text="Get Operational Account", + command = get_operational_account) +btn_get_operational_account.grid(row=0, column=3, sticky = "nsew") +btn_get_op_account_info = tk.Button(master=frm_form, text="Get Op Account Info", + command = get_operational_account_info) +btn_get_op_account_info.grid(row=1, column=3, sticky = "nsew") +btn_op_send_xrp = tk.Button(master=frm_form, text="< Send XRP", + command = operational_send_xrp) +btn_op_send_xrp.grid(row=2, column = 3, sticky = "nsew") +btn_op_finish_escrow = tk.Button(master=frm_form, text="Finish Escrow", + command = operational_finish_time_escrow) +btn_op_finish_escrow.grid(row = 4, column = 3, sticky="nsew") +btn_op_finish_escrow = tk.Button(master=frm_form, text="Get Escrows", + command = operational_get_escrows) +btn_op_finish_escrow.grid(row = 5, column = 3, sticky="nsew") +btn_op_get_transaction = tk.Button(master=frm_form, text="Get Transaction", + command = operational_get_transaction) +btn_op_get_transaction.grid(row = 6, column = 3, sticky = "nsew") + + +# Start the application +window.mainloop() diff --git a/content/_code-samples/quickstart/py/mod8.py b/content/_code-samples/quickstart/py/mod8.py new file mode 100644 index 00000000000..53e352926fb --- /dev/null +++ b/content/_code-samples/quickstart/py/mod8.py @@ -0,0 +1,92 @@ +import xrpl +from xrpl.clients import JsonRpcClient +from xrpl.wallet import Wallet +from datetime import datetime +from xrpl.models.transactions import EscrowCreate, EscrowFinish +from xrpl.models.requests import AccountObjects, AccountTx + +testnet_url = "https://s.altnet.rippletest.net:51234" + + +def add_seconds(numOfSeconds): + new_date = datetime.now() + if new_date != '': + new_date = xrpl.utils.datetime_to_ripple_time(new_date) + new_date = new_date + int(numOfSeconds) + return new_date + + +def create_time_escrow(seed, amount, destination, finish, cancel): + wallet=Wallet.from_seed(seed) + client=JsonRpcClient(testnet_url) + finish_date = add_seconds(finish) + cancel_date = add_seconds(cancel) + + escrow_tx=xrpl.models.transactions.EscrowCreate( + account=wallet.address, + amount=amount, + destination=destination, + finish_after=finish_date, + cancel_after=cancel_date + ) + # Submit the transaction and report the results + reply="" + try: + response=xrpl.transaction.submit_and_wait(escrow_tx,client,wallet) + reply=response.result + except xrpl.transaction.XRPLReliableSubmissionException as e: + reply=f"Submit failed: {e}" + return reply + +def finish_time_escrow(seed, owner, sequence): + wallet=Wallet.from_seed(seed) + client=JsonRpcClient(testnet_url) + finish_tx=xrpl.models.transactions.EscrowFinish( + account=wallet.address, + owner=owner, + offer_sequence=int(sequence) + ) + # Submit the transaction and report the results + reply="" + try: + response=xrpl.transaction.submit_and_wait(finish_tx,client,wallet) + reply=response.result + except xrpl.transaction.XRPLReliableSubmissionException as e: + reply=f"Submit failed: {e}" + return reply + +def get_escrows(account): + client=JsonRpcClient(testnet_url) + acct_escrows=AccountObjects( + account=account, + ledger_index="validated", + type="escrow" + ) + response=client.request(acct_escrows) + return response.result + +def cancel_time_escrow(seed, owner, sequence): + wallet=Wallet.from_seed(seed) + client=JsonRpcClient(testnet_url) + cancel_tx=xrpl.models.transactions.EscrowCancel( + account=wallet.address, + owner=owner, + offer_sequence=int(sequence) + ) + # Submit the transaction and report the results + reply="" + try: + response=xrpl.transaction.submit_and_wait(cancel_tx,client,wallet) + reply=response.result + except xrpl.transaction.XRPLReliableSubmissionException as e: + reply=f"Submit failed: {e}" + return reply + +def get_transaction(account, ledger_index): + client=JsonRpcClient(testnet_url) + tx_info=AccountTx( + account=account, + ledger_index=int(ledger_index) + ) + response=client.request(tx_info) + return response.result diff --git a/content/infrastructure/rippled/installation/build-on-linux-mac-windows.md b/content/infrastructure/rippled/installation/build-on-linux-mac-windows.md new file mode 100644 index 00000000000..85a6e117218 --- /dev/null +++ b/content/infrastructure/rippled/installation/build-on-linux-mac-windows.md @@ -0,0 +1,19 @@ +--- +html: build-on-linux-mac-windows.html +parent: install-rippled.html +blurb: Build rippled on Linux, Mac (macOS), or Windows +labels: + - Core Server + - Blockchain +top_nav_grouping: Popular Pages +--- +# Build rippled on Linux, Mac, or Windows + +Building `rippled` across various platforms such as Windows, Linux, or macOS requires a C++ development environment. You will need tools like Git, Python, Conan, CMake, and a suitable C++ compiler. + +To continue, proceed to [the latest `rippled` build instructions on GitHub](https://github.com/XRPLF/rippled/blob/develop/BUILD.md). + + +{% include '_snippets/rippled-api-links.md' %} +{% include '_snippets/tx-type-links.md' %} +{% include '_snippets/rippled_versions.md' %} diff --git a/content/tutorials/quickstart/py-create-time-based-escrows.md b/content/tutorials/quickstart/py-create-time-based-escrows.md new file mode 100644 index 00000000000..7ea2adc8237 --- /dev/null +++ b/content/tutorials/quickstart/py-create-time-based-escrows.md @@ -0,0 +1,637 @@ +--- +html: py-create-time-based-escrows.html +parent: send-payments-using-python.html +blurb: Create, finish, or cancel time-based escrow transactions. +labels: + - Accounts + - Quickstart + - Transaction Sending + - XRP +--- +# Create Time-based Escrows Using Python + +This example shows how to: + + +1. Create escrow payments that become available at a specified time and expire at a specified time. +2. Finish an escrow payment. +3. Retrieve information on escrows attached to an account. +3. Cancel an escrow payment and return the XRP to the sending account. + + +[![Escrow Tester Form](img/quickstart-py-escrow1.png)](img/quickstart-py-escrow1.png) + +## Prerequisites + +Download the [Python Modular Code Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/py/){.github-code-download}. + +## Usage + +To get test accounts: + +1. Open `lesson8-time-escrow.py.` +2. Get test accounts. + 1. If you have existing account seeds + 1. Paste Standby account seed in the **Standby Seed** field. + 2. Click **Get Standby Account**. + 3. Click **Get Standby Account Info**. + 4. Paste Operational account seed in the **Operational Seed** field. + 5. Click **Get Operational Account**. + 6. Click **Get Op Account Info**. + 2. If you do not have account seeds: + 1. Click **Get Standby Account**. + 2. Click **Get Standby Account Info**. + 3. Click **Get Operational Account**. + 4. Click **Get Op Account Info**. + +[![Escrow Tester with Account Information](img/quickstart-escrow2.png)](img/quickstart-py-escrow2.png) + +## Create Escrow + +
+ +
+ +You can create a time-based escrow with a minimum time to finish the escrow and a cancel time after which the funds in escrow are no longer available to the recipient. This is a test harness: while a practical scenario might express time in days or weeks, this form lets you set the finish and cancel times in seconds so that you can quickly run through a variety of scenarios. (There are 86,400 seconds in a day, if you want to play with longer term escrows.) + +To create a time-based escrow: + +1. Enter an **Amount** to transfer. For example, _100000000_. +2. Copy the **Operational Account** value. +3. Paste it in the **Destination Account** field. +4. Set the **Escrow Finish (seconds)** value. For example, enter _10_. +5. Set the **Escrow Cancel (seconds)** value. For example, enter _120_. +6. Click **Create Time-based Escrow**. +7. Copy the _Sequence Number_ of the escrow called out in the **Standby Result** field. + +The escrow is created on the XRP Ledger instance, reserving 100 XRP plus the transaction cost and reserve requirements. When you create an escrow, capture and save the **Sequence Number** so that you can use it to finish the escrow transaction. + +[![Completed Create Escrow Transaction](img/quickstart-py-escrow3.png)](img/quickstart-py-escrow3.png) + +## Finish Escrow + +The recipient of the XRP held in escrow can finish the transaction any time within the time window after the Escrow Finish date and time but before the Escrow Cancel date and time. Following on the example above, you can use the _Sequence Number_ to finish the transaction once 10 seconds have passed. + +To finish a time-based escrow: + +1. Paste the sequence number in the Operational account **Sequence Number** field. +2. Click **Finish Escrow**. +3. Click **Get Op Account Info** and **Get Standby Account Info** to update their **XRP Balance**. + +The transaction completes and balances are updated for both the Standby and Operational accounts. + +[![Completed Escrow Transaction](img/quickstart-py-escrow4.png)](img/quickstart-py-escrow4.png) + +## Get Escrows + +Click **Get Escrows** to see the current list of escrows for the Operational account. If you click the button now, there are no escrows at the moment. + +For the purposes of this tutorial, you can follow the steps in [Create Escrow](#create-escrow), above, to create a new escrow transaction that you can then look up. Remember to capture the _Sequence Number_ from the transaction results. + +[![Get Escrows results](img/quickstart-py-escrow5.png)](img/quickstart-py-escrow5.png) + + +## Cancel Escrow + +When the Escrow Cancel time passes, the escrow is no longer available to the recipient. The initiator of the escrow can reclaim the XRP. If you try to cancel the transaction prior to the **Escrow Cancel** time, you are charged for the transaction, but the actual escrow cannot be cancelled until the time limit is reached. + +You can wait the allotted time for the escrow you created in the previous step, then use it to try out the **Cancel Escrow** button + +To cancel an expired escrow: + +1. Enter the sequence number in the Standby **Sequence Number** field. +2. Copy the **Standby Account** value and paste it in the **Escrow Owner** field. +2. Click **Cancel Time-based Escrow**. + +The funds are returned to the Standby account, less the initial transaction fee. + +[![Cancel Escrow results](img/quickstart-py-escrow6.png)](img/quickstart-py-escrow6.png) + +## Oh No! I Forgot to Save the Sequence Number! + +If you forget to save the sequence number, you can find it in the escrow transaction record. + +1. Create a new escrow as described in [Create Escrow](#create-escrow), above. +2. Click **Get Escrows** to get the escrow information. +3. Copy the _PreviousTxnLgrSeq_ value from the results. + ![Transaction ID in Get Escrows results](img/quickstart-py-escrow7.png) +4. Paste the _PreviousTxnLgrSeq_ in the **Transaction to Look Up** field. +5. Click **Get Transaction**. +6. Locate the _Sequence_ value in the results. + ![Sequence number in results](img/quickstart-py-escrow8.png) + +# Code Walkthrough + +You can download the [Python Modular Code Samples](https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/quickstart/py/){.github-code-download} in the source repository for this website. + +## mod8.py + +This example can be used with the XRP Ledger network, _Testnet_. You can update the code to choose different or additional XRP Ledger networks. + +### add_seconds + +This function accomplishes two things. It creates a new date object and adds the number of seconds taken from a form field. Then, it adjusts the date from the Python format to the XRP Ledger format. + +Provide the _numOfSeconds_ argument. + +```python +def add_seconds(numOfSeconds): +``` + +Create a new Python date object. + +```python + new_date = datetime.now() +``` + +Convert the date variable for the Ripple epoch. + +```python + if new_date != '': + new_date = xrpl.utils.datetime_to_ripple_time(new_date) +``` + +Add your seconds to the date. + +```python + new_date = new_date + int(numOfSeconds) +``` + +Return the resulting date value. + +```python + return new_date +``` + +### create_time_escrow + +Call the create_time_escrow function, passing the _seed_, _amount_, _destination_, _finish_ interval, and _cancel_ interval. + +```python +def create_time_escrow(seed, amount, destination, finish, cancel): +``` + +Get the client wallet. + +```python + wallet=Wallet.from_seed(seed) +``` + +Connect to Testnet. + +```python + client=JsonRpcClient(testnet_url) +``` + +Create variables for the finish and cancel dates using the add_seconds function. + +```python + finish_date = add_seconds(finish) + cancel_date = add_seconds(cancel) +``` + +Define the **EscrowCreate** transaction. + +```python + escrow_tx=xrpl.models.transactions.EscrowCreate( + account=wallet.address, + amount=amount, + destination=destination, + finish_after=finish_date, + cancel_after=cancel_date + ) +``` + +Submit the transaction and report the results. + +```python + reply="" + try: + response=xrpl.transaction.submit_and_wait(escrow_tx,client,wallet) + reply=response.result + except xrpl.transaction.XRPLReliableSubmissionException as e: + reply=f"Submit failed: {e}" + return reply +``` + +### finish_time_escrow + +Pass the operational account _seed_, escrow _owner_ (in these examples, the standby address), and the escrow _sequence_ number. + +```python +def finish_time_escrow(seed, owner, sequence): +``` + +Instantiate the wallet and client. + +```python + wallet=Wallet.from_seed(seed) + client=JsonRpcClient(testnet_url) +``` + +Define the **EscrowFinish** transaction. + +```python + finish_tx=xrpl.models.transactions.EscrowFinish( + account=wallet.address, + owner=owner, + offer_sequence=int(sequence) + ) +``` + +Submit the transaction and report the results. + +```python + reply="" + try: + response=xrpl.transaction.submit_and_wait(finish_tx,client,wallet) + reply=response.result + except xrpl.transaction.XRPLReliableSubmissionException as e: + reply=f"Submit failed: {e}" + return reply +``` + +### get_escrows + +This request only requires the _account_ argument. + +```python +def get_escrows(account): +``` + +Since this is a request, there's no need to sign in with an account to perform the query. You can just instantiate a client on Testnet. + +```python + client=JsonRpcClient(testnet_url) +``` + +Define the **AccountObjects** request, specifying objects of type _escrow_. + +```python + acct_escrows=AccountObjects( + account=account, + ledger_index="validated", + type="escrow" + ) +``` + +Submit the request and return the results. + +```python + response=client.request(acct_escrows) + return response.result +``` + +### cancel_time_escrows + +Pass the issuer account _seed_, the _owner_ account, and the escrow _sequence_ number. + +```python +def cancel_time_escrow(seed, owner, sequence): +``` + +Get the wallet and instantiate a client on _Testnet_. + +```python + wallet=Wallet.from_seed(seed) + client=JsonRpcClient(testnet_url) +``` + +Define the cancel transaction + +```python + cancel_tx=xrpl.models.transactions.EscrowCancel( + account=wallet.address, + owner=owner, + offer_sequence=int(sequence) + ) +``` + +Submit the transaction and report the results + +```python + reply="" + try: + response=xrpl.transaction.submit_and_wait(cancel_tx,client,wallet) + reply=response.result + except xrpl.transaction.XRPLReliableSubmissionException as e: + reply=f"Submit failed: {e}" + return reply +``` + +### get_transaction + +Pass the requesting account number and the previous transaction ledger sequence number. + +```python +def get_transaction(account, ledger_index): +``` + +Create a client instance. + +```python + client=JsonRpcClient(testnet_url) +``` + +Create the **AccountTx** request. + +```python + tx_info=AccountTx( + account=account, + ledger_index=int(ledger_index) + ) +``` + +Send the request and report the results. + +```python + response=client.request(tx_info) + return response.result +``` + +## lesson8-time-escrow.py + +This module builds on `lesson1-send-xrp.py`. Changes are noted below. + +```python +import tkinter as tk +import xrpl +import json + +from mod1 import get_account, get_account_info, send_xrp +``` + +Import new functions from mod8.py. + +```python +from mod8 import create_time_escrow, finish_time_escrow, get_escrows, cancel_time_escrow, get_transaction +``` + +Module 8 Handlers + +```python +def standby_create_time_escrow(): + results = create_time_escrow( + ent_standby_seed.get(), + ent_standby_amount.get(), + ent_standby_destination.get(), + ent_standby_escrow_finish.get(), + ent_standby_escrow_cancel.get() + ) + text_standby_results.delete("1.0", tk.END) + text_standby_results.insert("1.0", json.dumps(results, indent=4)) + +def operational_finish_time_escrow(): + results = finish_time_escrow( + ent_operational_seed.get(), + ent_operational_escrow_owner.get(), + ent_operational_sequence_number.get() + ) + text_operational_results.delete("1.0", tk.END) + text_operational_results.insert("1.0", json.dumps(results, indent=4)) + +def operational_get_escrows(): + results = get_escrows(ent_operational_account.get()) + text_operational_results.delete("1.0", tk.END) + text_operational_results.insert("1.0", json.dumps(results, indent=4)) + +def standby_cancel_time_escrow(): + results = cancel_time_escrow( + ent_standby_seed.get(), + ent_standby_escrow_owner.get(), + ent_standby_escrow_sequence_number.get() + ) + text_standby_results.delete("1.0", tk.END) + text_standby_results.insert("1.0", json.dumps(results, indent=4)) + +def operational_get_transaction(): + results = get_transaction(ent_operational_account.get(), + ent_operational_look_up.get()) + text_operational_results.delete("1.0", tk.END) + text_operational_results.insert("1.0", json.dumps(results, indent=4)) + +## Mod 1 Handlers + +def get_standby_account(): + new_wallet = get_account(ent_standby_seed.get()) + ent_standby_account.delete(0, tk.END) + ent_standby_seed.delete(0, tk.END) + ent_standby_account.insert(0, new_wallet.classic_address) + ent_standby_seed.insert(0, new_wallet.seed) + + +def get_standby_account_info(): + accountInfo = get_account_info(ent_standby_account.get()) + ent_standby_balance.delete(0, tk.END) + ent_standby_balance.insert(0,accountInfo['Balance']) + text_standby_results.delete("1.0", tk.END) + text_standby_results.insert("1.0",json.dumps(accountInfo, indent=4)) + + +def standby_send_xrp(): + response = send_xrp(ent_standby_seed.get(),ent_standby_amount.get(), + ent_standby_destination.get()) + text_standby_results.delete("1.0", tk.END) + text_standby_results.insert("1.0",json.dumps(response.result, indent=4)) + get_standby_account_info() + get_operational_account_info() + + +def get_operational_account(): + new_wallet = get_account(ent_operational_seed.get()) + ent_operational_account.delete(0, tk.END) + ent_operational_account.insert(0, new_wallet.classic_address) + ent_operational_seed.delete(0, tk.END) + ent_operational_seed.insert(0, new_wallet.seed) + + +def get_operational_account_info(): + accountInfo = get_account_info(ent_operational_account.get()) + ent_operational_balance.delete(0, tk.END) + ent_operational_balance.insert(0,accountInfo['Balance']) + text_operational_results.delete("1.0", tk.END) + text_operational_results.insert("1.0",json.dumps(accountInfo, indent=4)) + + +def operational_send_xrp(): + response = send_xrp(ent_operational_seed.get(),ent_operational_amount.get(), + ent_operational_destination.get()) + text_operational_results.delete("1.0", tk.END) + text_operational_results.insert("1.0",json.dumps(response.result,indent=4)) + get_standby_account_info() + get_operational_account_info() + + +# Create a new window with the title "Quickstart Module 1" +window = tk.Tk() +window.title("Time-based Escrow Example") + +# Form frame +frm_form = tk.Frame(relief=tk.SUNKEN, borderwidth=3) +frm_form.pack() + +# Create the Label and Entry widgets for "Standby Account" +lbl_standy_seed = tk.Label(master=frm_form, text="Standby Seed") +ent_standby_seed = tk.Entry(master=frm_form, width=50) +lbl_standby_account = tk.Label(master=frm_form, text="Standby Account") +ent_standby_account = tk.Entry(master=frm_form, width=50) +lbl_standy_amount = tk.Label(master=frm_form, text="Amount") +ent_standby_amount = tk.Entry(master=frm_form, width=50) +lbl_standby_destination = tk.Label(master=frm_form, text="Destination") +ent_standby_destination = tk.Entry(master=frm_form, width=50) +lbl_standby_balance = tk.Label(master=frm_form, text="XRP Balance") +ent_standby_balance = tk.Entry(master=frm_form, width=50) +``` + +Add supporting fields for escrow commands. + +```python +lbl_standby_escrow_finish = tk.Label(master=frm_form, text="Escrow Finish (seconds)") +ent_standby_escrow_finish = tk.Entry(master=frm_form, width=50) +lbl_standby_escrow_cancel = tk.Label(master=frm_form, text="Escrow Cancel (seconds)") +ent_standby_escrow_cancel = tk.Entry(master=frm_form, width=50) +lbl_standby_escrow_sequence_number = tk.Label(master=frm_form, text="Sequence Number") +ent_standby_escrow_sequence_number = tk.Entry(master=frm_form, width=50) +lbl_standby_escrow_owner = tk.Label(master=frm_form, text="Escrow Owner") +ent_standby_escrow_owner = tk.Entry(master=frm_form, width=50) +lbl_standby_results = tk.Label(master=frm_form, text="Results") +text_standby_results = tk.Text(master=frm_form, height = 20, width = 65) + +# Place fields in a grid. +lbl_standy_seed.grid(row=0, column=0, sticky="e") +ent_standby_seed.grid(row=0, column=1) +lbl_standby_account.grid(row=2, column=0, sticky="e") +ent_standby_account.grid(row=2, column=1) +lbl_standy_amount.grid(row=3, column=0, sticky="e") +ent_standby_amount.grid(row=3, column=1) +lbl_standby_destination.grid(row=4, column=0, sticky="e") +ent_standby_destination.grid(row=4, column=1) +lbl_standby_balance.grid(row=5, column=0, sticky="e") +ent_standby_balance.grid(row=5, column=1) +``` + +Add supporting fields for escrow to the standby side of the form. + +```python +lbl_standby_escrow_finish.grid(row=6, column=0, sticky="e") +ent_standby_escrow_finish.grid(row=6, column=1) +lbl_standby_escrow_cancel.grid(row=7, column=0, sticky="e") +ent_standby_escrow_cancel.grid(row=7, column=1) +lbl_standby_escrow_sequence_number.grid(row=8, column=0, sticky="e") +ent_standby_escrow_sequence_number.grid(row=8, column=1) +lbl_standby_escrow_owner.grid(row=9, column=0, sticky="e") +ent_standby_escrow_owner.grid(row=9, column=1) +lbl_standby_results.grid(row=10, column=0, sticky="ne") +text_standby_results.grid(row=10, column=1, sticky="nw") + +############################################### +## Operational Account ######################## +############################################### + +# Create the Label and Entry widgets for "Operational Account" +lbl_operational_seed = tk.Label(master=frm_form, text="Operational Seed") +ent_operational_seed = tk.Entry(master=frm_form, width=50) +lbl_operational_account = tk.Label(master=frm_form, text="Operational Account") +ent_operational_account = tk.Entry(master=frm_form, width=50) +lbl_operational_amount = tk.Label(master=frm_form, text="Amount") +ent_operational_amount = tk.Entry(master=frm_form, width=50) +lbl_operational_destination = tk.Label(master=frm_form, text="Destination") +ent_operational_destination = tk.Entry(master=frm_form, width=50) +lbl_operational_balance = tk.Label(master=frm_form, text="XRP Balance") +ent_operational_balance = tk.Entry(master=frm_form, width=50) +``` + +Define escrow supporting fields for the operational side of the form. + +```python +lbl_operational_sequence_number = tk.Label(master=frm_form, text="Sequence Number") +ent_operational_sequence_number = tk.Entry(master=frm_form, width=50) +lbl_operational_escrow_owner=tk.Label(master=frm_form, text="Escrow Owner") +ent_operational_escrow_owner=tk.Entry(master=frm_form, width=50) +lbl_operational_look_up = tk.Label(master=frm_form, text="Transaction to Look Up") +ent_operational_look_up = tk.Entry(master=frm_form, width=50) +lbl_operational_results = tk.Label(master=frm_form,text='Results') +text_operational_results = tk.Text(master=frm_form, height = 20, width = 65) + +#Place the widgets in a grid +lbl_operational_seed.grid(row=0, column=4, sticky="e") +ent_operational_seed.grid(row=0, column=5, sticky="w") +lbl_operational_account.grid(row=2,column=4, sticky="e") +ent_operational_account.grid(row=2,column=5, sticky="w") +lbl_operational_amount.grid(row=3, column=4, sticky="e") +ent_operational_amount.grid(row=3, column=5, sticky="w") +lbl_operational_destination.grid(row=4, column=4, sticky="e") +ent_operational_destination.grid(row=4, column=5, sticky="w") +lbl_operational_balance.grid(row=5, column=4, sticky="e") +ent_operational_balance.grid(row=5, column=5, sticky="w") +``` + +Add supporting fields for escrow to the operational side of the form. + +```python +lbl_operational_sequence_number.grid(row=6, column=4, sticky="e") +ent_operational_sequence_number.grid(row=6, column=5, sticky="w") +lbl_operational_escrow_owner.grid(row=7, column=4, sticky="e") +ent_operational_escrow_owner.grid(row=7, column=5, sticky="w") +lbl_operational_look_up.grid(row=8, column=4, sticky="e") +ent_operational_look_up.grid(row=8, column=5, sticky="w") +lbl_operational_results.grid(row=10, column=4, sticky="ne") +text_operational_results.grid(row=10, column=5, sticky="nw") + +############################################# +## Buttons ################################## +############################################# + +# Create the Get Standby Account Buttons +btn_get_standby_account = tk.Button(master=frm_form, text="Get Standby Account", + command = get_standby_account) +btn_get_standby_account.grid(row = 0, column = 2, sticky = "nsew") +btn_get_standby_account_info = tk.Button(master=frm_form, + text="Get Standby Account Info", + command = get_standby_account_info) +btn_get_standby_account_info.grid(row = 1, column = 2, sticky = "nsew") +btn_standby_send_xrp = tk.Button(master=frm_form, text="Send XRP >", + command = standby_send_xrp) +btn_standby_send_xrp.grid(row = 2, column = 2, sticky = "nsew") +``` + +Add buttons for escrow activity on the standby side of the form. + +```python +btn_standby_create_escrow = tk.Button(master=frm_form, text="Create Time-based Escrow", + command = standby_create_time_escrow) +btn_standby_create_escrow.grid(row = 4, column = 2, sticky="nsew") +btn_standby_cancel_escrow = tk.Button(master=frm_form, text="Cancel Time-based Escrow", + command = standby_cancel_time_escrow) +btn_standby_cancel_escrow.grid(row=5,column = 2, sticky="nsew") + +# Create the Operational Account Buttons +btn_get_operational_account = tk.Button(master=frm_form, + text="Get Operational Account", + command = get_operational_account) +btn_get_operational_account.grid(row=0, column=3, sticky = "nsew") +btn_get_op_account_info = tk.Button(master=frm_form, text="Get Op Account Info", + command = get_operational_account_info) +btn_get_op_account_info.grid(row=1, column=3, sticky = "nsew") +btn_op_send_xrp = tk.Button(master=frm_form, text="< Send XRP", + command = operational_send_xrp) +btn_op_send_xrp.grid(row=2, column = 3, sticky = "nsew") +``` + +Add buttons to support escrow activity on the operational side of the form. + +```python +btn_op_finish_escrow = tk.Button(master=frm_form, text="Finish Escrow", + command = operational_finish_time_escrow) +btn_op_finish_escrow.grid(row = 4, column = 3, sticky="nsew") +btn_op_finish_escrow = tk.Button(master=frm_form, text="Get Escrows", + command = operational_get_escrows) +btn_op_finish_escrow.grid(row = 5, column = 3, sticky="nsew") +btn_op_get_transaction = tk.Button(master=frm_form, text="Get Transaction", + command = operational_get_transaction) +btn_op_get_transaction.grid(row = 6, column = 3, sticky = "nsew") + + +# Start the application +window.mainloop() +``` \ No newline at end of file diff --git a/dactyl-config.yml b/dactyl-config.yml index 48a6a765e3f..e29c33b2ae9 100644 --- a/dactyl-config.yml +++ b/dactyl-config.yml @@ -1560,7 +1560,8 @@ pages: - en - ja - - md: tutorials/quickstart/py-create-conditional-escrows.md + # TODO: translate + - md: tutorials/quickstart/py-create-time-based-escrows.md targets: - en - ja @@ -3899,11 +3900,17 @@ pages: targets: - ja + # TODO: translate + - md: infrastructure/rippled/installation/build-on-linux-mac-windows.md + targets: + - en + - ja + # Redirect to build instructions on rippled repo. - name: Build and Run rippled on Ubuntu html: build-run-rippled-ubuntu.html template: pagetype-redirect.html.jinja - redirect_url: https://github.com/XRPLF/rippled/blob/release/BUILD.md + redirect_url: build-on-linux-mac-windows.html targets: - en - ja @@ -3912,7 +3919,7 @@ pages: - name: Build and Run rippled on macOS html: build-run-rippled-macos.html template: pagetype-redirect.html.jinja - redirect_url: https://github.com/XRPLF/rippled/blob/release/BUILD.md + redirect_url: build-on-linux-mac-windows.html targets: - en - ja diff --git a/img/quickstart-py-escrow1.png b/img/quickstart-py-escrow1.png new file mode 100644 index 00000000000..7676b14278b Binary files /dev/null and b/img/quickstart-py-escrow1.png differ diff --git a/img/quickstart-py-escrow2.png b/img/quickstart-py-escrow2.png new file mode 100644 index 00000000000..e6e7fa6e3e3 Binary files /dev/null and b/img/quickstart-py-escrow2.png differ diff --git a/img/quickstart-py-escrow3.png b/img/quickstart-py-escrow3.png new file mode 100644 index 00000000000..8f2043bad6d Binary files /dev/null and b/img/quickstart-py-escrow3.png differ diff --git a/img/quickstart-py-escrow4.png b/img/quickstart-py-escrow4.png new file mode 100644 index 00000000000..6f26e11b6f2 Binary files /dev/null and b/img/quickstart-py-escrow4.png differ diff --git a/img/quickstart-py-escrow5.png b/img/quickstart-py-escrow5.png new file mode 100644 index 00000000000..a4ad6dd08fd Binary files /dev/null and b/img/quickstart-py-escrow5.png differ diff --git a/img/quickstart-py-escrow6.png b/img/quickstart-py-escrow6.png new file mode 100644 index 00000000000..96d1e9dd2ca Binary files /dev/null and b/img/quickstart-py-escrow6.png differ diff --git a/img/quickstart-py-escrow7.png b/img/quickstart-py-escrow7.png new file mode 100644 index 00000000000..703fade4754 Binary files /dev/null and b/img/quickstart-py-escrow7.png differ diff --git a/img/quickstart-py-escrow8.png b/img/quickstart-py-escrow8.png new file mode 100644 index 00000000000..9b0165abb61 Binary files /dev/null and b/img/quickstart-py-escrow8.png differ