Quick rc6 fixes
This commit is contained in:
parent
05584f0352
commit
aa0e722dfa
@ -8,6 +8,33 @@
|
||||
|
||||
using namespace MWEB;
|
||||
|
||||
TxType MWEB::GetTxType(const std::vector<CRecipient>& recipients, const std::set<CInputCoin>& input_coins)
|
||||
{
|
||||
assert(!recipients.empty());
|
||||
|
||||
static auto is_ltc = [](const CInputCoin& input) { return !input.IsMWEB(); };
|
||||
static auto is_mweb = [](const CInputCoin& input) { return input.IsMWEB(); };
|
||||
|
||||
if (recipients.front().IsMWEB()) {
|
||||
// If any inputs are non-MWEB inputs, this is a peg-in transaction.
|
||||
// Otherwise, it's a simple MWEB-to-MWEB transaction.
|
||||
if (std::any_of(input_coins.cbegin(), input_coins.cend(), is_ltc)) {
|
||||
return TxType::PEGIN;
|
||||
} else {
|
||||
return TxType::MWEB_TO_MWEB;
|
||||
}
|
||||
} else {
|
||||
// If any inputs are MWEB inputs, this is a peg-out transaction.
|
||||
// NOTE: This does not exclude the possibility that it's also pegging-in in addition to the pegout.
|
||||
// Otherwise, if there are no MWEB inputs, it's a simple LTC-to-LTC transaction.
|
||||
if (std::any_of(input_coins.cbegin(), input_coins.cend(), is_mweb)) {
|
||||
return TxType::PEGOUT;
|
||||
} else {
|
||||
return TxType::LTC_TO_LTC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool MWEB::ContainsPegIn(const TxType& mweb_type, const std::set<CInputCoin>& input_coins)
|
||||
{
|
||||
if (mweb_type == MWEB::TxType::PEGIN) {
|
||||
|
||||
@ -20,6 +20,7 @@ enum class TxType {
|
||||
PEGOUT // NOTE: It's possible pegout transactions will also have pegins, but they will still be classified as PEGOUT
|
||||
};
|
||||
|
||||
TxType GetTxType(const std::vector<CRecipient>& recipients, const std::set<CInputCoin>& input_coins);
|
||||
bool ContainsPegIn(const TxType& mweb_type, const std::set<CInputCoin>& input_coins);
|
||||
bool IsChangeOnMWEB(const CWallet& wallet, const MWEB::TxType& mweb_type, const std::vector<CRecipient>& recipients, const CTxDestination& dest_change);
|
||||
uint64_t CalcMWEBWeight(const MWEB::TxType& mweb_type, const bool change_on_mweb, const std::vector<CRecipient>& recipients);
|
||||
|
||||
@ -94,6 +94,10 @@ bool Wallet::GetStealthAddress(const uint32_t index, StealthAddress& address) co
|
||||
return false;
|
||||
}
|
||||
|
||||
if (keychain->GetSpendKey().IsNull()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
address = keychain->GetStealthAddress(index);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -129,6 +129,8 @@ void TxAssembler::CreateTransaction_Locked(
|
||||
new_tx.coin_selection_params.use_bnb = false;
|
||||
}
|
||||
|
||||
new_tx.mweb_type = MWEB::GetTxType(new_tx.recipients, new_tx.selected_coins);
|
||||
|
||||
// We already created an output for each non-MWEB recipient, but for pegout transactions,
|
||||
// the recipients are funded through the pegout kernel instead of traditional LTC outputs.
|
||||
if (new_tx.mweb_type == MWEB::TxType::PEGOUT) {
|
||||
@ -397,7 +399,6 @@ bool TxAssembler::AttemptCoinSelection(InProcessTx& new_tx, const CAmount& nTarg
|
||||
mweb_to_mweb.tx_noinputs_size = 0;
|
||||
|
||||
if (SelectCoins(new_tx, nTargetValue, mweb_to_mweb)) {
|
||||
new_tx.mweb_type = MWEB::TxType::MWEB_TO_MWEB;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -411,7 +412,6 @@ bool TxAssembler::AttemptCoinSelection(InProcessTx& new_tx, const CAmount& nTarg
|
||||
params_pegin.change_spend_size = change_on_mweb ? 0 : new_tx.coin_selection_params.change_spend_size;
|
||||
|
||||
if (SelectCoins(new_tx, nTargetValue, params_pegin)) {
|
||||
new_tx.mweb_type = MWEB::TxType::PEGIN;
|
||||
return std::any_of(new_tx.selected_coins.cbegin(), new_tx.selected_coins.cend(), is_ltc);
|
||||
}
|
||||
} else {
|
||||
@ -422,7 +422,6 @@ bool TxAssembler::AttemptCoinSelection(InProcessTx& new_tx, const CAmount& nTarg
|
||||
mweb_to_mweb.mweb_nochange_weight = 0;
|
||||
|
||||
if (SelectCoins(new_tx, nTargetValue, mweb_to_mweb)) {
|
||||
new_tx.mweb_type = MWEB::TxType::LTC_TO_LTC;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -441,7 +440,6 @@ bool TxAssembler::AttemptCoinSelection(InProcessTx& new_tx, const CAmount& nTarg
|
||||
new_tx.tx.vout.clear();
|
||||
|
||||
if (SelectCoins(new_tx, nTargetValue, params_pegout)) {
|
||||
new_tx.mweb_type = MWEB::TxType::PEGOUT;
|
||||
return std::any_of(new_tx.selected_coins.cbegin(), new_tx.selected_coins.cend(), is_mweb);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user