func (bm *BitMessage) calculateChecksumAndLength() { tmp := mymath.Uint322HexRev(uint32(len(bm.Payload))) for i := 0; i < 4; i++ { bm.Length[i] = tmp[i] } tmp = mymath.DoubleSHA(bm.Payload) for i := 0; i < 4; i++ { bm.Checksum[i] = tmp[i] } }
func (b *Block) Hash() []byte { answer := make([]byte, len(b.Version)+len(b.PrevBlock)+len(b.MerkleRoot)+len(b.Timestamp)+len(b.Bits)+len(b.Nonce)) iterator := 0 copy(answer[iterator:], b.Version[:]) iterator += len(b.Version) copy(answer[iterator:], b.PrevBlock[:]) iterator += len(b.PrevBlock) copy(answer[iterator:], b.MerkleRoot[:]) iterator += len(b.MerkleRoot) copy(answer[iterator:], b.Timestamp[:]) iterator += len(b.Timestamp) copy(answer[iterator:], b.Bits[:]) iterator += len(b.Bits) copy(answer[iterator:], b.Nonce[:]) return mymath.Rev(mymath.DoubleSHA(answer)) }
//TODO: test //TODO: double check if rev or not func (t *Tx) Hash() []byte { return mymath.DoubleSHA(t.Compile()) }