mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
[UI] Add Instantsend parameter to URI/QR-code (#1042)
This commit is contained in:
parent
b9bd11610d
commit
93cd3693c2
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>776</width>
|
||||
<height>364</height>
|
||||
<height>387</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,1">
|
||||
@ -127,7 +127,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="2">
|
||||
<item row="9" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="receiveButton">
|
||||
@ -176,13 +176,23 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="2">
|
||||
<widget class="QCheckBox" name="checkUseInstantSend">
|
||||
<property name="text">
|
||||
<string>Request InstantSend</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -151,6 +151,8 @@ bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
|
||||
QUrlQuery uriQuery(uri);
|
||||
QList<QPair<QString, QString> > items = uriQuery.queryItems();
|
||||
#endif
|
||||
|
||||
rv.fUseInstantSend = false;
|
||||
for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); i++)
|
||||
{
|
||||
bool fShouldReturnFalse = false;
|
||||
@ -165,6 +167,13 @@ bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
|
||||
rv.label = i->second;
|
||||
fShouldReturnFalse = false;
|
||||
}
|
||||
if (i->first == "IS")
|
||||
{
|
||||
if(i->second.compare(QString("1")) == 0)
|
||||
rv.fUseInstantSend = true;
|
||||
|
||||
fShouldReturnFalse = false;
|
||||
}
|
||||
if (i->first == "message")
|
||||
{
|
||||
rv.message = i->second;
|
||||
@ -230,6 +239,12 @@ QString formatBitcoinURI(const SendCoinsRecipient &info)
|
||||
ret += QString("%1message=%2").arg(paramCount == 0 ? "?" : "&").arg(msg);
|
||||
paramCount++;
|
||||
}
|
||||
|
||||
if(info.fUseInstantSend)
|
||||
{
|
||||
ret += QString("%1IS=1").arg(paramCount == 0 ? "?" : "&");
|
||||
paramCount++;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -152,6 +152,7 @@ void ReceiveCoinsDialog::on_receiveButton_clicked()
|
||||
}
|
||||
SendCoinsRecipient info(address, label,
|
||||
ui->reqAmount->value(), ui->reqMessage->text());
|
||||
info.fUseInstantSend = ui->checkUseInstantSend->isChecked();
|
||||
ReceiveRequestDialog *dialog = new ReceiveRequestDialog(this);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dialog->setModel(model->getOptionsModel());
|
||||
|
@ -149,6 +149,10 @@ void ReceiveRequestDialog::update()
|
||||
html += "<b>"+tr("Label")+"</b>: " + GUIUtil::HtmlEscape(info.label) + "<br>";
|
||||
if(!info.message.isEmpty())
|
||||
html += "<b>"+tr("Message")+"</b>: " + GUIUtil::HtmlEscape(info.message) + "<br>";
|
||||
if(info.fUseInstantSend)
|
||||
html += "<b>"+tr("InstantSend")+"</b>: Yes<br>";
|
||||
else
|
||||
html += "<b>"+tr("InstantSend")+"</b>: No<br>";
|
||||
ui->outUri->setText(html);
|
||||
|
||||
#ifdef USE_QRCODE
|
||||
|
@ -63,4 +63,32 @@ void URITests::uriTests()
|
||||
|
||||
uri.setUrl(QString("dash:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?amount=1,000.0&label=Some Example"));
|
||||
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
|
||||
|
||||
uri.setUrl(QString("dash:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?amount=100&label=Some Example&message=Some Example Message&IS=1"));
|
||||
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
||||
QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
|
||||
QVERIFY(rv.amount == 10000000000LL);
|
||||
QVERIFY(rv.label == QString("Some Example"));
|
||||
QVERIFY(rv.message == QString("Some Example Message"));
|
||||
QVERIFY(rv.fUseInstantSend == 1);
|
||||
|
||||
uri.setUrl(QString("dash:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?amount=100&label=Some Example&message=Some Example Message&IS=Something Invalid"));
|
||||
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
||||
QVERIFY(rv.address == QString("XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
|
||||
QVERIFY(rv.amount == 10000000000LL);
|
||||
QVERIFY(rv.label == QString("Some Example"));
|
||||
QVERIFY(rv.message == QString("Some Example Message"));
|
||||
QVERIFY(rv.fUseInstantSend != 1);
|
||||
|
||||
uri.setUrl(QString("dash:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?IS=1"));
|
||||
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
||||
QVERIFY(rv.fUseInstantSend == 1);
|
||||
|
||||
uri.setUrl(QString("dash:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg?IS=0"));
|
||||
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
||||
QVERIFY(rv.fUseInstantSend != 1);
|
||||
|
||||
uri.setUrl(QString("dash:XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg"));
|
||||
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
||||
QVERIFY(rv.fUseInstantSend != 1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user