From 7d1c36322c7a65a7b5449fe9f8c6f279c2ebe122 Mon Sep 17 00:00:00 2001 From: Martin Kuvandzhiev Date: Tue, 16 Jan 2018 13:26:06 +0200 Subject: [PATCH] Added support for ZClassic. Also corrected BTG block explorer (#157) * Added correct BTG block explorer * Added ZClassic * Miner fixed to support ZCL * Added ZCL to equihash coins * Fixed incorrect way of typing Zclassic * Cleaned coinmetadata file * Trying to fix the whole changed file from git * Fixed rejected segwit blocks in BTG - https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki --- .../Blockchain/Bitcoin/BitcoinConstants.cs | 1 + .../Blockchain/Bitcoin/BitcoinProperties.cs | 1 + .../Blockchain/BitcoinGold/BitcoinGoldJob.cs | 2 +- src/MiningCore/Blockchain/CoinMetaData.cs | 191 +++++++++--------- .../Blockchain/ZCash/ZCashConstants.cs | 47 +++++ .../Blockchain/ZCash/ZCashPayoutHandler.cs | 2 +- src/MiningCore/Blockchain/ZCash/ZCashPool.cs | 2 +- src/MiningCore/Configuration/ClusterConfig.cs | 1 + 8 files changed, 150 insertions(+), 97 deletions(-) diff --git a/src/MiningCore/Blockchain/Bitcoin/BitcoinConstants.cs b/src/MiningCore/Blockchain/Bitcoin/BitcoinConstants.cs index cf61c495a..13fe0b9c1 100644 --- a/src/MiningCore/Blockchain/Bitcoin/BitcoinConstants.cs +++ b/src/MiningCore/Blockchain/Bitcoin/BitcoinConstants.cs @@ -92,6 +92,7 @@ public class KnownAddresses {CoinType.MONA, "MBbkeAM3VQKg474bgxJEXrtcnMg8cjHY3S"}, {CoinType.VTC, "VfCAvPVrksYvwcpU7E44e51HxfvVhcxMXf"}, {CoinType.ZEC, "t1YHZHz2DGVMJiggD2P4fBQ2TAPgtLSUwZ7"}, + {CoinType.ZCL, "t1Ysa2CHdpMu8T2zjYXQNQxPgGh8ehe9QYo"}, {CoinType.BTG, "GQb77ZuMCyJGZFyxpzqNfm7GB1rQreP4n6"}, {CoinType.XMR, "475YVJbPHPedudkhrcNp1wDcLMTGYusGPF5fqE7XjnragVLPdqbCHBdZg3dF4dN9hXMjjvGbykS6a77dTAQvGrpiQqHp2eH"} }; diff --git a/src/MiningCore/Blockchain/Bitcoin/BitcoinProperties.cs b/src/MiningCore/Blockchain/Bitcoin/BitcoinProperties.cs index 4e96d1558..701b1b3d3 100644 --- a/src/MiningCore/Blockchain/Bitcoin/BitcoinProperties.cs +++ b/src/MiningCore/Blockchain/Bitcoin/BitcoinProperties.cs @@ -101,6 +101,7 @@ public class BitcoinProperties // Equihash { CoinType.ZEC, equihashCoin }, { CoinType.BTG, equihashCoin }, + { CoinType.ZCL, equihashCoin }, }; public static BitcoinCoinProperties GetCoinProperties(CoinType coin, string algorithm = null) diff --git a/src/MiningCore/Blockchain/BitcoinGold/BitcoinGoldJob.cs b/src/MiningCore/Blockchain/BitcoinGold/BitcoinGoldJob.cs index 0952f2ae7..5906f9ad1 100644 --- a/src/MiningCore/Blockchain/BitcoinGold/BitcoinGoldJob.cs +++ b/src/MiningCore/Blockchain/BitcoinGold/BitcoinGoldJob.cs @@ -125,7 +125,7 @@ public override void Init(ZCashBlockTemplate blockTemplate, string jobId, // build tx hashes var txHashes = new List { new uint256(coinbaseInitialHash) }; - txHashes.AddRange(BlockTemplate.Transactions.Select(tx => new uint256(tx.Hash.HexToByteArray().ReverseArray()))); + txHashes.AddRange(BlockTemplate.Transactions.Select(tx => new uint256(tx.TxId.HexToByteArray().ReverseArray()))); // build merkle root merkleRoot = MerkleNode.GetRoot(txHashes).Hash.ToBytes().ReverseArray(); diff --git a/src/MiningCore/Blockchain/CoinMetaData.cs b/src/MiningCore/Blockchain/CoinMetaData.cs index 888be0b08..264d83eaf 100644 --- a/src/MiningCore/Blockchain/CoinMetaData.cs +++ b/src/MiningCore/Blockchain/CoinMetaData.cs @@ -1,94 +1,97 @@ -using System.Collections.Generic; -using MiningCore.Blockchain.Ethereum; -using MiningCore.Configuration; - -namespace MiningCore.Blockchain -{ - public static class CoinMetaData - { - public static readonly Dictionary> BlockInfoLinks = new Dictionary> - { - { CoinType.ETH, new Dictionary - { - { string.Empty, "https://etherscan.io/block/{0}" }, - { EthereumConstants.BlockTypeUncle, "https://etherscan.io/uncle/{0}" }, - }}, - - { CoinType.ETC, new Dictionary - { - { string.Empty, "https://gastracker.io/block/{0}" }, - { EthereumConstants.BlockTypeUncle, "https://gastracker.io/uncle/{0}" } - }}, - - { CoinType.XMR, new Dictionary { { string.Empty, "https://chainradar.com/xmr/block/{0}" }}}, - { CoinType.ETN, new Dictionary { { string.Empty, "https://blockexplorer.electroneum.com/block/{0}" } }}, - { CoinType.LTC, new Dictionary { { string.Empty, "http://explorer.litecoin.net/block/{0}" }}}, - { CoinType.BCH, new Dictionary { { string.Empty, "https://www.blocktrail.com/BCC/block/{0}" }}}, - { CoinType.DASH, new Dictionary { { string.Empty, "https://chainz.cryptoid.info/dash/block.dws?{0}.htm" }}}, - { CoinType.BTC, new Dictionary { { string.Empty, "https://blockchain.info/block/{0}" }}}, - { CoinType.DOGE, new Dictionary { { string.Empty, "https://dogechain.info/block/{0}" }}}, - { CoinType.ZEC, new Dictionary { { string.Empty, "https://explorer.zcha.in/blocks/{0}" }}}, - { CoinType.DGB, new Dictionary { { string.Empty, "https://digiexplorer.info/block/{0}" }}}, - { CoinType.NMC, new Dictionary { { string.Empty, "https://explorer.namecoin.info/b/{0}" }}}, - { CoinType.GRS, new Dictionary { { string.Empty, "https://groestlsight.groestlcoin.org/block/{0}" }}}, - { CoinType.MONA, new Dictionary { { string.Empty, "https://bchain.info/MONA/block/{0}" }}}, - { CoinType.GLT, new Dictionary { { string.Empty, "https://bchain.info/GLT/block/{0}" }}}, - { CoinType.VTC, new Dictionary { { string.Empty, "https://bchain.info/VTC/block/{0}" }}}, - //{ CoinType.BTG, new Dictionary { { string.Empty, "https://btgexp.com/block/{0}" }}}, - { CoinType.ELLA, new Dictionary { { string.Empty, "https://explorer.ellaism.org/block/{0}" }}}, - { CoinType.EXP, new Dictionary { { string.Empty, "http://www.gander.tech/blocks/{0}" }}}, - { CoinType.AEON, new Dictionary { { string.Empty, "https://chainradar.com/aeon/block/{0}" }}}, - { CoinType.STAK, new Dictionary { { string.Empty, "https://straks.info/block/{0}" }}}, - { CoinType.MOON, new Dictionary { { string.Empty, " https://chainz.cryptoid.info/moon/block.dws?{0}.htm" }}}, - }; - - public static readonly Dictionary PaymentInfoLinks = new Dictionary - { - { CoinType.XMR, "https://chainradar.com/xmr/transaction/{0}" }, - { CoinType.ETN, "https://blockexplorer.electroneum.com/tx/{0}" }, - { CoinType.ETH, "https://etherscan.io/tx/{0}" }, - { CoinType.ETC, "https://gastracker.io/tx/{0}" }, - { CoinType.LTC, "http://explorer.litecoin.net/tx/{0}" }, - { CoinType.BCH, "https://www.blocktrail.com/BCC/tx/{0}" }, - { CoinType.DASH, "https://chainz.cryptoid.info/dash/tx.dws?{0}.htm" }, - { CoinType.BTC, "https://blockchain.info/tx/{0}" }, - { CoinType.DOGE, "https://dogechain.info/tx/{0}" }, - { CoinType.ZEC, "https://explorer.zcha.in/transactions/{0}" }, - { CoinType.DGB, "https://digiexplorer.info/tx/{0}" }, - { CoinType.NMC, "https://explorer.namecoin.info/tx/{0}" }, - { CoinType.GRS, "https://groestlsight.groestlcoin.org/tx/{0}" }, - { CoinType.MONA, "https://bchain.info/MONA/tx/{0}" }, - { CoinType.STAK, "https://straks.info/transaction/{0}" }, - { CoinType.GLT, "https://bchain.info/GLT/tx/{0}" }, - { CoinType.VTC, "https://bchain.info/VTC/tx/{0}" }, - { CoinType.BTG, "https://btgexp.com/tx/{0}" }, - { CoinType.ELLA, "https://explorer.ellaism.org/tx/{0}" }, - { CoinType.EXP, "http://www.gander.tech/tx/{0}" }, - { CoinType.AEON, "https://chainradar.com/aeon/transaction/{0}" }, - { CoinType.MOON, "https://chainz.cryptoid.info/moon/tx.dws?{0}.htm" }, - }; - - public static readonly Dictionary AddressInfoLinks = new Dictionary - { - { CoinType.ETH, "https://etherscan.io/address/{0}" }, - { CoinType.ETC, "https://gastracker.io/addr/{0}" }, - { CoinType.LTC, "http://explorer.litecoin.net/address/{0}" }, - { CoinType.BCH, "https://www.blocktrail.com/BCC/address/{0}" }, - { CoinType.DASH, "https://chainz.cryptoid.info/dash/address.dws?{0}.htm" }, - { CoinType.BTC, "https://blockchain.info/address/{0}" }, - { CoinType.DOGE, "https://dogechain.info/address/{0}" }, - { CoinType.ZEC, "https://explorer.zcha.in/accounts/{0}" }, - { CoinType.DGB, "https://digiexplorer.info/address/{0}" }, - { CoinType.NMC, "https://explorer.namecoin.info/a/{0}" }, - { CoinType.GRS, "https://groestlsight.groestlcoin.org/address/{0}" }, - { CoinType.MONA, "https://bchain.info/MONA/addr/{0}" }, - { CoinType.STAK, "https://straks.info/address/{0}" }, - { CoinType.GLT, "https://bchain.info/GLT/addr/{0}" }, - { CoinType.VTC, "https://bchain.info/VTC/addr/{0}" }, - { CoinType.BTG, "https://btgexp.com/address/{0}" }, - { CoinType.ELLA, "https://explorer.ellaism.org/addr/{0}" }, - { CoinType.EXP, "http://www.gander.tech/address/{0}" }, - { CoinType.MOON, "https://chainz.cryptoid.info/moon/address.dws?{0}.htm" }, - }; - } -} +using System.Collections.Generic; +using MiningCore.Blockchain.Ethereum; +using MiningCore.Configuration; + +namespace MiningCore.Blockchain +{ + public static class CoinMetaData + { + public static readonly Dictionary> BlockInfoLinks = new Dictionary> + { + { CoinType.ETH, new Dictionary + { + { string.Empty, "https://etherscan.io/block/{0}" }, + { EthereumConstants.BlockTypeUncle, "https://etherscan.io/uncle/{0}" }, + }}, + + { CoinType.ETC, new Dictionary + { + { string.Empty, "https://gastracker.io/block/{0}" }, + { EthereumConstants.BlockTypeUncle, "https://gastracker.io/uncle/{0}" } + }}, + + { CoinType.XMR, new Dictionary { { string.Empty, "https://chainradar.com/xmr/block/{0}" }}}, + { CoinType.ETN, new Dictionary { { string.Empty, "https://blockexplorer.electroneum.com/block/{0}" } }}, + { CoinType.LTC, new Dictionary { { string.Empty, "http://explorer.litecoin.net/block/{0}" }}}, + { CoinType.BCH, new Dictionary { { string.Empty, "https://www.blocktrail.com/BCC/block/{0}" }}}, + { CoinType.DASH, new Dictionary { { string.Empty, "https://chainz.cryptoid.info/dash/block.dws?{0}.htm" }}}, + { CoinType.BTC, new Dictionary { { string.Empty, "https://blockchain.info/block/{0}" }}}, + { CoinType.DOGE, new Dictionary { { string.Empty, "https://dogechain.info/block/{0}" }}}, + { CoinType.ZEC, new Dictionary { { string.Empty, "https://explorer.zcha.in/blocks/{0}" }}}, + { CoinType.ZCL, new Dictionary { { string.Empty, "http://explorer.zclmine.pro/blocks/{0}" }}}, + { CoinType.DGB, new Dictionary { { string.Empty, "https://digiexplorer.info/block/{0}" }}}, + { CoinType.NMC, new Dictionary { { string.Empty, "https://explorer.namecoin.info/b/{0}" }}}, + { CoinType.GRS, new Dictionary { { string.Empty, "https://groestlsight.groestlcoin.org/block/{0}" }}}, + { CoinType.MONA, new Dictionary { { string.Empty, "https://bchain.info/MONA/block/{0}" }}}, + { CoinType.GLT, new Dictionary { { string.Empty, "https://bchain.info/GLT/block/{0}" }}}, + { CoinType.VTC, new Dictionary { { string.Empty, "https://bchain.info/VTC/block/{0}" }}}, + { CoinType.BTG, new Dictionary { { string.Empty, "https://btg-bitcore2.trezor.io/block/{0}" }}}, + { CoinType.ELLA, new Dictionary { { string.Empty, "https://explorer.ellaism.org/block/{0}" }}}, + { CoinType.EXP, new Dictionary { { string.Empty, "http://www.gander.tech/blocks/{0}" }}}, + { CoinType.AEON, new Dictionary { { string.Empty, "https://chainradar.com/aeon/block/{0}" }}}, + { CoinType.STAK, new Dictionary { { string.Empty, "https://straks.info/block/{0}" }}}, + { CoinType.MOON, new Dictionary { { string.Empty, " https://chainz.cryptoid.info/moon/block.dws?{0}.htm" }}}, + }; + + public static readonly Dictionary PaymentInfoLinks = new Dictionary + { + { CoinType.XMR, "https://chainradar.com/xmr/transaction/{0}" }, + { CoinType.ETN, "https://blockexplorer.electroneum.com/tx/{0}" }, + { CoinType.ETH, "https://etherscan.io/tx/{0}" }, + { CoinType.ETC, "https://gastracker.io/tx/{0}" }, + { CoinType.LTC, "http://explorer.litecoin.net/tx/{0}" }, + { CoinType.BCH, "https://www.blocktrail.com/BCC/tx/{0}" }, + { CoinType.DASH, "https://chainz.cryptoid.info/dash/tx.dws?{0}.htm" }, + { CoinType.BTC, "https://blockchain.info/tx/{0}" }, + { CoinType.DOGE, "https://dogechain.info/tx/{0}" }, + { CoinType.ZEC, "https://explorer.zcha.in/transactions/{0}" }, + { CoinType.ZCL, "http://explorer.zclmine.pro/transactions/{0}" }, + { CoinType.DGB, "https://digiexplorer.info/tx/{0}" }, + { CoinType.NMC, "https://explorer.namecoin.info/tx/{0}" }, + { CoinType.GRS, "https://groestlsight.groestlcoin.org/tx/{0}" }, + { CoinType.MONA, "https://bchain.info/MONA/tx/{0}" }, + { CoinType.STAK, "https://straks.info/transaction/{0}" }, + { CoinType.GLT, "https://bchain.info/GLT/tx/{0}" }, + { CoinType.VTC, "https://bchain.info/VTC/tx/{0}" }, + { CoinType.BTG, "https://btgexp.com/tx/{0}" }, + { CoinType.ELLA, "https://explorer.ellaism.org/tx/{0}" }, + { CoinType.EXP, "http://www.gander.tech/tx/{0}" }, + { CoinType.AEON, "https://chainradar.com/aeon/transaction/{0}" }, + { CoinType.MOON, "https://chainz.cryptoid.info/moon/tx.dws?{0}.htm" }, + }; + + public static readonly Dictionary AddressInfoLinks = new Dictionary + { + { CoinType.ETH, "https://etherscan.io/address/{0}" }, + { CoinType.ETC, "https://gastracker.io/addr/{0}" }, + { CoinType.LTC, "http://explorer.litecoin.net/address/{0}" }, + { CoinType.BCH, "https://www.blocktrail.com/BCC/address/{0}" }, + { CoinType.DASH, "https://chainz.cryptoid.info/dash/address.dws?{0}.htm" }, + { CoinType.BTC, "https://blockchain.info/address/{0}" }, + { CoinType.DOGE, "https://dogechain.info/address/{0}" }, + { CoinType.ZEC, "https://explorer.zcha.in/accounts/{0}" }, + { CoinType.ZCL, "http://explorer.zclmine.pro/accounts/{0}" }, + { CoinType.DGB, "https://digiexplorer.info/address/{0}" }, + { CoinType.NMC, "https://explorer.namecoin.info/a/{0}" }, + { CoinType.GRS, "https://groestlsight.groestlcoin.org/address/{0}" }, + { CoinType.MONA, "https://bchain.info/MONA/addr/{0}" }, + { CoinType.STAK, "https://straks.info/address/{0}" }, + { CoinType.GLT, "https://bchain.info/GLT/addr/{0}" }, + { CoinType.VTC, "https://bchain.info/VTC/addr/{0}" }, + { CoinType.BTG, "https://btgexp.com/address/{0}" }, + { CoinType.ELLA, "https://explorer.ellaism.org/addr/{0}" }, + { CoinType.EXP, "http://www.gander.tech/address/{0}" }, + { CoinType.MOON, "https://chainz.cryptoid.info/moon/address.dws?{0}.htm" }, + }; + } +} diff --git a/src/MiningCore/Blockchain/ZCash/ZCashConstants.cs b/src/MiningCore/Blockchain/ZCash/ZCashConstants.cs index 50f59240d..fd94ae50f 100644 --- a/src/MiningCore/Blockchain/ZCash/ZCashConstants.cs +++ b/src/MiningCore/Blockchain/ZCash/ZCashConstants.cs @@ -119,11 +119,58 @@ public class ZCashConstants } }, }; + + private static readonly Dictionary ZCLCoinbaseTxConfig = new Dictionary + { + { + BitcoinNetworkType.Main, new ZCashCoinbaseTxConfig + { + PayFoundersReward = false, + PercentFoundersReward = 0, + FoundersRewardSubsidyHalvingInterval = 0, + FoundersRewardSubsidySlowStartInterval = 0, + + FoundersRewardAddresses = new[] + { + "" + } + } + }, + { + BitcoinNetworkType.Test, new ZCashCoinbaseTxConfig + { + PayFoundersReward = false, + PercentFoundersReward = 0, + FoundersRewardSubsidyHalvingInterval = 0, + FoundersRewardSubsidySlowStartInterval = 0, + + FoundersRewardAddresses = new[] + { + "" + } + } + }, + { + BitcoinNetworkType.RegTest, new ZCashCoinbaseTxConfig + { + PayFoundersReward = false, + PercentFoundersReward = 0, + FoundersRewardSubsidyHalvingInterval = 0, + FoundersRewardSubsidySlowStartInterval = 0, + + FoundersRewardAddresses = new[] + { + "" + } + } + }, + }; public static Dictionary> CoinbaseTxConfig = new Dictionary> { { CoinType.ZEC, ZCashCoinbaseTxConfig }, + { CoinType.ZCL, ZCLCoinbaseTxConfig } }; } diff --git a/src/MiningCore/Blockchain/ZCash/ZCashPayoutHandler.cs b/src/MiningCore/Blockchain/ZCash/ZCashPayoutHandler.cs index 6ea1826d8..b707341f7 100644 --- a/src/MiningCore/Blockchain/ZCash/ZCashPayoutHandler.cs +++ b/src/MiningCore/Blockchain/ZCash/ZCashPayoutHandler.cs @@ -39,7 +39,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. namespace MiningCore.Blockchain.ZCash { - [CoinMetadata(CoinType.ZEC)] + [CoinMetadata(CoinType.ZEC, CoinType.ZCL)] public class ZCashPayoutHandler : BitcoinPayoutHandler { public ZCashPayoutHandler( diff --git a/src/MiningCore/Blockchain/ZCash/ZCashPool.cs b/src/MiningCore/Blockchain/ZCash/ZCashPool.cs index 458f69e23..1cf2ca629 100644 --- a/src/MiningCore/Blockchain/ZCash/ZCashPool.cs +++ b/src/MiningCore/Blockchain/ZCash/ZCashPool.cs @@ -32,7 +32,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. namespace MiningCore.Blockchain.ZCash { - [CoinMetadata(CoinType.ZEC)] + [CoinMetadata(CoinType.ZEC, CoinType.ZCL)] public class ZCashPool : ZCashPoolBase { public ZCashPool(IComponentContext ctx, diff --git a/src/MiningCore/Configuration/ClusterConfig.cs b/src/MiningCore/Configuration/ClusterConfig.cs index 1f79755ae..359245535 100644 --- a/src/MiningCore/Configuration/ClusterConfig.cs +++ b/src/MiningCore/Configuration/ClusterConfig.cs @@ -38,6 +38,7 @@ public enum CoinType VIA, // Viacoin PPC, // Peercoin ZEC, // ZCash + ZCL, // Zcassic ETH, // Ethereum ETC, // Ethereum Classic EXP, // Expanse