Skip to content

Commit

Permalink
test2
Browse files Browse the repository at this point in the history
  • Loading branch information
humblenginr committed Apr 11, 2024
1 parent 8c507bf commit 840705f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/mining/coinbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,19 @@ func AddWitnessCommitmentX(coinbaseTx *txn.Transaction,

var witnessNonce [32]byte
coinbaseTx.Vin[0].Witness = []string{hex.EncodeToString(witnessNonce[:])}
fmt.Printf("\n\nSerialized coinbase tx: %x\n\n", blockTxns[0].RawHex())

// Next, obtain the merkle root of a tree which consists of the
// wtxid of all transactions in the block. The coinbase
// transaction will have a special wtxid of all zeroes.
var zeroHash [32]byte
wtxids := make([][32]byte, 0)
for _, t := range blockTxns {
wtxids = append(wtxids, [32]byte(utils.ReverseBytes(t.WitnessHash())))
for i, t := range blockTxns {
// coinbase
if(i == 0){
wtxids = append(wtxids, zeroHash)
} else {
wtxids = append(wtxids, [32]byte(utils.ReverseBytes(t.WitnessHash())))
}
}

witnessMerkleRoot := GenerateMerkleTreeRoot(wtxids)
Expand Down

0 comments on commit 840705f

Please sign in to comment.