Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/common/messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ std::string FeeModeInfo(const std::pair<std::string, FeeEstimateMode>& mode, std
return strprintf("%s estimates use a longer time horizon, making them\n"
"less responsive to short-term drops in the prevailing fee market. This mode\n"
"potentially returns a higher fee rate estimate.\n", mode.first);
default:
assert(false);
}
} // no default case, so the compiler can warn about missing cases
assert(false);
}

std::string FeeModesDetail(std::string default_info)
Expand Down Expand Up @@ -120,8 +119,7 @@ bilingual_str PSBTErrorString(PSBTError err)
return Untranslated("Input needs additional signatures or other data");
case PSBTError::OK:
return Untranslated("No errors");
// no default case, so the compiler can warn about missing cases
}
} // no default case, so the compiler can warn about missing cases
assert(false);
}

Expand All @@ -144,8 +142,7 @@ bilingual_str TransactionErrorString(const TransactionError err)
return Untranslated("Unspendable output exceeds maximum configured by user (maxburnamount)");
case TransactionError::INVALID_PACKAGE:
return Untranslated("Transaction rejected due to invalid package");
// no default case, so the compiler can warn about missing cases
}
} // no default case, so the compiler can warn about missing cases
assert(false);
}

Expand Down
3 changes: 1 addition & 2 deletions src/common/signmessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ std::string SigningResultString(const SigningResult res)
return "Private key not available";
case SigningResult::SIGNING_FAILED:
return "Sign failed";
// no default case, so the compiler can warn about missing cases
}
} // no default case, so the compiler can warn about missing cases
assert(false);
}
3 changes: 2 additions & 1 deletion src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <script/verify_flags.h>
#include <uint256.h>

#include <cassert>
#include <array>
#include <chrono>
#include <limits>
Expand Down Expand Up @@ -150,7 +151,7 @@ struct Params {
case DEPLOYMENT_SEGWIT:
return SegwitHeight;
} // no default case, so the compiler can warn about missing cases
return std::numeric_limits<int>::max();
assert(false);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/deploymentinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ std::string DeploymentName(Consensus::BuriedDeployment dep)
case Consensus::DEPLOYMENT_SEGWIT:
return "segwit";
} // no default case, so the compiler can warn about missing cases
return "";
assert(false);
}

std::optional<Consensus::BuriedDeployment> GetBuriedDeployment(const std::string_view name)
Expand Down
3 changes: 1 addition & 2 deletions src/psbt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,7 @@ std::string PSBTRoleName(PSBTRole role) {
case PSBTRole::SIGNER: return "signer";
case PSBTRole::FINALIZER: return "finalizer";
case PSBTRole::EXTRACTOR: return "extractor";
// no default case, so the compiler can warn about missing cases
}
} // no default case, so the compiler can warn about missing cases
assert(false);
}

Expand Down
3 changes: 1 addition & 2 deletions src/qt/signverifymessagedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ void SignVerifyMessageDialog::on_signMessageButton_SM_clicked()
case SigningResult::SIGNING_FAILED:
error = tr("Message signing failed.");
break;
// no default case, so the compiler can warn about missing cases
}
} // no default case, so the compiler can warn about missing cases

if (res != SigningResult::OK) {
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }");
Expand Down
36 changes: 20 additions & 16 deletions src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,10 @@ QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const
return tr("Sent to");
case TransactionRecord::Generated:
return tr("Mined");
default:
case TransactionRecord::Other:
return QString();
}
} // no default case, so the compiler can warn about missing cases
assert(false);
}

QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx) const
Expand All @@ -395,9 +396,10 @@ QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx
case TransactionRecord::SendToAddress:
case TransactionRecord::SendToOther:
return QIcon(":/icons/tx_output");
default:
case TransactionRecord::Other:
return QIcon(":/icons/tx_inout");
}
} // no default case, so the compiler can warn about missing cases
assert(false);
}

QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
Expand All @@ -412,9 +414,10 @@ QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, b
return lookupAddress(wtx->address, tooltip);
case TransactionRecord::SendToOther:
return QString::fromStdString(wtx->address);
default:
case TransactionRecord::Other:
return tr("(n/a)");
}
} // no default case, so the compiler can warn about missing cases
assert(false);
}

QVariant TransactionTableModel::addressColor(const TransactionRecord *wtx) const
Expand All @@ -427,13 +430,15 @@ QVariant TransactionTableModel::addressColor(const TransactionRecord *wtx) const
case TransactionRecord::Generated:
{
QString label = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(wtx->address));
if(label.isEmpty())
return COLOR_BAREADDRESS;
} break;
default:
break;
}
return QVariant();
if(label.isEmpty()) return COLOR_BAREADDRESS;
else return QVariant();
}
case TransactionRecord::Other:
case TransactionRecord::RecvFromOther:
case TransactionRecord::SendToOther:
return QVariant();
} // no default case, so the compiler can warn about missing cases
assert(false);
}

QString TransactionTableModel::formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed, BitcoinUnits::SeparatorStyle separators) const
Expand Down Expand Up @@ -477,9 +482,8 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx)
}
case TransactionStatus::NotAccepted:
return QIcon(":/icons/transaction_0");
default:
return COLOR_BLACK;
}
} // no default case, so the compiler can warn about missing cases
assert(false);
}

QString TransactionTableModel::formatTooltip(const TransactionRecord *rec) const
Expand Down
16 changes: 10 additions & 6 deletions src/wallet/migrate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,10 @@ class RecordsPage
to_jump += OverflowRecord::SIZE;
break;
}
default:
throw std::runtime_error("Unknown record type in records page");
}
case RecordType::DELETE_FLAG:
throw std::runtime_error("Invalid records page entry: DELETE_FLAG set without a base record type");
} // no default case, so the compiler can warn about missing cases
assert(false);

// Go back to the indexes
s.seek(-to_jump, SEEK_CUR);
Expand Down Expand Up @@ -697,9 +698,12 @@ void BerkeleyRODatabase::Open()
}
break;
}
default:
throw std::runtime_error("Unexpected page type");
}
case PageType::OVERFLOW_DATA:
throw std::runtime_error("Unexpected overflow page type");
case PageType::BTREE_META:
throw std::runtime_error("Unexpected metadata page type");
} // no default case, so the compiler can warn about missing cases
assert(false);
}
}

Expand Down
35 changes: 14 additions & 21 deletions src/wallet/rpc/spend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1146,28 +1146,21 @@ static RPCHelpMan bumpfee_helper(std::string method_name)
CAmount old_fee;
CAmount new_fee;
CMutableTransaction mtx;
feebumper::Result res;
// Targeting feerate bump.
res = feebumper::CreateRateBumpTransaction(*pwallet, hash, coin_control, errors, old_fee, new_fee, mtx, /*require_mine=*/ !want_psbt, outputs, original_change_index);
if (res != feebumper::Result::OK) {
switch(res) {
case feebumper::Result::INVALID_ADDRESS_OR_KEY:
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, errors[0].original);
break;
case feebumper::Result::INVALID_REQUEST:
throw JSONRPCError(RPC_INVALID_REQUEST, errors[0].original);
break;
case feebumper::Result::INVALID_PARAMETER:
throw JSONRPCError(RPC_INVALID_PARAMETER, errors[0].original);
break;
case feebumper::Result::WALLET_ERROR:
throw JSONRPCError(RPC_WALLET_ERROR, errors[0].original);
break;
default:
throw JSONRPCError(RPC_MISC_ERROR, errors[0].original);
break;
}
}
switch (feebumper::CreateRateBumpTransaction(*pwallet, hash, coin_control, errors, old_fee, new_fee, mtx, /*require_mine=*/ !want_psbt, outputs, original_change_index)) {
case feebumper::Result::OK:
break;
case feebumper::Result::INVALID_ADDRESS_OR_KEY:
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, errors[0].original);
case feebumper::Result::INVALID_REQUEST:
throw JSONRPCError(RPC_INVALID_REQUEST, errors[0].original);
case feebumper::Result::INVALID_PARAMETER:
throw JSONRPCError(RPC_INVALID_PARAMETER, errors[0].original);
case feebumper::Result::WALLET_ERROR:
throw JSONRPCError(RPC_WALLET_ERROR, errors[0].original);
case feebumper::Result::MISC_ERROR:
throw JSONRPCError(RPC_MISC_ERROR, errors[0].original);
} // no default case, so the compiler can warn about missing cases

UniValue result(UniValue::VOBJ);

Expand Down
3 changes: 1 addition & 2 deletions src/wallet/rpc/transactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -905,8 +905,7 @@ RPCHelpMan rescanblockchain()
throw JSONRPCError(RPC_MISC_ERROR, "Rescan failed. Potentially corrupted data files.");
case CWallet::ScanResult::USER_ABORT:
throw JSONRPCError(RPC_MISC_ERROR, "Rescan aborted.");
// no default case, so the compiler can warn about missing cases
}
} // no default case, so the compiler can warn about missing cases
UniValue response(UniValue::VOBJ);
response.pushKV("start_height", start_height);
response.pushKV("stop_height", result.last_scanned_height ? *result.last_scanned_height : UniValue());
Expand Down
8 changes: 6 additions & 2 deletions src/wallet/rpc/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,13 @@ void HandleWalletError(const std::shared_ptr<CWallet>& wallet, DatabaseStatus& s
case DatabaseStatus::FAILED_ENCRYPT:
code = RPC_WALLET_ENCRYPTION_FAILED;
break;
default: // RPC_WALLET_ERROR is returned for all other cases.
case DatabaseStatus::SUCCESS:
case DatabaseStatus::FAILED_BAD_PATH:
case DatabaseStatus::FAILED_CREATE:
case DatabaseStatus::FAILED_LOAD:
case DatabaseStatus::FAILED_VERIFY:
break;
}
} // no default case, so the compiler can warn about missing cases
throw JSONRPCError(code, error.original);
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/wallet/spend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,15 @@ static OutputType GetOutputType(TxoutType type, bool is_from_p2sh)
case TxoutType::SCRIPTHASH:
case TxoutType::PUBKEYHASH:
return OutputType::LEGACY;
default:
case TxoutType::NONSTANDARD:
case TxoutType::ANCHOR:
case TxoutType::PUBKEY:
case TxoutType::MULTISIG:
case TxoutType::NULL_DATA:
case TxoutType::WITNESS_UNKNOWN:
return OutputType::UNKNOWN;
}
} // no default case, so the compiler can warn about missing cases
assert(false);
}

// Fetch and validate the coin control selected inputs.
Expand Down
Loading