zone117x / node-open-mining-portal

A scalable all-in-one easy to setup cryptocurrency mining pool and portal written entirely in Node.js.
GNU General Public License v2.0
1.02k stars 1.03k forks source link

blocks generate to some random address. #661

Open Thanoos opened 5 years ago

Thanoos commented 5 years ago

Hey I am using cpuminer and it is generating coin to some unknown address on startum. I am very confused. The blocks are visible in the explorer but not very sure where these coins are going. Please can you guide me. It will be great help. This is for the altcoin i have created using bitcoin fork v0,17.1. my orphaned blocks are exactly equal to my valid share.

wilsonpc commented 4 years ago

Something similar happened to me with v0.18.0 yesterday. Were you able to find anything out? Block headers version was 0100. Using P2PKH addresses seemed to work but when I used a P2SH address, blocks went to a random P2PKH address. Any information appreciated.

c0mm4nd commented 4 years ago

nomp's AddressToScript supports P2PKH only.

For P2SH, use these code to convert address

// written in golang
func P2SHAddressToScript(addr string) []byte {
    decoded, err := base58.FastBase58Decoding(addr)
    if decoded == nil || err != nil {
        log.Fatal("base58 decode failed for " + addr)
    }

    if len(decoded) != 25 {
        log.Fatal("invalid address length for " + addr)
    }

    publicKey := decoded[1 : len(decoded)-4]

    return bytes.Join([][]byte{
        {0xA9, 0x14},
        publicKey,
        {0x87},
    }, nil)
}