Skip to content

Commit

Permalink
chore(BUX-164): move CMP into separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
pawellewandowski98 committed Oct 5, 2023
1 parent 385f23f commit 5c38327
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
18 changes: 18 additions & 0 deletions compound_merkle_path.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package paymail

type CompoundMerklePath []map[string]uint64

type CMPSlice []CompoundMerklePath

func (cmp CompoundMerklePath) calculateMerkleRoots() ([]string, error) {
merkleRoots := make([]string, 0)

for tx, offset := range cmp[len(cmp)-1] {
merkleRoot, err := calculateMerkleRoot(tx, offset, cmp)
if err != nil {
return nil, err
}
merkleRoots = append(merkleRoots, merkleRoot)
}
return merkleRoots, nil
}
17 changes: 0 additions & 17 deletions p2p_beef_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import (
"github.com/libsv/go-bt/v2/bscript/interpreter"
)

type CompoundMerklePath []map[string]uint64

type CMPSlice []CompoundMerklePath

type MerkleRootVerifier interface {
VerifyMerkleRoots(
ctx context.Context,
Expand Down Expand Up @@ -172,19 +168,6 @@ func (dBeef *DecodedBEEF) validateLockTime() error {
return nil
}

func (cmp CompoundMerklePath) calculateMerkleRoots() ([]string, error) {
merkleRoots := make([]string, 0)

for tx, offset := range cmp[len(cmp)-1] {
merkleRoot, err := calculateMerkleRoot(tx, offset, cmp)
if err != nil {
return nil, err
}
merkleRoots = append(merkleRoots, merkleRoot)
}
return merkleRoots, nil
}

// Verify locking and unlocking scripts pair
func verifyScripts(tx, prevTx *bt.Tx, inputIdx int) bool {
input := tx.InputIdx(inputIdx)
Expand Down

0 comments on commit 5c38327

Please sign in to comment.