Skip to content

Commit

Permalink
Add refresh mempool function for RPA.
Browse files Browse the repository at this point in the history
  • Loading branch information
fyookball committed May 19, 2021
1 parent 407f71a commit f4954ee
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions electroncash/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,8 @@ def process_response(self, interface, request, response, callbacks):
self.on_server_version(interface, result)
elif method == 'blockchain.reusable.get_history':
self.process_rpa_transactions(interface, result, self.rpawallet)
elif method == 'blockchain.reusable.get_mempool':
self.process_rpa_transactions(interface, result, self.rpawallet)
elif method == 'blockchain.headers.subscribe':
if error is None:
# on_notify_header below validates result is right type or
Expand Down Expand Up @@ -1411,6 +1413,12 @@ def on_block_headers(self, interface, request, response):
interface.blockchain.catch_up = None
self.notify('blockchain_updated')

def request_rpa_mempool(self, byte_prefix_string, wallet):
params = [byte_prefix_string]
self.queue_request('blockchain.reusable.get_mempool', params)
self.rpawallet = wallet
return True

def request_rpa_txs(self, height, number_of_blocks,
byte_prefix_string, wallet):
params = [height, number_of_blocks, byte_prefix_string]
Expand Down
13 changes: 13 additions & 0 deletions electroncash/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -3101,6 +3101,18 @@ def derive_pubkeys(self, c, i):
def get_receiving_paycode(self):
return rpa.generate_paycode(self, prefix_size="10")

def fetch_rpa_mempool_txs_from_server(self):
# This function is intended to be called when the clients wants
# to check for new incoming RPA transactions from the mempool. Functions
# like fetch_rpa_candidate_txs_from_server except that it queries
# the mempool rather than confirmed transactions.

# Define the "grind string" (the RPA prefix)
rpa_grind_string = rpa.get_grind_string(self)
# Make the network call to request transactions
self.network.request_rpa_mempool(rpa_grind_string,self)
return

def fetch_rpa_candidate_txs_from_server(self, rpa_height, server_height):
# This function is intended to be called when the client wants
# to check for new incoming RPA transaction (for example when a new block arrives)
Expand All @@ -3109,6 +3121,7 @@ def fetch_rpa_candidate_txs_from_server(self, rpa_height, server_height):
# and then it will call import_rpa_tx, passing the response back to the
# wallet module.

# Make sure everything is properly connected (for example on wallet startup)
if not(self.network.interface and server_height > 0):
return

Expand Down
5 changes: 5 additions & 0 deletions electroncash_gui/qt/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,11 @@ def add_toggle_action(view_menu, tab):
paytomany_menu = tools_menu.addAction(
_("&Pay to Many"), self.paytomany, QKeySequence("Ctrl+M"))

if self.wallet.wallet_type == 'rpa':
tools_menu.addAction(
_("&Refresh RPA Transactions"),
self.wallet.fetch_rpa_mempool_txs_from_server)

raw_transaction_menu = tools_menu.addMenu(_("&Load Transaction"))
raw_transaction_menu.addAction(
_("From &File") + "...",
Expand Down

0 comments on commit f4954ee

Please sign in to comment.