ditch payment ID from the Receive page

This commit is contained in:
kenshi84 2018-01-13 14:36:28 +09:00
parent cee0474e37
commit a6a7b56d73
No known key found for this signature in database
GPG key ID: 085D092F1F43D51A

View file

@ -47,39 +47,8 @@ Rectangle {
property var model property var model
property var current_address property var current_address
property alias addressText : pageReceive.current_address property alias addressText : pageReceive.current_address
property alias paymentIdText : paymentIdLine.text
property alias integratedAddressText : integratedAddressLine.text
property string trackingLineText: "" property string trackingLineText: ""
function updatePaymentId(payment_id) {
if (typeof appWindow.currentWallet === 'undefined' || appWindow.currentWallet == null)
return
// generate a new one if not given as argument
if (typeof payment_id === 'undefined') {
payment_id = appWindow.currentWallet.generatePaymentId()
paymentIdLine.text = payment_id
}
if (payment_id.length > 0) {
integratedAddressLine.text = appWindow.currentWallet.integratedAddress(payment_id)
if (integratedAddressLine.text === "") {
integratedAddressLine.text = qsTr("Invalid payment ID")
paymentIdLine.error = true
}
else {
paymentIdLine.error = false
}
}
else {
paymentIdLine.text = ""
integratedAddressLine.text = ""
paymentIdLine.error = false
}
update()
}
function makeQRCodeString() { function makeQRCodeString() {
var s = "monero:" var s = "monero:"
var nfields = 0 var nfields = 0
@ -89,11 +58,6 @@ Rectangle {
s += (nfields++ ? "&" : "?") s += (nfields++ ? "&" : "?")
s += "tx_amount=" + amount s += "tx_amount=" + amount
} }
var pid = paymentIdLine.text.trim().toLowerCase()
if (pid !== "" && walletManager.paymentIdValid(pid)) {
s += (nfields++ ? "&" : "?")
s += "tx_payment_id=" + pid
}
return s return s
} }
@ -121,13 +85,14 @@ Rectangle {
var count = model.rowCount() var count = model.rowCount()
var totalAmount = 0 var totalAmount = 0
var nTransactions = 0 var nTransactions = 0
var list = "" var list = []
var blockchainHeight = 0 var blockchainHeight = 0
for (var i = 0; i < count; ++i) { for (var i = 0; i < count; ++i) {
var idx = model.index(i, 0) var idx = model.index(i, 0)
var isout = model.data(idx, TransactionHistoryModel.TransactionIsOutRole); var isout = model.data(idx, TransactionHistoryModel.TransactionIsOutRole);
var payment_id = model.data(idx, TransactionHistoryModel.TransactionPaymentIdRole); var subaddrAccount = model.data(idx, TransactionHistoryModel.TransactionSubaddrAccountRole);
if (!isout && payment_id == paymentIdLine.text) { var subaddrIndex = model.data(idx, TransactionHistoryModel.TransactionSubaddrIndexRole);
if (!isout && subaddrAccount == appWindow.currentWallet.currentSubaddressAccount && subaddrIndex == table.currentIndex) {
var amount = model.data(idx, TransactionHistoryModel.TransactionAtomicAmountRole); var amount = model.data(idx, TransactionHistoryModel.TransactionAtomicAmountRole);
totalAmount = walletManager.addi(totalAmount, amount) totalAmount = walletManager.addi(totalAmount, amount)
nTransactions += 1 nTransactions += 1
@ -135,21 +100,25 @@ Rectangle {
var txid = model.data(idx, TransactionHistoryModel.TransactionHashRole); var txid = model.data(idx, TransactionHistoryModel.TransactionHashRole);
var blockHeight = model.data(idx, TransactionHistoryModel.TransactionBlockHeightRole); var blockHeight = model.data(idx, TransactionHistoryModel.TransactionBlockHeightRole);
if (blockHeight == 0) { if (blockHeight == 0) {
list += qsTr("in the txpool: %1").arg(txid) + translationManager.emptyString list.push(qsTr("in the txpool: %1").arg(txid) + translationManager.emptyString)
} else { } else {
if (blockchainHeight == 0) if (blockchainHeight == 0)
blockchainHeight = walletManager.blockchainHeight() blockchainHeight = walletManager.blockchainHeight()
var confirmations = blockchainHeight - blockHeight - 1 var confirmations = blockchainHeight - blockHeight - 1
var displayAmount = model.data(idx, TransactionHistoryModel.TransactionDisplayAmountRole); var displayAmount = model.data(idx, TransactionHistoryModel.TransactionDisplayAmountRole);
if (confirmations > 1) { if (confirmations > 1) {
list += qsTr("%2 confirmations: %3 (%1)").arg(txid).arg(confirmations).arg(displayAmount) + translationManager.emptyString list.push(qsTr("%2 confirmations: %3 (%1)").arg(txid).arg(confirmations).arg(displayAmount) + translationManager.emptyString)
} else { } else {
list += qsTr("1 confirmation: %2 (%1)").arg(txid).arg(displayAmount) + translationManager.emptyString list.push(qsTr("1 confirmation: %2 (%1)").arg(txid).arg(displayAmount) + translationManager.emptyString)
} }
} }
list += "<br>"
} }
} }
// if there are too many txes, only show the first 3
if (list.length > 3) {
list.length = 3;
list.push("...");
}
if (nTransactions == 0) { if (nTransactions == 0) {
setTrackingLineText(qsTr("No transaction found yet...") + translationManager.emptyString) setTrackingLineText(qsTr("No transaction found yet...") + translationManager.emptyString)
@ -168,7 +137,7 @@ Rectangle {
} }
} }
setTrackingLineText(text + "<br>" + list) setTrackingLineText(text + "<br>" + list.join("<br>"))
} }
Clipboard { id: clipboard } Clipboard { id: clipboard }
@ -260,93 +229,6 @@ Rectangle {
} }
} }
GridLayout {
id: paymentIdRow
columns:2
Label {
Layout.columnSpan: 2
id: paymentIdLabel
text: qsTr("Payment ID") + translationManager.emptyString
width: mainLayout.labelWidth
}
LineEdit {
id: paymentIdLine
fontSize: mainLayout.lineEditFontSize
placeholderText: qsTr("16 hexadecimal characters") + translationManager.emptyString;
readOnly: false
onTextChanged: updatePaymentId(paymentIdLine.text)
width: mainLayout.editWidth
Layout.fillWidth: true
IconButton {
imageSource: "../images/copyToClipboard.png"
onClicked: {
if (paymentIdLine.text.length > 0) {
clipboard.setText(paymentIdLine.text)
appWindow.showStatusMessage(qsTr("Payment ID copied to clipboard"),3)
}
}
}
}
StandardButton {
id: generatePaymentId
shadowReleasedColor: "#FF4304"
shadowPressedColor: "#B32D00"
releasedColor: "#FF6C3C"
pressedColor: "#FF4304"
text: qsTr("Generate") + translationManager.emptyString;
onClicked: updatePaymentId()
}
StandardButton {
id: clearPaymentId
enabled: !!paymentIdLine.text
shadowReleasedColor: "#FF4304"
shadowPressedColor: "#B32D00"
releasedColor: "#FF6C3C"
pressedColor: "#FF4304"
text: qsTr("Clear") + translationManager.emptyString;
onClicked: updatePaymentId("")
}
}
ColumnLayout {
id: integratedAddressRow
Label {
id: integratedAddressLabel
text: qsTr("Integrated address") + translationManager.emptyString
width: mainLayout.labelWidth
}
LineEdit {
id: integratedAddressLine
fontSize: mainLayout.lineEditFontSize
placeholderText: qsTr("Generate payment ID for integrated address") + translationManager.emptyString
readOnly: true
width: mainLayout.editWidth
Layout.fillWidth: true
onTextChanged: cursorPosition = 0
IconButton {
imageSource: "../images/copyToClipboard.png"
onClicked: {
if (integratedAddressLine.text.length > 0) {
clipboard.setText(integratedAddressLine.text)
appWindow.showStatusMessage(qsTr("Integrated address copied to clipboard"),3)
}
}
}
}
}
ColumnLayout { ColumnLayout {
id: amountRow id: amountRow
Label { Label {
@ -390,7 +272,6 @@ Rectangle {
trackingHowToUseDialog.title = qsTr("Tracking payments") + translationManager.emptyString; trackingHowToUseDialog.title = qsTr("Tracking payments") + translationManager.emptyString;
trackingHowToUseDialog.text = qsTr( trackingHowToUseDialog.text = qsTr(
"<p><font size='+2'>This is a simple sales tracker:</font></p>" + "<p><font size='+2'>This is a simple sales tracker:</font></p>" +
"<p>Click Generate to create a random payment id for a new customer</p> " +
"<p>Let your customer scan that QR code to make a payment (if that customer has software which " + "<p>Let your customer scan that QR code to make a payment (if that customer has software which " +
"supports QR code scanning).</p>" + "supports QR code scanning).</p>" +
"<p>This page will automatically scan the blockchain and the tx pool " + "<p>This page will automatically scan the blockchain and the tx pool " +