30 m_wallet_model(wallet_model),
31 m_client_model(client_model)
40 connect(
m_ui->
closeButton, &QPushButton::clicked,
this, &PSBTOperationsDialog::close);
60 showStatus(tr(
"Failed to load transaction: %1")
85 showStatus(tr(
"Failed to sign transaction: %1")
92 if (!complete && !ctx.isValid()) {
94 }
else if (!complete && n_signed < 1) {
96 }
else if (!complete) {
97 showStatus(tr(
"Signed %1 inputs, but more signatures are still required.").arg(n_signed),
100 showStatus(tr(
"Signed transaction successfully. Transaction is ready to broadcast."),
117 std::string err_string;
122 showStatus(tr(
"Transaction broadcast successfully! Transaction ID: %1")
125 showStatus(tr(
"Transaction broadcast failed: %1")
141 QString selected_filter;
142 QString filename_suggestion =
"";
146 filename_suggestion.append(
"-");
152 filename_suggestion.append(address_str +
"-" + amount);
155 filename_suggestion.append(
".psbt");
157 tr(
"Save Transaction Data"), filename_suggestion,
159 tr(
"Partially Signed Transaction (Binary)") + QLatin1String(
" (*.psbt)"), &selected_filter);
160 if (filename.isEmpty()) {
176 QString tx_description =
"";
181 totalAmount +=
out.nValue;
182 tx_description.append(tr(
" * Sends %1 to %2")
187 tx_description.append(
"<br>");
191 tx_description.append(
" * ");
192 if (!*analysis.
fee) {
194 tx_description.append(tr(
"Unable to calculate transaction fee or total transaction amount."));
196 tx_description.append(tr(
"Pays transaction fee: "));
200 tx_description.append(
"<hr />");
201 QStringList alternativeUnits;
208 tx_description.append(QString(
"<b>%1</b>: <b>%2</b>").arg(tr(
"Total Amount"))
210 tx_description.append(QString(
"<br /><span style='font-size:10pt; font-weight:normal;'>(=%1)</span>")
211 .arg(alternativeUnits.join(
" " + tr(
"or") +
" ")));
215 if (num_unsigned > 0) {
216 tx_description.append(
"<br><br>");
217 tx_description.append(tr(
"Transaction has %1 unsigned inputs.").arg(QString::number(num_unsigned)));
220 return tx_description.toStdString();
227 m_ui->
statusBar->setStyleSheet(
"QLabel { background-color : lightgreen }");
231 m_ui->
statusBar->setStyleSheet(
"QLabel { background-color : orange }");
235 m_ui->
statusBar->setStyleSheet(
"QLabel { background-color : red }");
261 switch (analysis.
next) {
267 QString need_sig_text = tr(
"Transaction still needs signature(s).");
270 need_sig_text +=
" " + tr(
"(But no wallet is loaded.)");
273 need_sig_text +=
" " + tr(
"(But this wallet cannot sign transactions.)");
275 }
else if (n_could_sign < 1) {
276 need_sig_text +=
" " + tr(
"(But this wallet does not have the right keys.)");
std::shared_ptr< const CTransaction > CTransactionRef
virtual bool privateKeysDisabled()=0
static QList< Unit > availableUnits()
Get list of units, for drop-down box.
interfaces::Wallet & wallet() const
std::string renderTransaction(const PartiallySignedTransaction &psbtx)
QPushButton * broadcastTransactionButton
Utility functions used by the Bitcoin Qt UI.
void setupUi(QDialog *PSBTOperationsDialog)
Dialog showing transaction details.
virtual TransactionError broadcastTransaction(CTransactionRef tx, CAmount max_tx_fee, std::string &err_string)=0
Broadcast transaction.
void broadcastTransaction()
UnlockContext requestUnlock()
bool FinalizePSBT(PartiallySignedTransaction &psbtx)
Finalizes a PSBT if possible, combining partial signatures.
BitcoinUnit getDisplayUnit() const
std::string EncodeBase64(Span< const unsigned char > input)
OptionsModel * getOptionsModel()
void updateTransactionDisplay()
bilingual_str TransactionErrorString(const TransactionError err)
A version of CTransaction with the PSBT format.
ClientModel * m_client_model
Ui::PSBTOperationsDialog * m_ui
void openWithPSBT(PartiallySignedTransaction psbtx)
bool FinalizeAndExtractPSBT(PartiallySignedTransaction &psbtx, CMutableTransaction &result)
Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized...
std::optional< CAmount > fee
Amount of fee being paid by the transaction.
static QString formatWithUnit(Unit unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as string (with unit)
constexpr auto dialog_flags
int64_t CAmount
Amount in satoshis (Can be negative)
virtual wallet::isminetype txoutIsMine(const CTxOut &txout)=0
Return whether transaction output belongs to wallet.
size_t couldSignInputs(const PartiallySignedTransaction &psbtx)
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a scriptPubKey for the destination.
static QString format(Unit unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD, bool justify=false)
Format as string.
void setClipboard(const QString &str)
QPushButton * copyToClipboardButton
QTextEdit * transactionDescription
PartiallySignedTransaction m_transaction_data
interfaces::Node & node() const
void showTransactionStatus(const PartiallySignedTransaction &psbtx)
An output of a transaction.
Model for Bitcoin network client.
QPushButton * signTransactionButton
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
size_t CountPSBTUnsignedInputs(const PartiallySignedTransaction &psbt)
Counts the unsigned inputs of a PSBT.
PSBTOperationsDialog(QWidget *parent, WalletModel *walletModel, ClientModel *clientModel)
void showStatus(const QString &msg, StatusLevel level)
bool error(const char *fmt, const Args &... args)
Interface to Bitcoin wallet from Qt view code.
static const int PROTOCOL_VERSION
network protocol versioning
QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedSuffixOut)
Get save filename, mimics QFileDialog::getSaveFileName, except that it appends a default suffix when ...
Holds the results of AnalyzePSBT (miscellaneous information about a PSBT)
std::string EncodeDestination(const CTxDestination &dest)
A mutable version of CTransaction.
virtual TransactionError fillPSBT(int sighash_type, bool sign, bool bip32derivs, size_t *n_signed, PartiallySignedTransaction &psbtx, bool &complete)=0
Fill PSBT.
QPushButton * closeButton
static QString formatHtmlWithUnit(Unit unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as HTML string (with unit)
std::optional< CMutableTransaction > tx
static const CFeeRate DEFAULT_MAX_RAW_TX_FEE_RATE
Maximum fee rate for sendrawtransaction and testmempoolaccept RPC calls.
PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx)
Provides helpful miscellaneous information about where a PSBT is in the signing workflow.
PSBTRole next
Which of the BIP 174 roles needs to handle the transaction next.
CAmount GetFeePerK() const
Return the fee in satoshis for a vsize of 1000 vbytes.
WalletModel * m_wallet_model