bonesoul / CoiniumServ

Next-gen crypto currency mining pool software
Other
801 stars 495 forks source link

CoiniumServ needs to add a new command for coin wallet v0.16.0 instead of use a getinfo() #975

Closed jeong760 closed 6 years ago

jeong760 commented 6 years ago

@bonesoul,

After I've upgrade of bitcoin and globaltoken wallet core v0.16.0 the following problem occurred. So could you give me an idea where I put new command for support and get following info from the new wallet?

[Information] [NetworkInfo] [Bitcoin] symbol: BTC algorithm: sha256 version: null protocol: 0 wallet: 0 network difficulty: 3007383866429.73000000 block difficulty: 3007383866429.73 network hashrate: 23.10 EH/s network: mainnet peers: 0 blocks: 512021 errors: none

07:14:51 [Error] [NetworkInfo] [Bitcoin] Can not read getinfo(): getinfo This call was removed in version 0.16.0. Use the appropriate fields from:

bitcoin-cli has the option -getinfo to collect and format these in the old format.

jeong760 commented 6 years ago

@bonesoul, I've partially solved an above problem after I modified some codes, but still does not get a peers: 0 and could not be removed a getinfo related message also.

src/CoiniumServ/Daemon/Responses

src/CoiniumServ/Pools

src/Test/Pools PoolTest.cs

The screenshot of CoiniumServ console after added a new command coiniumserv_console_180305

The error message related to getinfo command on bitcoin wallet v0.16.0 07:14:51 [Error] [NetworkInfo] [Bitcoin] Can not read getinfo(): getinfo This call was removed in version 0.16.0. Use the appropriate fields from:

getblockchaininfo: blocks, difficulty, chain getnetworkinfo: version, protocolversion, timeoffset, connections, proxy, relayfee, warnings getwalletinfo: balance, keypoololdest, keypoolsize, paytxfee, unlocked_until, walletversion

bitcoin-cli has the option -getinfo to collect and format these in the old format.

jeong760 commented 6 years ago

@bonesoul, I've solved a peers: 0. however getinfo related error does not solved yet. and mining seems works well

The screenshot solved did not get a peers info correctly coiniumserv_console_180305_1

The screenshot of CoiniumServ Web capture_20180305

jeong760 commented 6 years ago

@bonesoul, I think I need to create a source code for following new command under src/CoiniumServ/Daemon/Responses folder. So I need your help or guide for initial code form.

jeong760 commented 6 years ago

@bonesoul, Globaltoken does not use a "IsMine" to check the wallet address instead they recommend me to use a "getaddressinfo". Related to this I have the following errors.

23:10:34 [Error] [PaymentProcessor] [Globaltoken] Halted as daemon we are connected to does not own the pool address: GWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.

How and Where I put the command of getaddressinfo on CoiniumServ source code? The above issue related to following codes but I don't know how to add or insert a getaddressinfo

jeong760 commented 6 years ago

@bonesoul, Could you help me my last question about supporting a getaddressinfo for Globaltoken?

jeong760 commented 6 years ago

@bonesoul, In order to solved a [Error] [NetworkInfo] [Bitcoin] Can not read getinfo(): getinfo. if I inserted a following additional code, then does error message disappear on CoiniumServ console? How about your thought?

    public void Recache()
    {
                var Info= _daemonClient.Getnetworkinfo(); //Defined a Variables to get CoinVersion info
                CoinVersion = Info.Version; // CoinVersion is a string with version: 150100
                int version = Int32.Parse("CoinVersion"); // Convert a CoinVersion info to numeric value

        if (version == 150100)   // Compare the value same as condition, then running a GetInfo()

            try // read getinfo() based data.
            {
                var info = _daemonClient.GetInfo();

                //read data.
                CoinVersion = info.Version;
                ProtocolVersion = info.ProtocolVersion;
                WalletVersion = info.WalletVersion;
                Testnet = info.Testnet;
                Connections = info.Connections;
                Errors = info.Errors;

                // check if our network connection is healthy.
                Healthy = Connections >= 0 && string.IsNullOrEmpty(Errors);
            }
            catch (RpcException e)
            {
                _logger.Error("Can not read getinfo(): {0:l}", e.Message);
                Healthy = false; // set healthy status to false as we couldn't get a reply.
            }

        else // Except the version:150100, try to running following to get an info from the coin daemon

            try // read getblockchaininfo() based data.
            {
                var info = _daemonClient.GetBlockChainInfo();

                // read data.    
                // Blocks = info.Blocks;
                Testnet = info.Testnet;
                Errors = info.Errors;
            }
            catch (RpcException e)
            {
                _logger.Error("Can not read getblockchaininfo(): {0:l}", e.Message);
                Healthy = false; // set healthy status to false as we couldn't get a reply.
            }

            try // read getnetworkinfo() based data.
            {
                var info = _daemonClient.GetNetworkInfo();

                // read data.
                CoinVersion = info.Version;
                ProtocolVersion = info.ProtocolVersion;
                // TimeOffset = info.TimeOffset;
                Connections = info.Connections;
                Errors = info.Errors;

                // check if our network connection is healthy.
                Healthy = Connections >= 0 && string.IsNullOrEmpty(Errors);
            }
            catch (RpcException e)
            { 
                _logger.Error("Can not read getnetworkinfo(): {0:l}", e.Message);
                Healthy = false; // set healthy status to false as we couldn't get a reply.
            }

            try // read getwalletinfo() based data.
            {
                var info = _daemonClient.GetWalletInfo();

                // read data.
                WalletVersion = info.WalletVersion;
            }
            catch (RpcException e)
            {
                _logger.Error("Can not read getwalletinfo(): {0:l}", e.Message);
                Healthy = false; // set healthy status to false as we couldn't get a reply.
            }
      }
bonesoul commented 6 years ago

seems fine

jeong760 commented 6 years ago

@bonesoul, ok. thanks I will made test this evening my time.

bonesoul commented 6 years ago

sure, take your time.

jeong760 commented 6 years ago

@bonesoul, so above code will be check the version and will running a correct command by the coin daemon version. Right?

bonesoul commented 6 years ago

should be so?

jeong760 commented 6 years ago

@bonesoul, Yes, because some coin wallet does not update and uses an old version, which needs to use a Getinfo() to get its general info such as version, protocol version etc.

jeong760 commented 6 years ago

@bonesoul, I've solved an [Error] [NetworkInfo] [Bitcoin] Can not read getinfo(): getinfo after insert above code on NetwrokInfo.cs. it compared the version of coin wallet is 150100 or not and then running a correct command. In order to solve, I added references to following code for var Info= _daemonClient.Getnetworkinfo().

The additionally modified codes

The screenshot of CoiniumServ console capture_20180307

Regards, John Ahn

bonesoul commented 6 years ago

great, send a PR please.

jeong760 commented 6 years ago

@bonesoul, The only thing I have an issue of IsMine related error on the console of CoiniumServ for Globaltoken. Because it does not support a IsMine instead it uses a getaddressinfo to get same info for IsMine result.

So I need to your guide where I check or added this command, please. Because getaddressinfo has a IsMine result value but it needs to add somewhere in the code.

22:45:59 [Error] [PaymentProcessor] [Globaltoken] Halted as daemon we are connected to does not own the pool address: GWPKpNam1nsdXQT62fYKwWvYMJk49H2G2G.

Regards, John Ahn

jeong760 commented 6 years ago

@bonesoul, I will open a new PR after I've solved a IsMine issue of Globaltoken coin.

Regards, John Ahn

bonesoul commented 6 years ago

you have to fix tx creator and payment processor;

https://github.com/bonesoul/CoiniumServ/blob/89d8c71012972981f97cb80ba4aecb95db7f1572/src/CoiniumServ/Transactions/Outputs.cs#L81

https://github.com/bonesoul/CoiniumServ/blob/7f609e642c5e2e7ae4c6820a2e8936e720105d1f/src/CoiniumServ/Payments/PaymentProcessor.cs#L198

add a check after https://github.com/bonesoul/CoiniumServ/blob/7f609e642c5e2e7ae4c6820a2e8936e720105d1f/src/CoiniumServ/Payments/PaymentProcessor.cs#L195

if it doesn't contain isMine data, do your extra getaddressinfo work.

jeong760 commented 6 years ago

@bonesoul, Yes I know the where to use a IsMine result on the code of CoiniumServ but also It needs to do more extra work now.

As you see the following query result using getaddressinfo Globaltoken wallet address. there is a IsMine result. so I needs to get that information to validateaddress and paymentprocessor of CoiniumServ.

Query is getaddressinfo GWPKpNam1nsdXQT62fYKwWvYMJk49H2G2G

Result is { "address": "GWPKpNam1nsdXQT62fYKwWvYMJk49H2G2G", "scriptPubKey": "", "ismine": true, "iswatchonly": false, "isscript": false, "iswitness": false, "pubkey": "", "iscompressed": true, "account": "Jeong760_Mining_Pool", "timestamp": 1501847645, "hdkeypath": "m/0'/1'/0'", "hdmasterkeyid": "" }

bonesoul commented 6 years ago

in;

https://github.com/bonesoul/CoiniumServ/blob/7f609e642c5e2e7ae4c6820a2e8936e720105d1f/src/CoiniumServ/Payments/PaymentProcessor.cs#L195

if (validateaddress errors) getaddressinfo()

and use the results?

jeong760 commented 6 years ago

@bonesoul, should I add an above code to after 195 line on PaymentProcessor.cs? if (validateaddress errors) getaddressinfo()

bonesoul commented 6 years ago

that's pseudo code. though should be clear enough for the direction.

https://github.com/bonesoul/CoiniumServ/blob/7f609e642c5e2e7ae4c6820a2e8936e720105d1f/src/CoiniumServ/Payments/PaymentProcessor.cs#L195

and

https://github.com/bonesoul/CoiniumServ/blob/89d8c71012972981f97cb80ba4aecb95db7f1572/src/CoiniumServ/Transactions/Outputs.cs#L71

jeong760 commented 6 years ago

@bonesoul, could you write an example? I am not a programmer so don't know what you mean exactly.

jeong760 commented 6 years ago

@bonesoul I will open a cumultaed PR of CoiniumServ. and as your advices I've change back MySql version to 6.8.8 again.

jeong760 commented 6 years ago

@bonesoul, I think except the IsMine result value for globaltoken, other coins works fine with this PR.

jeong760 commented 6 years ago

@bonesoul, PR request opened

jeong760 commented 6 years ago

@bonesoul if I added a following code on PaymentProcessor.cs for validate pool address. Does it work?

private bool ValidatePoolAddress()
{
    bool validate;      
        validate=_daemonClient.ValidateAddress(_poolConfig.Wallet.Adress)

   if (validate)

    try
    {
        var result = _daemonClient.ValidateAddress(_poolConfig.Wallet.Adress);

        // make sure the pool central wallet address is valid and belongs to the daemon we are connected to.
        if (result.IsValid && result.IsMine)
            return true;

        _logger.Error("Halted as daemon we are connected to does not own the pool address: {0:l}.", _poolConfig.Wallet.Adress);
        return false;
    }
    catch (Exception e)
    {
        _logger.Error("Halted as we can not connect to configured coin daemon: {0:l}", e.Message);
        return false;
    }
  else
   try
    {
        var result = _daemonClient.Getaddressinfo(_poolConfig.Wallet.Adress);
        // make sure the pool central wallet address is valid and belongs to the daemon we are connected to.
        if (result.IsValid && result.IsMine)
            return true;

        _logger.Error("Halted as daemon we are connected to does not own the pool address: {0:l}.", _poolConfig.Wallet.Adress);
        return false;
    }
    catch (Exception e)
    {
        _logger.Error("Halted as we can not connect to configured coin daemon: {0:l}", e.Message);
        return false;
    }

}

Regards, John Ahn

bonesoul commented 6 years ago

i disliked the idea of layering ValidateAddress() call.

jeong760 commented 6 years ago

@bonesoul, ok but without if - else layer on ValidateAddress() call. How I call or use a getaddressinfo() to validate a IsMine = True or False? if you know the more better one than tell me I will try it.

globaltoken commented 6 years ago

Hello guys,

I suggest to check validateaddress call first, if it responds with rpc error, then you are trying getaddressinfo, this ensures backward compatibility.

Regards. Globaltoken Dev.

jeong760 commented 6 years ago

@globaltoken, That's why I am made a if-else layer on ValidateAddress on PaymentPrecessor.cs. so it simply check the IsMine value is True or False and go to and running a right command.

But @bonesoul does not want to make a layer on this section then I don't know the idea.

Regards, John Ahn

jeong760 commented 6 years ago

@bonesoul, I've added a public class for getaddressinfo() and will be made a test using the following statement

PaymentProcessor.cs

    private bool ValidatePoolAddress()
    {
        try
        {
            var result = _daemonClient.ValidateAddress(_poolConfig.Wallet.Adress);

            // make sure the pool central wallet address is valid and belongs to the daemon we are connected to.
            if (result.IsValid && result.IsMine)
                return true;

            _logger.Error("Halted as daemon we are connected to does not own the pool address: {0:l}.", _poolConfig.Wallet.Adress);
            return false;
        }
        catch (Exception e)
        {
            _logger.Error("Halted as we can not connect to configured coin daemon: {0:l}", e.Message);
            return false;
        }
    }

    private bool GetAddressInfo()
    {
        try
        {
            var result = _daemonClient.GetAddressInfo(_poolConfig.Wallet.Adress);
            // make sure the pool central wallet address is valid and belongs to the daemon we are connected to.
            if (result.IsValid && result.IsMine)
                return true;

            _logger.Error("Halted as daemon we are connected to does not own the pool address: {0:l}.", _poolConfig.Wallet.Adress);
            return false;
        }
        catch (Exception e)
        {
            _logger.Error("Halted as we can not connect to configured coin daemon: {0:l}", e.Message);
            return false;
        }

Regards, John Ahn

globaltoken commented 6 years ago

@jeong760 So where is the problem here? This code looks good, and should also be downgrade compatible. ?

Greetings,

bonesoul commented 6 years ago

The thing is that CoiniumServ at the first hand was developer for Bitcoin and compatible blockchains. Any shitcoin making nonsense changes to the API is just cluttering stuff.

We really can't clutter the code for every shit coin out there with switchs & ifs.

For that IsMine() stuff, we should be developing a better strategy i guess.

bonesoul commented 6 years ago

The PR https://github.com/bonesoul/CoiniumServ/pull/978/files seems good to me except the IsMine change.

globaltoken commented 6 years ago

Check out Bitcoin Core 0.16 The Bitcoin Core Team deleted validateaddress tag, not me.

So pls check it and change it.

globaltoken commented 6 years ago

That means that the latest BTC Core Version deleted ismine tag, as you are just speicified for Bitcoin you should change this. Read the Release doc of 0.16 to get more details about the change.

bonesoul commented 6 years ago

link the doc please. if bitcoin core is making the change, I can happily merge the fix in including the isMine change.

And in that case, @jeong760, we don't need a switch for ValidateAddress. We can just start using GetAddressInfo directly. Please make the change if you have willing for so.

globaltoken commented 6 years ago

Okay I checked it. GlobalToken is a Bitcoin fork, so it should match the same rpc calls. I checked Bitcoin 0.16 and noticed that validateaddress is working. BUT! You can check 0.16 + (Version coming soon).

The RPC call is marked as deprecated, and will be removed. Check out the example: https://github.com/bitcoin/bitcoin/blob/b225010a808d475cbb53aeed484295f8dc8751c4/src/rpc/misc.cpp#L36 There is no ismine arg anymore.

So it will changed in next Version of Bitcoin Core. As we are some commits above 0.16 we still use the new format.

But as I told, the same issue will be displayed in the next Bitcoin Core Version.

bonesoul commented 6 years ago

we should move to getaddressinfo then.

globaltoken commented 6 years ago

Yes, thats all.

If you just want to allow Bitcoin, then change it directly, otherwhise for Altcoin support I suggest to use @jeong760 script to ensure Coins based on old source are also working.

bonesoul commented 6 years ago

@jeong760 solution is viable then, though better if he can document it briefly about why we need the switch there.

jeong760 commented 6 years ago

@bonesoul and @globaltoken , I will post a code tomorrow after made some more changes.

jeong760 commented 6 years ago

@bonesoul, I agree.

jeong760 commented 6 years ago

@bonesoul and @globaltoken I've compared a Bitcoin and Globaltoken v0.16.0 wallet for IsMine reqsult. however Bitcoin v16.0 has a IsMine on validatedaddress. only Globaltoken does not have..

jeong760 commented 6 years ago

@bonesoul and @globaltoken, Bitcoin V0.16.0 does not have a getaddressinfo() command yet. it uses a validateaddress() command for validating a wallet using bool result true or false of IsMine.

Only Globaltoken uses a Getaddressinfo for IsMine result is true or false to validation address.

validateadress will be deprecated from on v0.18.0. however it still now uses it by bitcoin v0.16.0

bonesoul commented 6 years ago

@globaltoken?

jeong760 commented 6 years ago

@bonesoul and @globaltoken

After I've added the following source for GetAddressInfo() all payment processor disabled to display a following error message on the console.

The both coin's payment processor disabled but mining works. so we need to run a different command by coins wallet supported commands such as ValidateAddress() and GetAddressInfo() in order to prevent or removed it.

[Error] [PaymentProcessor] [Bitcoin] Halted as we can not connect to configured coin daemon: Method not found [Error] [PaymentProcessor] [Globaltoken] Halted as daemon we are connected to does not own the pool address: GWPKpNam1nsdXQT62fYKwWvYMJk49H2G2G.

How I run a different command like a ValidateAddress() and a GetAddressInfo() by coin wallet?

src/CoiniumServ/Daemon/DaemonClient.cs 465: public GetAddressInfo GetAddressInfo(string walletAddress) 466: { 467: return MakeRequest("getaddressinfo", walletAddress); 468: }

src/CoiniumServ/Daemon/IDaemonClient.cs 61: GetAddressInfo GetAddressInfo(string walletAddress);

src/CoiniumServ/Transactions/OutPuts.cs // It is an original code. but also don't know how... 73: if (!result.IsValid) 74: throw new InvalidWalletAddressException(walletAddress);

src/CoiniumServ/Payments/PaymentProcessor.cs 74: if (!GetAddressInfo()) // try to validate the globaltoken pool wallet. 75: return; // if we can't, stop the payment processor.

214: private bool GetAddressInfo() 215: { 216: try 217: { 218: var result = _daemonClient.GetAddressInfo(_poolConfig.Wallet.Adress); 219: 220: // make sure the pool central wallet address is valid and belongs to the daemon we are connected to. 221: if (result.IsValid && result.IsMine) 222: return true; 223: 224: _logger.Error("Halted as daemon we are connected to does not own the pool address: {0:l}.", _poolConfig.Wallet.Adress); 225: return false; 226: } 227: catch (Exception e) 228: { 229: _logger.Error("Halted as we can not connect to configured coin daemon: {0:l}", e.Message); 230: return false; 231: } 232: }

The screenshot debug mode of CoiniumServ capture_20180311

The CodeLens references - IDeamonClient.cs -ValidateAddress validateaddress_references

Regards, John Ahn

dmshel commented 6 years ago

@jeong760 After i add ur code i get error Error] [RedisProvider] [Litecoin] Redis storage initialization failed: 127.0.0.1:6379 default How i can fix it?

jeong760 commented 6 years ago

@dmshel Let me check but this seems related to Redis version you installed. I proved my last code does not relate to you mentioned the issue if it has an issue how am I running a tree different coins simultaneously?

dmshel commented 6 years ago

@jeong760 default