Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Fix missing support for Monero subaddresses
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Weichhold committed Sep 26, 2022
1 parent 5279ce5 commit 1b110d6
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 12 deletions.
9 changes: 9 additions & 0 deletions src/Miningcore.Tests/Crypto/CrytonoteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ public void Crytonote_DecodeAddress()
Assert.Equal(18ul, result);
}

[Fact]
public void Crytonote_DecodeSubAddress()
{
var address = "84k5FLcuZeQ9vUmTfRJkpxCxdppVF5wWdPpxhU4SdTZmAD1i1YH81rPf8XRAsbpc7Na4GG7A8xscjQbqMETLZCXZ7Cdfb7X";
var result = CryptonoteBindings.DecodeAddress(address);

Assert.Equal(42ul, result);
}

[Fact]
public void Cryptonote_DecodeAddress_Should_Throw_On_Null_Or_Empty_Argument()
{
Expand Down
3 changes: 3 additions & 0 deletions src/Miningcore/Blockchain/Cryptonote/CryptonoteJobManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,18 +330,21 @@ public bool ValidateAddress(string address)
{
case CryptonoteNetworkType.Main:
if(addressPrefix != coin.AddressPrefix &&
addressPrefix != coin.SubAddressPrefix &&
addressIntegratedPrefix != coin.AddressPrefixIntegrated)
return false;
break;

case CryptonoteNetworkType.Test:
if(addressPrefix != coin.AddressPrefixTestnet &&
addressPrefix != coin.SubAddressPrefixTestnet &&
addressIntegratedPrefix != coin.AddressPrefixIntegratedTestnet)
return false;
break;

case CryptonoteNetworkType.Stage:
if(addressPrefix != coin.AddressPrefixStagenet &&
addressPrefix != coin.SubAddressPrefixStagenet &&
addressIntegratedPrefix != coin.AddressPrefixIntegratedStagenet)
return false;
break;
Expand Down
18 changes: 18 additions & 0 deletions src/Miningcore/Configuration/ClusterConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,18 +434,36 @@ public partial class CryptonoteCoinTemplate : CoinTemplate
/// </summary>
public ulong AddressPrefix { get; set; }

/// <summary>
/// Sub Prefix of a valid sub address
/// See: namespace config -> CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX in src/cryptonote_config.h
/// </summary>
public ulong SubAddressPrefix { get; set; }

/// <summary>
/// Prefix of a valid testnet-address
/// See: namespace config -> CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX in src/cryptonote_config.h
/// </summary>
public ulong AddressPrefixTestnet { get; set; }

/// <summary>
/// Sub Prefix of a valid testnet-address
/// See: namespace config -> CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX in src/cryptonote_config.h
/// </summary>
public ulong SubAddressPrefixTestnet { get; set; }

/// <summary>
/// Prefix of a valid stagenet-address
/// See: namespace config -> CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX in src/cryptonote_config.h
/// </summary>
public ulong AddressPrefixStagenet { get; set; }

/// <summary>
/// Sub Prefix of a valid stagenet-address
/// See: namespace config -> CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX in src/cryptonote_config.h
/// </summary>
public ulong SubAddressPrefixStagenet { get; set; }

/// <summary>
/// Prefix of a valid integrated address
/// See: namespace testnet -> CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX in src/cryptonote_config.h
Expand Down
27 changes: 15 additions & 12 deletions src/Miningcore/coins.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"actinium": {
"name": "Actinium",
"symbol": "ACM",
"family": "bitcoin",
"family": "bitcoin",
"website": "https://actinium.org/",
"market": "",
"twitter": "https://twitter.com/ActiniumCrypto",
Expand All @@ -57,7 +57,7 @@
"alpscoin": {
"name": "Alpenstars",
"symbol": "ALPS",
"family": "bitcoin",
"family": "bitcoin",
"website": "https://axerunners.com/",
"market": "",
"twitter": "https://twitter.com/search?q=$axe",
Expand Down Expand Up @@ -317,7 +317,7 @@
"explorerTxLink": "http://explorer.kriptokyng.com:3001/tx/{0}",
"explorerAccountLink": "http://explorer.kriptokyng.com:3001/address/{0}"
},

"bitcoin": {
"name": "Bitcoin",
"canonicalName": "Bitcoin",
Expand Down Expand Up @@ -548,7 +548,7 @@
"explorerTxLink": "https://blocks.butcoin.tech/tx/{0}",
"explorerAccountLink": "https://blocks.butcoin.tech/address/{0}"
},

"butkoin-scrypt": {
"name": "ButKoin Scrypt",
"canonicalName": "ButKoin",
Expand Down Expand Up @@ -614,7 +614,7 @@
"explorerTxLink": "https://blocks.butcoin.tech/tx/{0}",
"explorerAccountLink": "https://blocks.butcoin.tech/address/{0}"
},

"cannabiscoin": {
"name": "Cannabiscoin",
"canonicalName": "Cannabiscoin",
Expand Down Expand Up @@ -979,7 +979,7 @@
"explorerTxLink": "https://chainz.cryptoid.info/dem/tx.dws?{0}.htm",
"explorerAccountLink": "https://chainz.cryptoid.info/dem/address.dws?{0}.htm"
},

"emrals": {
"name": "Emrals",
"canonicalName": "Emrals",
Expand Down Expand Up @@ -1462,7 +1462,7 @@
"explorerAccountLink": "http://157.245.248.32:3000/#/address/{0}"
},


"lanacoin": {
"name": "Lanacoin",
"canonicalName": "Lana",
Expand Down Expand Up @@ -1994,7 +1994,7 @@
"explorerTxLink": "hhttps://eksplorator.polcoin.pl/tx/{0}",
"explorerAccountLink": "https://eksplorator.polcoin.pl/address/{0}"
},

"profithunters": {
"name": "Profit Hunters",
"symbol": "PHC",
Expand Down Expand Up @@ -2507,7 +2507,7 @@
"explorerTxLink": "https://explore.susukino.com/tx/{0}",
"explorerAccountLink": "https://explore.susukino.com/address/{0}"
},

"swippcoin": {
"name": "Swipp",
"symbol": "SWP",
Expand Down Expand Up @@ -2721,7 +2721,7 @@
"explorerTxLink": "https://explorer.tiltcoin.io/tx/{0}",
"explorerAccountLink": "https://explorer.tiltcoin.io/address/{0}"
},

"veco": {
"name": "Veco",
"canonicalName": "Veco",
Expand Down Expand Up @@ -2774,7 +2774,7 @@
"explorerTxLink": "https://chainz.cryptoid.info/vls/tx.dws?{0}.htm",
"explorerAccountLink": "https://chainz.cryptoid.info/vls/address.dws?{0}.htm"
},

"veles-scrypt": {
"name": "Veles Scrypt",
"canonicalName": "Veles",
Expand Down Expand Up @@ -3228,7 +3228,7 @@
"explorerTxLink": "https://explorer.yerbas.org/tx/{0}",
"explorerAccountLink": "https://explorer.yerbas.org/address/{0}"
},

"zetacoin": {
"name": "Zetacoin",
"canonicalName": "Zetacoin",
Expand Down Expand Up @@ -3994,6 +3994,9 @@
"addressPrefixIntegrated": 19,
"addressPrefixIntegratedStagenet": 25,
"addressPrefixIntegratedTestnet": 54,
"subAddressPrefix": 42,
"subAddressPrefixTestnet": 63,
"subAddressPrefixStagenet": 36,
"explorerBlockLink": "https://www.exploremonero.com/block/$height$",
"explorerTxLink": "https://www.exploremonero.com/transaction/{0}"
},
Expand Down

0 comments on commit 1b110d6

Please sign in to comment.