fixed Carrot mining; added support for dedicated Carrot wallet addresses with SC1 prefix

This commit is contained in:
Some Random Crypto Guy
2025-07-03 23:08:24 +01:00
parent 520d4b4eab
commit b7cc8e8100
9 changed files with 89 additions and 18 deletions
+8
View File
@@ -276,6 +276,14 @@ DISABLE_VS_WARNINGS(4244 4345)
//TODO: change this code into base 58
return get_account_address_as_str(nettype, false, m_keys.m_account_address);
}
//----------------------------------------------------------------------------------------------------------------------
std::string account_base::get_carrot_public_address_str(network_type nettype) const
{
// Build the cryptonote::account_public_address
account_public_address addr{m_keys.m_carrot_account_address.m_spend_public_key, m_keys.m_account_address.m_view_public_key};
// change this code into base 58
return get_account_address_as_str(nettype, false, addr, true);
}
//-----------------------------------------------------------------
std::string account_base::get_public_integrated_address_str(const crypto::hash8 &payment_id, network_type nettype) const
{
+2 -1
View File
@@ -61,7 +61,7 @@ namespace cryptonote
crypto::secret_key k_generate_image;
crypto::secret_key s_generate_address;
// carrot public keys (minus K^0_v, which is shared with legacy K^0_v)
// carrot public keys (minus K_v, which is shared with legacy K_v)
account_public_address m_carrot_account_address;
@@ -101,6 +101,7 @@ namespace cryptonote
bool make_multisig(const crypto::secret_key &view_secret_key, const crypto::secret_key &spend_secret_key, const crypto::public_key &spend_public_key, const std::vector<crypto::secret_key> &multisig_keys);
const account_keys& get_keys() const;
std::string get_public_address_str(network_type nettype) const;
std::string get_carrot_public_address_str(network_type nettype) const;
std::string get_public_integrated_address_str(const crypto::hash8 &payment_id, network_type nettype) const;
hw::device& get_device() const {return m_keys.get_device();}
+35 -3
View File
@@ -155,9 +155,12 @@ namespace cryptonote {
network_type nettype
, bool subaddress
, account_public_address const & adr
, bool is_carrot
)
{
uint64_t address_prefix = subaddress ? get_config(nettype).CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX : get_config(nettype).CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX;
uint64_t address_prefix = is_carrot
? (subaddress ? get_config(nettype).CARROT_PUBLIC_SUBADDRESS_BASE58_PREFIX : get_config(nettype).CARROT_PUBLIC_ADDRESS_BASE58_PREFIX)
: (subaddress ? get_config(nettype).CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX : get_config(nettype).CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX);
return tools::base58::encode_addr(address_prefix, t_serializable_object_to_blob(adr));
}
@@ -166,9 +169,10 @@ namespace cryptonote {
network_type nettype
, account_public_address const & adr
, crypto::hash8 const & payment_id
, bool is_carrot
)
{
uint64_t integrated_address_prefix = get_config(nettype).CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX;
uint64_t integrated_address_prefix = is_carrot ? get_config(nettype).CARROT_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX : get_config(nettype).CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX;
integrated_address iadr = {
adr, payment_id
@@ -196,6 +200,9 @@ namespace cryptonote {
uint64_t address_prefix = get_config(nettype).CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX;
uint64_t integrated_address_prefix = get_config(nettype).CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX;
uint64_t subaddress_prefix = get_config(nettype).CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX;
uint64_t carrot_address_prefix = get_config(nettype).CARROT_PUBLIC_ADDRESS_BASE58_PREFIX;
uint64_t carrot_integrated_address_prefix = get_config(nettype).CARROT_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX;
uint64_t carrot_subaddress_prefix = get_config(nettype).CARROT_PUBLIC_SUBADDRESS_BASE58_PREFIX;
if (2 * sizeof(public_address_outer_blob) != str.size())
{
@@ -211,21 +218,45 @@ namespace cryptonote {
{
info.is_subaddress = false;
info.has_payment_id = true;
info.is_carrot = false;
}
else if (address_prefix == prefix)
{
info.is_subaddress = false;
info.has_payment_id = false;
info.is_carrot = false;
}
else if (subaddress_prefix == prefix)
{
info.is_subaddress = true;
info.has_payment_id = false;
info.is_carrot = false;
}
else if (carrot_integrated_address_prefix == prefix)
{
info.is_subaddress = false;
info.has_payment_id = true;
info.is_carrot = true;
}
else if (carrot_address_prefix == prefix)
{
info.is_subaddress = false;
info.has_payment_id = false;
info.is_carrot = true;
}
else if (carrot_subaddress_prefix == prefix)
{
info.is_subaddress = true;
info.has_payment_id = false;
info.is_carrot = true;
}
else {
LOG_PRINT_L1("Wrong address prefix: " << prefix << ", expected " << address_prefix
<< " or " << integrated_address_prefix
<< " or " << subaddress_prefix);
<< " or " << subaddress_prefix
<< " or " << carrot_address_prefix
<< " or " << carrot_integrated_address_prefix
<< " or " << carrot_subaddress_prefix);
return false;
}
@@ -287,6 +318,7 @@ namespace cryptonote {
info.address = blob.m_address;
info.is_subaddress = false;
info.has_payment_id = false;
info.is_carrot = false;
}
return true;
@@ -71,6 +71,7 @@ namespace cryptonote {
account_public_address address;
bool is_subaddress;
bool has_payment_id;
bool is_carrot;
crypto::hash8 payment_id;
};
@@ -87,12 +88,14 @@ namespace cryptonote {
network_type nettype
, bool subaddress
, const account_public_address& adr
, bool is_carrot = false
);
std::string get_account_integrated_address_as_str(
network_type nettype
, const account_public_address& adr
, const crypto::hash8& payment_id
, bool is_carrot = false
);
bool get_account_address_from_str(