Bitcoin Forum
January 23, 2017, 12:44:42 AM *
News: Latest stable version of Bitcoin Core: 0.13.2  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Pool mining software  (Read 1667 times)
woozoro
Newbie
*
Offline Offline

Activity: 7


View Profile
September 29, 2016, 08:06:16 AM
 #1



i write part of miner for check correct work

private String generateCoinbase(String en2){
    StringBuilder coinbase = new StringBuilder();
    coinbase.append(coinb1);
    coinbase.append(Extranonce1);
    coinbase.append(en2);
    coinbase.append(coinb2);
    return coinbase.toString();
}

public String Merkle2(String cb) {
    String mr = cb;
    for(int i = 0; i < merkle_branch.length; ++i)
        mr = sha256(sha256(mr + merkle_branch));
    return mr;
}

public String reverse(String string) {
    int n = string.length() / 2;
    StringBuilder sb = new StringBuilder();
    for(int i = (n - 1) * 2; n >= 0; n-=2)
        sb.append(string.substring(i, i + 1));
    return sb.toString();
}

public String reverse8(String string) {
    StringBuilder sb = new StringBuilder();
    for(int i = 0; i < string.length(); i+=8){
        int end = Math.min(i + 7, string.length() - 1);
        sb.append(reverse(string.substring(i, end)));
    }
    return sb.toString();
}

public String testControll(String nonce2, String en2) {
    String coinbase = sha256(sha256(generateCoinbase(en2)));
    String merkle = Merkle2(coinbase);
    String header = version + prevhash + reverse8(merkle) + ntime +
            nbits + nonce2 + "0000008000000000000000000000000000000000000000000000000000000000000000000000000 00000000080020000";
    String hash = sha256(sha256(header));
    return hash;
}

algorithm i get from here https://slushpool.com/help/#!/manual/stratum-protocol

i run this with next parameters (that i get from existing miner)

    {"id": 0, "method": "mining.subscribe", "params": ["cgminer/3.7.2"]}

    {"id":0,"result":[[["mining.set_difficulty","b4b6693b72a50c7116db18d6497cac52"],["mining.notify","ae6812eb4cd7735a302a8a9dd95cf71f"]],"f53d0211",4],"error":null} {"id": 1, "method": "mining.authorize", "params": ["up101084139.cgminertest", "pass"]}

    {"id":1,"result":true,"error":null}

    {"id":null,"params":[4],"method":"mining.set_difficulty"}

    {"id":null,"params":["-4fb1d548","db48fff805d2f2be98c101b2103afcd3fc0d2f2803bf92a30000000000000000","01000000010000000000000000000000000000000000000000000000000000000000000000fffff fff410353950604f8b0e75708","2e522cfabe6d6d3555ed13d9e4c9317fc507a9080eeef9cb14b591b0cc1636caff691168d3f2470 4000000000000000000000001e5129d4a000000001976a91480ad90d403581fa3bf46086a91b2d9 d4125db6c188ac00000000",["7c60191525d8563e379a4049e44d77be2fecdb348eaf844c86d434a0cad8d75c","ae757ce8f99307303fd31b81b1672674523e84cebab7d4f5fc76c97c46fe6f87","6ab95b94b7970237331551e2f22097432863ee31916d9c80fa2251739d6eb20d","332eec53c5f131c6abe85d64f928151d072cae47f8477d417185b84ec2904a56","3c2f9fdbcca3f01cc8ca2f8eee445271617f10889c39d5644399865fe6dc8a1d","b06350717cd3e844ed5d605a4d7a5f25bf859beeb2bf1aab4e2bf7fa45ee5954","7a1f44163fe18591b2c50b1499b8f09f519e9cd18d1fda14be0e87a029cda741"],"20000000","18048ed4","57e7b0f8",true],"method":"mining.notify"}

    {"params": ["up101084139.cgminertest", "-4fb1d548", "01000000", "57e7b0f8", "2536d114"], "id": 2, "method": "mining.submit"}

and get result of header block hash: 60be74f0d211b35bc2d23b39cb3bc79667291b439639dc20f63616a35d89b14b but it must be low than target and is not

    what i do wrong?
    where is my fail?
    how do it right?
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1485132282
Hero Member
*
Offline Offline

Posts: 1485132282

View Profile Personal Message (Offline)

Ignore
1485132282
Reply with quote  #2

1485132282
Report to moderator
1485132282
Hero Member
*
Offline Offline

Posts: 1485132282

View Profile Personal Message (Offline)

Ignore
1485132282
Reply with quote  #2

1485132282
Report to moderator
elbandi
Sr. Member
****
Offline Offline

Activity: 424


View Profile
September 29, 2016, 10:09:29 AM
 #2

My tips:

Code:
String mr =  sha256(sha256(cb);
@Merkle2

and

Code:
String header = version + prevhash + reverse8(merkle) + ntime +
            nbits + nonce2;
@testControll

(header.length sould be 80 here!)
woozoro
Newbie
*
Offline Offline

Activity: 7


View Profile
October 01, 2016, 02:56:55 PM
 #3

[url https://docs.google.com/document/d/132mNZ1TQ4kOCg490wUw44jkCFuMd5ehzqDxLGrnwnN0/edit?usp=sharing] Here is my code try to edit and run[/url]
Vinion
Newbie
*
Offline Offline

Activity: 6


View Profile
October 26, 2016, 01:44:45 PM
 #4

I am trying to do the same using Java. Does your code work now ?

Thank you
woozoro
Newbie
*
Offline Offline

Activity: 7


View Profile
October 30, 2016, 07:33:50 PM
 #5

i find solution, answer not need any more

Question is closed
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!