Bitcoin Forum
November 11, 2024, 04:05:06 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [LTC] Checking if block hash is valid for given difficulty  (Read 3064 times)
aaaxn (OP)
Sr. Member
****
Offline Offline

Activity: 359
Merit: 250



View Profile
April 18, 2013, 07:12:54 AM
 #1

Hi,

How litecoin checks if block hash matches difficulty?
I understand how it works for bitcoin. Bitcoin hashes have leading zeroes for example 000000002c05cc2e78923c34df87fd108b22221ac6076c18f3ade378a4d915e9 is valid hash for difficulty 1. When difficulty icreases more leading zeroes are needed.

Litecoin hashes don't have leading zeroes and hash a4ef2ee56356014853936c6c5f50baeeaa74c0db90e973e2ae5bc9d0d840cdf1 was accepted for difficulty 1.065.
Later on with difficulty 364.365 even greater hash d55ad6397da22574b63ae03d54dee8b58e0777cdc531252808371fc25bd296b3 was accepted.

So how do I check if block hash is valid for litecoin?


                                                                              █
                              █████████                  ██████ 
                      ███████████████████████████   
              ███████████████████████████████   
            ████████████████████████████████   
        █████████████████████████████████     
    ████████████████████████████████████   
    ████████          █████████          █████████   
  ████████                ██████              ████████   
█████████                █████                ████████   
███████████                █                ███████████ 
██████████████                      ██████████████ 
█████████████████            ████████████████ 
███████████████                  ███████████████ 
█████████████                          █████████████ 
███████████              ███                ██████████ 
█████████                █████                ████████   
  ████████              ███████              ███████     
    █████████        █████████          ████████     
      █████████████████████████████████       
        ██████████████████████████████           
            ███████████████████████████             
              ████████████████████████                 
                  ████████████████████                     
CorionX


















Powered by,
Remember remember the 5th of November
Legendary
*
Offline Offline

Activity: 1862
Merit: 1011

Reverse engineer from time to time


View Profile
April 18, 2013, 08:37:37 AM
 #2

+1, I'd like to know how and why too.

BTC:1AiCRMxgf1ptVQwx6hDuKMu4f7F27QmJC2
Remember remember the 5th of November
Legendary
*
Offline Offline

Activity: 1862
Merit: 1011

Reverse engineer from time to time


View Profile
April 18, 2013, 11:07:09 AM
 #3

I checked sources:
https://github.com/litecoin-project/litecoin/blob/master/src/main.cpp

I found function to check it. It is exacly same as in bitcoin so hashes should be similiar unless ... binary clients are from different source and LTC users are in BIG trouble or I am just missing something here.
Code:
bool CheckProofOfWork(uint256 hash, unsigned int nBits)
{
    CBigNum bnTarget;
    bnTarget.SetCompact(nBits);

    // Check range
    if (bnTarget <= 0 || bnTarget > bnProofOfWorkLimit)
        return error("CheckProofOfWork() : nBits below minimum work");

    // Check proof of work matches claimed amount
    if (hash > bnTarget.getuint256())
        return error("CheckProofOfWork() : hash doesn't match nBits");

    return true;
}
That sentence doesn't even make sense.

BTC:1AiCRMxgf1ptVQwx6hDuKMu4f7F27QmJC2
Balthazar
Legendary
*
Offline Offline

Activity: 3108
Merit: 1359



View Profile
April 18, 2013, 11:27:39 AM
 #4

It's because TBX, FBX, BBQ, LTC and other similar clones actually don't use scrypt as blockhash function. Scrypt hash isn't used in blockchain directly, getpowhash() function generates this.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!