Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
add convert-to-tube4 button
Browse files Browse the repository at this point in the history
  • Loading branch information
tubedev2000 committed Jun 27, 2020
1 parent 420782d commit 90389d6
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 0 deletions.
5 changes: 5 additions & 0 deletions MiddlePanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Rectangle {

signal paymentClicked(string address, string paymentId, string amount, int mixinCount, int priority, string description)
signal sweepUnmixableClicked()
signal sweepTube4Clicked()
signal generatePaymentIdInvoked()
signal getProofClicked(string txid, string address, string message);
signal checkProofClicked(string txid, string address, string message, string signature);
Expand Down Expand Up @@ -273,5 +274,9 @@ Rectangle {
console.log("MiddlePanel: sweepUnmixableClicked")
sweepUnmixableClicked()
}
onSweepTube4Clicked : {
console.log("MiddlePanel: sweepTube4Clicked")
sweepTube4Clicked()
}
}
}
41 changes: 41 additions & 0 deletions main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ ApplicationWindow {
currentWallet.transactionCommitted.disconnect(onTransactionCommitted);
middlePanel.paymentClicked.disconnect(handlePayment);
middlePanel.sweepUnmixableClicked.disconnect(handleSweepUnmixable);
middlePanel.sweepTube4Clicked.disconnect(handleSweepTube4);
middlePanel.getProofClicked.disconnect(handleGetProof);
middlePanel.checkProofClicked.disconnect(handleCheckProof);

Expand Down Expand Up @@ -361,6 +362,7 @@ ApplicationWindow {
currentWallet.transactionCommitted.connect(onTransactionCommitted);
middlePanel.paymentClicked.connect(handlePayment);
middlePanel.sweepUnmixableClicked.connect(handleSweepUnmixable);
middlePanel.sweepTube4Clicked.connect(handleSweepTube4);
middlePanel.getProofClicked.connect(handleGetProof);
middlePanel.checkProofClicked.connect(handleCheckProof);

Expand Down Expand Up @@ -928,6 +930,45 @@ ApplicationWindow {
}
}

function handleSweepTube4() {
console.log("Creating transaction: ")

transaction = currentWallet.createSweepTube4Transaction();
if (transaction.status !== PendingTransaction.Status_Ok) {
console.error("Can't create transaction: ", transaction.errorString);
informationPopup.title = qsTr("Error") + translationManager.emptyString;
informationPopup.text = qsTr("Can't create transaction: ") + transaction.errorString
informationPopup.icon = StandardIcon.Critical
informationPopup.onCloseCallback = null
informationPopup.open();
// deleting transaction object, we don't want memleaks
currentWallet.disposeTransaction(transaction);

} else if (transaction.txCount == 0) {
informationPopup.title = qsTr("Error") + translationManager.emptyString
informationPopup.text = qsTr("No outputs to sweep") + translationManager.emptyString
informationPopup.icon = StandardIcon.Information
informationPopup.onCloseCallback = null
informationPopup.open()
// deleting transaction object, we don't want memleaks
currentWallet.disposeTransaction(transaction);
} else {
console.log("Transaction created, amount: " + walletManager.displayAmount(transaction.amount)
+ ", fee: " + walletManager.displayAmount(transaction.fee));

// here we show confirmation popup;

transactionConfirmationPopup.title = qsTr("Confirmation") + translationManager.emptyString
transactionConfirmationPopup.text = qsTr("Please confirm transaction:\n")
+ qsTr("\n\nAmount: ") + walletManager.displayAmount(transaction.amount)
+ qsTr("\nFee: ") + walletManager.displayAmount(transaction.fee)
+ translationManager.emptyString
transactionConfirmationPopup.icon = StandardIcon.Question
transactionConfirmationPopup.open()
// committing transaction
}
}

// called after user confirms transaction
function handleTransactionConfirmed(fileName) {
// View only wallet - we save the tx
Expand Down
14 changes: 14 additions & 0 deletions pages/Transfer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Rectangle {
signal paymentClicked(string address, string paymentId, string amount, int mixinCount,
int priority, string description)
signal sweepUnmixableClicked()
signal sweepTube4Clicked()

color: "transparent"
property alias transferHeight1: pageRoot.height
Expand Down Expand Up @@ -468,6 +469,19 @@ Rectangle {
}
}
}

RowLayout {
StandardButton {
id: sweepTube4Button
Layout.topMargin: 4
text: qsTr("Convert to BitTubeCash 4.0") + translationManager.emptyString
enabled : pageRoot.enabled
onClicked: {
console.log("Transfer: sweepTube4Clicked")
root.sweepTube4Clicked()
}
}
}

function checkInformation(amount, address, nettype) {
return amount.length > 0 && walletManager.amountFromString(amountLine.text) <= appWindow.getUnlockedBalance() && TxUtils.checkAddress(address, nettype)
Expand Down
15 changes: 15 additions & 0 deletions src/libwalletqt/Wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,13 @@ PendingTransaction *Wallet::createSweepUnmixableTransaction()
return result;
}

PendingTransaction *Wallet::createSweepTube4Transaction()
{
Monero::PendingTransaction * ptImpl = m_walletImpl->createSweepTube4Transaction();
PendingTransaction * result = new PendingTransaction(ptImpl, this);
return result;
}

void Wallet::createSweepUnmixableTransactionAsync()
{
m_scheduler.run([this] {
Expand All @@ -573,6 +580,14 @@ void Wallet::createSweepUnmixableTransactionAsync()
});
}

void Wallet::createSweepTube4TransactionAsync()
{
m_scheduler.run([this] {
PendingTransaction *tx = createSweepTube4Transaction();
emit transactionCreated(tx, "", "", 0);
});
}

UnsignedTransaction * Wallet::loadTxFile(const QString &fileName)
{
qDebug() << "Trying to sign " << fileName;
Expand Down
6 changes: 6 additions & 0 deletions src/libwalletqt/Wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ class Wallet : public QObject
//! creates async sweep unmixable transaction
Q_INVOKABLE void createSweepUnmixableTransactionAsync();

//! creates sweep tube4 transaction
Q_INVOKABLE PendingTransaction * createSweepTube4Transaction();

//! creates async sweep tube4 transaction
Q_INVOKABLE void createSweepTube4TransactionAsync();

//! Sign a transfer from file
Q_INVOKABLE UnsignedTransaction * loadTxFile(const QString &fileName);

Expand Down

0 comments on commit 90389d6

Please sign in to comment.