Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for townforge (monero fork using randomx) #3391

Merged
merged 1 commit into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/base/crypto/Coin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ static const CoinInfo coinInfo[] = {
{ Algorithm::KAWPOW_RVN, "RVN", "Ravencoin", 0, 0, BLUE_BG_BOLD( WHITE_BOLD_S " raven ") },
{ Algorithm::RX_WOW, "WOW", "Wownero", 300, 100000000000, MAGENTA_BG_BOLD(WHITE_BOLD_S " wownero ") },
{ Algorithm::RX_0, "ZEPH", "Zephyr", 120, 1000000000000, BLUE_BG_BOLD( WHITE_BOLD_S " zephyr ") },
{ Algorithm::RX_0, "Townforge","Townforge", 30, 100000000, MAGENTA_BG_BOLD(WHITE_BOLD_S " townforge ") },
};


Expand Down
1 change: 1 addition & 0 deletions src/base/crypto/Coin.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Coin
RAVEN,
WOWNERO,
ZEPHYR,
TOWNFORGE,
MAX
};

Expand Down
10 changes: 9 additions & 1 deletion src/base/tools/cryptonote/BlockTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ bool xmrig::BlockTemplate::parse(bool hashes)
setOffset(MINER_TX_PREFIX_OFFSET, ar.index());

ar(m_txVersion);
ar(m_unlockTime);
if (m_coin != Coin::TOWNFORGE)
ar(m_unlockTime);
ar(m_numInputs);

// must be 1 input
Expand Down Expand Up @@ -280,6 +281,9 @@ bool xmrig::BlockTemplate::parse(bool hashes)
ar(m_viewTag);
}

if (m_coin == Coin::TOWNFORGE)
ar(m_unlockTime);

ar(m_extraSize);

setOffset(TX_EXTRA_OFFSET, ar.index());
Expand Down Expand Up @@ -335,6 +339,10 @@ bool xmrig::BlockTemplate::parse(bool hashes)
uint8_t vin_rct_type = 0;
ar(vin_rct_type);

// no way I'm parsing a full game update here
if (m_coin == Coin::TOWNFORGE && m_height % 720 == 0)
return true;

// must be RCTTypeNull (0)
if (vin_rct_type != 0) {
return false;
Expand Down
33 changes: 33 additions & 0 deletions src/base/tools/cryptonote/WalletAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@

bool xmrig::WalletAddress::decode(const char *address, size_t size)
{
uint64_t tf_tag = 0;
if (size >= 4 && !strncmp(address, "TF", 2))
{
tf_tag = 0x424200;
switch (address[2])
{
case '1': tf_tag |= 0; break;
case '2': tf_tag |= 1; break;
default: tf_tag = 0; return false;
}
switch (address[3]) {
case 'M': tf_tag |= 0; break;
case 'T': tf_tag |= 0x10; break;
case 'S': tf_tag |= 0x20; break;
default: tf_tag = 0; return false;
}
address += 4;
size -= 4;
}

static constexpr std::array<int, 9> block_sizes{ 0, 2, 3, 5, 6, 7, 9, 10, 11 };
static constexpr char alphabet[] = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
constexpr size_t alphabet_size = sizeof(alphabet) - 1;
Expand Down Expand Up @@ -114,6 +134,9 @@ bool xmrig::WalletAddress::decode(const char *address, size_t size)
if (memcmp(m_checksum, md, sizeof(m_checksum)) == 0) {
m_data = { address, size };

if (tf_tag)
m_tag = tf_tag;

return true;
}
}
Expand Down Expand Up @@ -228,6 +251,16 @@ const xmrig::WalletAddress::TagInfo &xmrig::WalletAddress::tagInfo(uint64_t tag)
{ 0x54, { Coin::GRAFT, TESTNET, PUBLIC, 28881, 28882 } },
{ 0x55, { Coin::GRAFT, TESTNET, INTEGRATED, 28881, 28882 } },
{ 0x70, { Coin::GRAFT, TESTNET, SUBADDRESS, 28881, 28882 } },

{ 0x424200, { Coin::TOWNFORGE, MAINNET, PUBLIC, 18881, 18882 } },
{ 0x424201, { Coin::TOWNFORGE, MAINNET, SUBADDRESS, 18881, 18882 } },

{ 0x424210, { Coin::TOWNFORGE, TESTNET, PUBLIC, 28881, 28882 } },
{ 0x424211, { Coin::TOWNFORGE, TESTNET, SUBADDRESS, 28881, 28882 } },

{ 0x424220, { Coin::TOWNFORGE, STAGENET, PUBLIC, 38881, 38882 } },
{ 0x424221, { Coin::TOWNFORGE, STAGENET, SUBADDRESS, 38881, 38882 } },

};

const auto it = tags.find(tag);
Expand Down