Skip to content

Commit

Permalink
Merge pull request #1226 from psgreco/elements-22_1_1_rc2
Browse files Browse the repository at this point in the history
elements-22.1.1-rc2
  • Loading branch information
jhfrontz authored Mar 20, 2023
2 parents eb83661 + ad10204 commit 9d61734
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ AC_PREREQ([2.69])
define(_CLIENT_VERSION_MAJOR, 22)
define(_CLIENT_VERSION_MINOR, 1)
define(_CLIENT_VERSION_BUILD, 1)
define(_CLIENT_VERSION_RC, 1)
define(_CLIENT_VERSION_RC, 2)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2023)
define(_COPYRIGHT_HOLDERS,[The %s developers])
Expand Down
9 changes: 9 additions & 0 deletions src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ class CBlockIndex
std::optional<CScriptWitness> m_signblock_witness{};

bool m_trimmed{false};
bool m_trimmed_dynafed_block{false};

friend class CBlockTreeDB;

Expand All @@ -210,6 +211,7 @@ class CBlockIndex
void trim() {
assert_untrimmed();
m_trimmed = true;
m_trimmed_dynafed_block = !m_dynafed_params.value().IsNull();
proof = std::nullopt;
m_dynafed_params = std::nullopt;
m_signblock_witness = std::nullopt;
Expand All @@ -228,6 +230,13 @@ class CBlockIndex
return proof.value();
}

const bool dynafed_block() const {
if (m_trimmed) {
return m_trimmed_dynafed_block;
}
return !m_dynafed_params.value().IsNull();
}

const DynaFedParams& dynafed_params() const {
assert_untrimmed();
return m_dynafed_params.value();
Expand Down
14 changes: 9 additions & 5 deletions src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,21 +777,25 @@ void SendCoinsDialog::useAvailableBalance(SendCoinsEntry* entry)
// Include watch-only for wallets without private key
m_coin_control->fAllowWatchOnly = model->wallet().privateKeysDisabled() && !model->wallet().hasExternalSigner();

SendAssetsRecipient recipient = entry->getValue();
// Calculate available amount to send.
CAmount amount = valueFor(model->wallet().getAvailableBalance(*m_coin_control), ::policyAsset);
CAmount amount = valueFor(model->wallet().getAvailableBalance(*m_coin_control), recipient.asset);
for (int i = 0; i < ui->entries->count(); ++i) {
SendCoinsEntry* e = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
if (e && !e->isHidden() && e != entry) {
if (e && !e->isHidden() && e != entry && e->getValue().asset == recipient.asset) {
amount -= e->getValue().asset_amount;
}
}

if (amount > 0) {
entry->checkSubtractFeeFromAmount();
entry->setAmount(amount);
if (recipient.asset == ::policyAsset) {
entry->checkSubtractFeeFromAmount();
}
recipient.asset_amount = amount;
} else {
entry->setAmount(0);
recipient.asset_amount = 0;
}
entry->setValue(recipient);
}

void SendCoinsDialog::updateFeeSectionControls()
Expand Down
10 changes: 2 additions & 8 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex
result.pushKV("difficulty", GetDifficulty(blockindex));
result.pushKV("chainwork", blockindex->nChainWork.GetHex());
} else {
if (blockindex->dynafed_params().IsNull()) {
if (!blockindex->dynafed_block()) {
if (blockindex->trimmed()) {
result.pushKV("signblock_witness_asm", "<trimmed>");
result.pushKV("signblock_witness_hex", "<trimmed>");
Expand Down Expand Up @@ -280,13 +280,7 @@ UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex

UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, bool txDetails)
{
UniValue result;
if (blockindex->trimmed()) {
CBlockIndex tmp = CBlockIndex(block.GetBlockHeader());
result = blockheaderToJSON(tip, &tmp);
} else {
result = blockheaderToJSON(tip, blockindex);
}
UniValue result = blockheaderToJSON(tip, blockindex);

result.pushKV("strippedsize", (int)::GetSerializeSize(block, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS));
result.pushKV("size", (int)::GetSerializeSize(block, PROTOCOL_VERSION));
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,7 @@ static RPCHelpMan testproposedblock()
"\nChecks a block proposal for validity, and that it extends chaintip\n",
{
{"blockhex", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex-encoded block from getnewblockhex"},
{"acceptnonstd", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED_NAMED_ARG, "If set false, returns error if block contains non-standard transaction. Default is set via `-acceptnonstdtxn`. If PAK enforcement is set, block commitment mismatches with configuration PAK lists are rejected as well."},
{"acceptnonstd", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED_NAMED_ARG, "If set false, returns error if block contains non-standard transaction. Default is set via `-acceptnonstdtxn`."},
},
RPCResult{RPCResult::Type::NONE, "", ""},
RPCExamples{
Expand Down
1 change: 1 addition & 0 deletions src/txdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams,
}
} else {
pindexNew->m_trimmed = true;
pindexNew->m_trimmed_dynafed_block = !diskindex.m_dynafed_params.value().IsNull();
}

pcursor->Next();
Expand Down

0 comments on commit 9d61734

Please sign in to comment.