Closed jeong760 closed 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
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.
@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
The screenshot of CoiniumServ Web
@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.
@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
@bonesoul, Could you help me my last question about supporting a getaddressinfo for Globaltoken?
@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.
}
}
seems fine
@bonesoul, ok. thanks I will made test this evening my time.
sure, take your time.
@bonesoul, so above code will be check the version and will running a correct command by the coin daemon version. Right?
should be so?
@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.
@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
DaemonClient.cs
public Info Getnetworkinfo()
{
return MakeRequest
IDaemonClient.cs Info Getnetworkinfo();
PoolTest.cs _daemonClient.Getnetworkinfo().Returns(new Info());
The screenshot of CoiniumServ console
Regards, John Ahn
great, send a PR please.
@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
@bonesoul, I will open a new PR after I've solved a IsMine issue of Globaltoken coin.
Regards, John Ahn
you have to fix tx creator and payment processor;
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.
@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": "" }
in;
if (validateaddress errors) getaddressinfo()
and use the results?
@bonesoul, should I add an above code to after 195 line on PaymentProcessor.cs? if (validateaddress errors) getaddressinfo()
that's pseudo code. though should be clear enough for the direction.
and
@bonesoul, could you write an example? I am not a programmer so don't know what you mean exactly.
@bonesoul I will open a cumultaed PR of CoiniumServ. and as your advices I've change back MySql version to 6.8.8 again.
@bonesoul, I think except the IsMine result value for globaltoken, other coins works fine with this PR.
@bonesoul, PR request opened
@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
i disliked the idea of layering ValidateAddress() call.
@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.
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.
@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
@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
@jeong760 So where is the problem here? This code looks good, and should also be downgrade compatible. ?
Greetings,
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.
The PR https://github.com/bonesoul/CoiniumServ/pull/978/files seems good to me except the IsMine change.
Check out Bitcoin Core 0.16 The Bitcoin Core Team deleted validateaddress tag, not me.
So pls check it and change it.
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.
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.
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.
we should move to getaddressinfo then.
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.
@jeong760 solution is viable then, though better if he can document it briefly about why we need the switch there.
@bonesoul and @globaltoken , I will post a code tomorrow after made some more changes.
@bonesoul, I agree.
@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..
@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
@globaltoken?
@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
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
The CodeLens references - IDeamonClient.cs -ValidateAddress
Regards, John Ahn
@jeong760 After i add ur code i get error Error] [RedisProvider] [Litecoin] Redis storage initialization failed: 127.0.0.1:6379 How i can fix it?
@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?
@jeong760
@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.