确认交易币的格式
// Format confirmation message
QStringList formatted;
for (const SendCoinsRecipient &rcp :currentTransaction.getRecipients())
{
// generate bold amount string
QString amount = ""+BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(),rcp.amount);
amount.append("");
// generate monospace address string
QString address = "" + rcp.address;
address.append("");
QString recipientElement;
if (!rcp.paymentRequest.IsInitialized())// normal payment
{
if(rcp.label.length() > 0) //label with address从标签中选择地址
{
recipientElement = tr("%1to %2").arg(amount, GUIUtil::HtmlEscape(rcp.label));
recipientElement.append(QString("(%1)").arg(address));
}
else // just address //直接输入地址
{
recipientElement = tr("%1to %2").arg(amount, address);
}
}
elseif(!rcp.authenticatedMerchant.isEmpty()) // authenticated payment request 如果是已验证的付款请求
{
recipientElement = tr("%1 to%2").arg(amount, GUIUtil::HtmlEscape(rcp.authenticatedMerchant));
}
else // unauthenticated payment request //如果是没有验证的付款请求
{
recipientElement = tr("%1 to%2").arg(amount, address);
}
formatted.append(recipientElement);
}
其中BitcoinUnits是定义btc单位,显示格式的。比如单位是用BTC还是mBTC,uBTC。数额与单位之间是否有空格等等
为确认交易做准备
QString questionString = tr("Are yousure you want to send?");
questionString.append("
%1");if(txFee > 0)
{
// append fee string if a fee isrequired 附加上费用信息
questionString.append("
");
questionString.append(BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(),txFee));
questionString.append(" ");
questionString.append(tr("added astransaction fee"));
// append transaction size 附件上交易大小
questionString.append(" (" +QString::number((double)currentTransaction.getTransactionSize() / 1000) +" kB)");
}
为确认交易做准备
QString questionString = tr("Are yousure you want to send?");
questionString.append("
%1");if(txFee > 0)
{
// append fee string if a fee isrequired 附加上费用信息
questionString.append("
");
questionString.append(BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(),txFee));
questionString.append(" ");
questionString.append(tr("added astransaction fee"));
// append transaction size 附件上交易字节大小
questionString.append(" (" +QString::number((double)currentTransaction.getTransactionSize() / 1000) +" kB)");
}
查看所有可交易的utxo
// add total amount in all subdivisionunits
questionString.append("
");
CAmount totalAmount =currentTransaction.getTotalTransactionAmount() + txFee; //读取总的交易费用,并加上交易费
QStringList alternativeUnits;
for (BitcoinUnits::Unit u : BitcoinUnits::availableUnits())//转换btc单位
{
if(u !=model->getOptionsModel()->getDisplayUnit())
alternativeUnits.append(BitcoinUnits::formatHtmlWithUnit(u,totalAmount));
}
questionString.append(tr("Total Amount%1")
.arg(BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(),totalAmount)));
questionString.append(QString("
(=%2)").arg(alternativeUnits.join("" + tr("or") + "
")));if (ui->optInRBF->isChecked())
{
questionString.append("
");
questionString.append(tr("Thistransaction signals replaceability (optin-RBF)."));
questionString.append("");
}
区块链研习社比特币源码研读班 electroman
QYB地址:QVR2eUwbx43YMkWjbaAQCYdoDmpC1ohnRk
网友评论