Skip to content

Commit

Permalink
fix: fixed merkle
Browse files Browse the repository at this point in the history
  • Loading branch information
pred695 committed Apr 14, 2024
1 parent 859a783 commit 4a0689c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Prioritize.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func Prioritize() (uint64, []string, []string) {
}
serialized, _ := serializeTransaction(&tx)
segserialized, _ := SegWitSerialize(&tx)
txID := to_sha(to_sha(serialized))
wtxID := to_sha(to_sha(segserialized))
txID := reverseBytes(to_sha(to_sha(serialized)))
wtxID := reverseBytes(to_sha(to_sha(segserialized)))
txInfo = append(txInfo, TxInfo{TxID: hex.EncodeToString(txID), WTxID: hex.EncodeToString(wtxID), Fee: fee, Weight: uint64(calculateWitnessSize(&tx) + CalculateBaseSize(&tx)*4)})

}
Expand Down
6 changes: 2 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func main() {

cbTx := Coinbase(netReward)
serializedcbTx, _ := serializeTransaction(cbTx)
TxIDs = append([]string{hex.EncodeToString(to_sha(to_sha(serializedcbTx)))}, TxIDs...)
TxIDs = append([]string{hex.EncodeToString(reverseBytes(to_sha(to_sha(serializedcbTx))))}, TxIDs...)
mkr := NewMerkleTree(TxIDs)
Bh.merkleRoot = hex.EncodeToString(mkr.Data)
// witnessMerkle := NewMerkleTree(wTxIDs)
Expand All @@ -45,9 +45,7 @@ func main() {
file.WriteString(hex.EncodeToString(serializedBh) + "\n")
file.WriteString(hex.EncodeToString(serializedcbTx) + "\n")
for _, tx := range TxIDs {
txBytes, _ := hex.DecodeString(tx)
txBytes = reverseBytes(txBytes)
file.WriteString(hex.EncodeToString(txBytes) + "\n")
file.WriteString(tx + "\n")
}
}

Expand Down
6 changes: 3 additions & 3 deletions output.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
0700000000000000000000000000000000000000000000000000000000000000000000009a8f7b50adf2dcbdbc1a0a5869c954e879fa0daec60e09b20fe7d241760aeb37bd311c66ffff001fd33c0000
01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1b03951a0604f15ccf5609013803062b9b5a0100072f425443432f20ffffffff02895d8c0100000000160014df4bf9f3621073202be59ae590f55f42879a21a00000000000000000266a24aa21a9ed3a44995d77b02e34b810da0cb9e5af0ca02aafeed77241c892d7ba23e4779c8b00000000
7d9b384572f688779f6ab6af5bfef2b16bf57c5f89a499759f9a9c6b852734b7
0700000000000000000000000000000000000000000000000000000000000000000000001469c49fc3a805b159391bfc2921584aa21f67e9f545d1110bff17d3313b83f5f3321c66ffff001f602f0500
01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1b03951a0604f15ccf5609013803062b9b5a0100072f425443432f20ffffffff02895d8c0100000000160014df4bf9f3621073202be59ae590f55f42879a21a00000000000000000266a24aa21a9ed392466efe913d353921707d69a39cfb22952a7d75de836728f73705b3c5db5e400000000
76bdb34d637ae63ec4ee9dc11c8e242c1ce89cef399dedbfc902e325c44e9e86
82f9f96db7bdbb9e70626747632e373b34eefd50d613dfea7092744169591b6e
7cb2a4f55245bae141a5d6ad51c08d7a9fdf2c2b905e4d97639ed80b82e69800
a9e537569db3c64340ed5abcdd983e9bb1b6ad6f90c93bc80d31c5cc0490bcea
Expand Down

0 comments on commit 4a0689c

Please sign in to comment.