Skip to content

Commit

Permalink
mainnet/testnet working
Browse files Browse the repository at this point in the history
  • Loading branch information
successor1 committed Nov 25, 2021
1 parent f79d733 commit 7515a0c
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 22 deletions.
35 changes: 35 additions & 0 deletions GUI5.ui
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,41 @@
<string>low medium high</string>
</property>
</widget>
<widget class="QRadioButton" name="custom_fee">
<property name="geometry">
<rect>
<x>460</x>
<y>80</y>
<width>151</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Enable custom fee</string>
</property>
</widget>
<widget class="QLineEdit" name="fee_edit">
<property name="geometry">
<rect>
<x>290</x>
<y>80</y>
<width>161</width>
<height>22</height>
</rect>
</property>
<property name="inputMask">
<string/>
</property>
<property name="text">
<string/>
</property>
<property name="cursorPosition">
<number>0</number>
</property>
<property name="placeholderText">
<string>Fee</string>
</property>
</widget>
</widget>
<widget class="QWidget" name="receive_tab">
<attribute name="icon">
Expand Down
46 changes: 39 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from views.about_ui import Ui_Form
from views.donate_ui import Ui_Form2
import sys
from models.model import Model
from models.model import *
import models.TransferTransaction
from models.aes import AESModel
from pyqrllib.pyqrllib import hstr2bin, SHAKE_128, SHAKE_256, SHA2_256
Expand All @@ -37,6 +37,8 @@

QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
options = []
qrl_network = []
explorer_network = []
class MyWizard(QtWidgets.QWizard):
def __init__(self, parent=None):
super().__init__(parent)
Expand Down Expand Up @@ -232,10 +234,22 @@ def onFinished(self):
qrl_address.append(main.walletDetails.qaddress.toPlainText())
mnemonic.append(main.walletDetails.mnemonic.text().rstrip())
hexseed.append(main.walletDetails.hexseed.text())
if main.introPage.combo.currentText() == "Mainnet":
qrl_network.append("Mainnet")
explorer_network.append("")
elif main.introPage.combo.currentText() == "Testnet":
qrl_network.append("Testnet")
explorer_network.append("testnet-")
elif QWizard.hasVisitedPage(main, 5):
qrl_address.append(main.data[0].split(" ")[0])
mnemonic.append(" ".join(main.data[0].split(" ")[1:-1]))
hexseed.append(main.data[0].split(" ")[35])
if main.introPage.combo.currentText() == "Mainnet":
qrl_network.append("Mainnet")
explorer_network.append("")
elif main.introPage.combo.currentText() == "Testnet":
qrl_network.append("Testnet")
explorer_network.append("testnet-")
elif QWizard.hasVisitedPage(main, 6):
if main.restoreWallet.seedline_edit.text()[:6] == "absorb":
qrl_address.append(Model.recoverAddressMnemonic(main.restoreWallet.seedline_edit.text()))
Expand All @@ -245,31 +259,43 @@ def onFinished(self):
qrl_address.append(Model.recoverAddressHexseed(main.restoreWallet.seedline_edit.text()))
mnemonic.append(Model.recoverMnemonicHexseed(main.restoreWallet.seedline_edit.text()))
hexseed.append(main.restoreWallet.seedline_edit.text())
if main.introPage.combo.currentText() == "Mainnet":
qrl_network.append("Mainnet")
explorer_network.append("")
elif main.introPage.combo.currentText() == "Testnet":
qrl_network.append("Testnet")
explorer_network.append("testnet-")
elif QWizard.hasVisitedPage(main, 3):
qrl_address.append(main.walletDetailsExperimental.qaddress.toPlainText())
mnemonic.append(main.walletDetailsExperimental.mnemonic.text().rstrip())
hexseed.append(main.walletDetailsExperimental.hexseed.text())
if main.introPage.combo.currentText() == "Mainnet":
qrl_network.append("Mainnet")
explorer_network.append("")
elif main.introPage.combo.currentText() == "Testnet":
qrl_network.append("Testnet")
explorer_network.append("testnet-")
mainWindow.public_label_description.setText(qrl_address[0])
mainWindow.public_label_description.setTextInteractionFlags(Qt.TextSelectableByMouse)
img = qrcode.make(qrl_address[0])
img_saved = img.save("qr_code.png")
mainWindow.pixmap = QPixmap('qr_code.png')
mainWindow.qr_image_label.setPixmap(mainWindow.pixmap)
mainWindow.qr_image_label.setScaledContents(True)
mainWindow.ots_key_index_input.setText(str(int(Model.getAddressOtsKeyIndex(qrl_address[0]))))
mainWindow.balance_label.setText("Balance: " + str(float(Model.getAddressBalance(qrl_address[0])) / 1000000000) + " QUANTA")
mainWindow.ots_key_index_input.setText(str(int(Model.getAddressOtsKeyIndex(qrl_address[0], explorer_network[0]))))
mainWindow.balance_label.setText("Balance: " + str(float(Model.getAddressBalance(qrl_address[0], explorer_network[0])) / 1000000000) + " QUANTA")
recoveryWindow.mnemonic_label_text.setText(mnemonic[0])
recoveryWindow.hexseed_label_text.setText(hexseed[0])
rowPosition = mainWindow.transaction_table.rowCount()
transaction_hashes = []
transaction_hashes.append(TableOutput.getMiniTransactionsByAddressHashes(qrl_address[0]))
transaction_hashes.append(TableOutput.getMiniTransactionsByAddressHashes(qrl_address[0], qrl_network[0]))
timestamp_seconds = []
amount = TableOutput.GetTransactionsByAddressAmounts(qrl_address[0])
addr_from = TableOutput.GetTransactionsByAddressAddrFrom(qrl_address[0])
amount = TableOutput.GetTransactionsByAddressAmounts(qrl_address[0], qrl_network[0])
addr_from = TableOutput.GetTransactionsByAddressAddrFrom(qrl_address[0], qrl_network[0])
message_tx = []
date_time = []
for x in transaction_hashes[0]:
resp = Model.getTransactionByHash(x)
resp = Model.getTransactionByHash(x, explorer_network[0])
try:
timestamp_seconds.append(resp["transaction"]["header"]["timestamp_seconds"])
except KeyError:
Expand Down Expand Up @@ -312,6 +338,11 @@ def __init__(self, parent=None):

self.setTitle("Welcome to Qrllight Wallet v1.4!")

self.combo = QComboBox(self)
self.combo.setMaximumWidth(100)
self.combo.addItem("Mainnet")
self.combo.addItem("Testnet")

self.label_description = QLabel("Select option:")
self.radiobutton_1 = QRadioButton("Create new wallet")
self.radiobutton_2 = QRadioButton("Open wallet file")
Expand All @@ -326,6 +357,7 @@ def __init__(self, parent=None):
self.radiobutton_2.setChecked(True)

layout = QVBoxLayout(self)
layout.addWidget(self.combo)
layout.addWidget(self.label_description)
layout.addWidget(self.radiobutton_1)
layout.addWidget(self.radiobutton_2)
Expand Down
17 changes: 9 additions & 8 deletions models/GetMiniTransactionsByAddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@
from qrl.generated import qrl_pb2_grpc, qrl_pb2
import grpc
import base64
import main

CONNECTION_TIMEOUT = 5

class TableOutput:
pass

def getMiniTransactionsByAddressHashes(qrl_address):
def getMiniTransactionsByAddressHashes(qrl_address, network):
binary_qrl_address = bytes(hstr2bin(qrl_address[1:]))
node_public_address = 'testnet-1.automated.theqrl.org:19009'
node_public_address = network + '-1.automated.theqrl.org:19009'
channel = grpc.insecure_channel(node_public_address)
stub = qrl_pb2_grpc.PublicAPIStub(channel)
request = qrl_pb2.GetMiniTransactionsByAddressReq(address=binary_qrl_address,
Expand All @@ -47,9 +48,9 @@ def getMiniTransactionsByAddressHashes(qrl_address):
transaction_hashes.append(response.mini_transactions[i].transaction_hash)
return transaction_hashes

def getMiniTransactionsByAddressAmount(qrl_address):
def getMiniTransactionsByAddressAmount(qrl_address, network):
binary_qrl_address = bytes(hstr2bin(qrl_address[1:]))
node_public_address = 'testnet-1.automated.theqrl.org:19009'
node_public_address = network + '-1.automated.theqrl.org:19009'
channel = grpc.insecure_channel(node_public_address)
stub = qrl_pb2_grpc.PublicAPIStub(channel)
request = qrl_pb2.GetMiniTransactionsByAddressReq(address=binary_qrl_address,
Expand All @@ -62,9 +63,9 @@ def getMiniTransactionsByAddressAmount(qrl_address):
return amount


def GetTransactionsByAddressAddrFrom(qrl_address):
def GetTransactionsByAddressAddrFrom(qrl_address, network):
binary_qrl_address = bytes(hstr2bin(qrl_address[1:]))
node_public_address = 'testnet-1.automated.theqrl.org:19009'
node_public_address = network + '-1.automated.theqrl.org:19009'
channel = grpc.insecure_channel(node_public_address)
stub = qrl_pb2_grpc.PublicAPIStub(channel)
request = qrl_pb2.GetTransactionsByAddressReq(address=binary_qrl_address,
Expand All @@ -76,9 +77,9 @@ def GetTransactionsByAddressAddrFrom(qrl_address):
addr_from.append("Q" + bin2hstr(response.transactions_detail[i].addr_from))
return addr_from

def GetTransactionsByAddressAmounts(qrl_address):
def GetTransactionsByAddressAmounts(qrl_address, network):
binary_qrl_address = bytes(hstr2bin(qrl_address[1:]))
node_public_address = 'testnet-1.automated.theqrl.org:19009'
node_public_address = network + '-1.automated.theqrl.org:19009'
channel = grpc.insecure_channel(node_public_address)
stub = qrl_pb2_grpc.PublicAPIStub(channel)
request = qrl_pb2.GetTransactionsByAddressReq(address=binary_qrl_address,
Expand Down
3 changes: 2 additions & 1 deletion models/TransferTransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from qrl.core.txs.multisig.MultiSigSpend import MultiSigSpend
from qrl.crypto.xmss import XMSS, hash_functions
from qrl.generated import qrl_pb2_grpc, qrl_pb2
import main

def tx_unbase64(tx_json_str):
tx_json = json.loads(tx_json_str)
Expand Down Expand Up @@ -80,7 +81,7 @@ def tx_transfer(addrs_to, amounts, message_data, fee, xmss_pk, src_xmss, ots_key

# Push transaction
print("Sending to a QRL Node...")
node_public_address = 'testnet-1.automated.theqrl.org:19009'
node_public_address = main.qrl_network[0] + '-1.automated.theqrl.org:19009'
channel = grpc.insecure_channel(node_public_address)
stub = qrl_pb2_grpc.PublicAPIStub(channel)
push_transaction_req = qrl_pb2.PushTransactionReq(transaction_signed=tx.pbdata)
Expand Down
13 changes: 7 additions & 6 deletions models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


class Model:

def __init__(self):
pass

Expand Down Expand Up @@ -38,23 +39,23 @@ def recoverHexseedMnemonic(seed):
recovered_xmss = XMSS.from_extended_seed(bin_seed)
return recovered_xmss.hexseed

def getAddressBalance(address):
request = requests.get('https://testnet-explorer.theqrl.org/api/a/'+address)
def getAddressBalance(address, network):
request = requests.get('https://' + network + 'explorer.theqrl.org/api/a/'+address)
response = request.text
getAddressResp = json.loads(response)
jsonResponse = getAddressResp
return jsonResponse["state"]["balance"]

def getAddressOtsKeyIndex(address):
request = requests.get('https://testnet-explorer.theqrl.org/api/a/'+address)
def getAddressOtsKeyIndex(address, network):
request = requests.get('https://' + network + 'explorer.theqrl.org/api/a/'+address)
response = request.text
getAddressResp = json.loads(response)
jsonResponse = getAddressResp
return jsonResponse["state"]["used_ots_key_count"]


def getTransactionByHash(tx_hash):
request = requests.get('https://testnet-explorer.theqrl.org/api/tx/'+tx_hash)
def getTransactionByHash(tx_hash, network):
request = requests.get('https://' + network + 'explorer.theqrl.org/api/tx/'+tx_hash)
response = request.text
getTXResp = json.loads(response)
jsonResponse = getTXResp
Expand Down

0 comments on commit 7515a0c

Please sign in to comment.