Skip to content

Commit

Permalink
try reversing the witness commitment
Browse files Browse the repository at this point in the history
  • Loading branch information
humblenginr committed Apr 10, 2024
1 parent 2904e94 commit 36c48f7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/mining/coinbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func AddWitnessCommitment(coinbase *txn.Transaction, txns []*txn.Transaction) er
copy(witnessPreimage[:32], witnessMerkleRoot[:])
copy(witnessPreimage[32:], witnessNonce[:])
witnessCommitment := utils.DoubleHashRaw(witnessPreimage[:])
witnessCommitment = [32]byte(utils.ReverseBytes(witnessCommitment[:]))
witnessScript := []byte{
// OP_RETURN
0x6a,
Expand Down
4 changes: 2 additions & 2 deletions src/mining/merkle_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ func (s *rollingMerkleTreeStore) calcMerkleRoot(adds []*transaction.Transaction,
var zeroHash [32]byte
s.add(zeroHash)
case witness:
s.add([32]byte(utils.ReverseBytes(adds[i].WitnessHash())))
s.add([32]byte(adds[i].WitnessHash()))
default:
s.add([32]byte(utils.ReverseBytes(adds[i].TxHash())))
s.add([32]byte(adds[i].TxHash()))
}
}

Expand Down

0 comments on commit 36c48f7

Please sign in to comment.