aboutsummaryrefslogtreecommitdiff
path: root/src/qt/guiutil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt/guiutil.cpp')
-rw-r--r--src/qt/guiutil.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index e7334e67cb..9bb2fa7c99 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -153,6 +153,34 @@ bool parseBitcoinURI(QString uri, SendCoinsRecipient *out)
return parseBitcoinURI(uriInstance, out);
}
+QString formatBitcoinURI(const SendCoinsRecipient &info)
+{
+ QString ret = QString("bitcoin:%1").arg(info.address);
+ int paramCount = 0;
+
+ if (info.amount)
+ {
+ ret += QString("?amount=%1").arg(BitcoinUnits::format(BitcoinUnits::BTC, info.amount));
+ paramCount++;
+ }
+
+ if (!info.label.isEmpty())
+ {
+ QString lbl(QUrl::toPercentEncoding(info.label));
+ ret += QString("%1label=%2").arg(paramCount == 0 ? "?" : "&").arg(lbl);
+ paramCount++;
+ }
+
+ if (!info.message.isEmpty())
+ {
+ QString msg(QUrl::toPercentEncoding(info.message));;
+ ret += QString("%1message=%2").arg(paramCount == 0 ? "?" : "&").arg(msg);
+ paramCount++;
+ }
+
+ return ret;
+}
+
bool isDust(const QString& address, qint64 amount)
{
CTxDestination dest = CBitcoinAddress(address.toStdString()).Get();