Skip to content

Commit 3c5bd7f

Browse files
authored
Merge pull request #59 from jakubmkowalski/fix/bump_order_map_to_table
fix: bump order in BEEF creation
2 parents 5d90f25 + f275391 commit 3c5bd7f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

transaction/beef.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (t *Transaction) BEEF() ([]byte, error) {
100100
if err != nil {
101101
return nil, err
102102
}
103-
bumps := map[uint32]*MerklePath{}
103+
bumps := []*MerklePath{}
104104
bumpIndex := map[uint32]int{}
105105
txns := map[string]*Transaction{t.TxID().String(): t}
106106
ancestors, err := t.collectAncestors(txns)
@@ -112,11 +112,11 @@ func (t *Transaction) BEEF() ([]byte, error) {
112112
if tx.MerklePath == nil {
113113
continue
114114
}
115-
if _, ok := bumps[tx.MerklePath.BlockHeight]; !ok {
115+
if _, ok := bumpIndex[tx.MerklePath.BlockHeight]; !ok {
116116
bumpIndex[tx.MerklePath.BlockHeight] = len(bumps)
117-
bumps[tx.MerklePath.BlockHeight] = tx.MerklePath
117+
bumps = append(bumps, tx.MerklePath)
118118
} else {
119-
err := bumps[tx.MerklePath.BlockHeight].Combine(tx.MerklePath)
119+
err := bumps[bumpIndex[tx.MerklePath.BlockHeight]].Combine(tx.MerklePath)
120120
if err != nil {
121121
return nil, err
122122
}

0 commit comments

Comments
 (0)