Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
feat(BUX-181): replace woc structs with new ones
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadiuszos4chain committed Sep 19, 2023
1 parent 9437393 commit 483328d
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 27 deletions.
4 changes: 2 additions & 2 deletions chainstate/filters/metanet.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package filters
import (
"strings"

"github.com/BuxOrg/bux/chainstate"
"github.com/libsv/go-bt"
"github.com/mrz1836/go-whatsonchain"
)

// MetanetScriptTemplate script template for metanet transaction
const MetanetScriptTemplate = "14c91e5cc393bb9d6da3040a7c72b4b569b237e450"

// Metanet filter processor
func Metanet(tx *whatsonchain.TxInfo) (*bt.Tx, error) {
func Metanet(tx *chainstate.TxInfo) (*bt.Tx, error) {
// Loop through all the outputs and check for pubkeyhash output
for _, out := range tx.Vout {
// if any output contains a pubkeyhash output, include this tx in the filter
Expand Down
6 changes: 3 additions & 3 deletions chainstate/filters/metanet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package filters
import (
"testing"

"github.com/mrz1836/go-whatsonchain"
"github.com/BuxOrg/bux/chainstate"
)

func TestMetanet(t *testing.T) {
type args struct {
tx *whatsonchain.TxInfo
tx *chainstate.TxInfo
}
tests := []struct {
name string
Expand All @@ -19,7 +19,7 @@ func TestMetanet(t *testing.T) {
{
name: "non-metanet transaction shouldn't pass filter",
args: args{
tx: &whatsonchain.TxInfo{
tx: &chainstate.TxInfo{
Hex: "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1c03d7c6082f7376706f6f6c2e636f6d2f3edff034600055b8467f0040ffffffff01247e814a000000001976a914492558fb8ca71a3591316d095afc0f20ef7d42f788ac00000000",
},
},
Expand Down
4 changes: 2 additions & 2 deletions chainstate/filters/planaria-b.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package filters
import (
"strings"

"github.com/BuxOrg/bux/chainstate"
"github.com/libsv/go-bt"
"github.com/mrz1836/go-whatsonchain"
)

// PlanariaBTemplate string template for a B transaction
Expand All @@ -14,7 +14,7 @@ const PlanariaBTemplate = "006a2231394878696756345179427633744870515663554551797
const PlanariaBTemplateAlternate = "6a2231394878696756345179427633744870515663554551797131707a5a56646f417574"

// PlanariaB processor
func PlanariaB(tx *whatsonchain.TxInfo) (*bt.Tx, error) {
func PlanariaB(tx *chainstate.TxInfo) (*bt.Tx, error) {
// Loop through all the outputs and check for pubkeyhash output
for _, out := range tx.Vout {
// if any output contains a pubkeyhash output, include this tx in the filter
Expand Down
12 changes: 6 additions & 6 deletions chainstate/filters/planaria-b_test.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions chainstate/filters/planaria-d.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package filters
import (
"strings"

"github.com/BuxOrg/bux/chainstate"
"github.com/libsv/go-bt"
"github.com/mrz1836/go-whatsonchain"
)

// PlanariaDTemplate string template for a D transaction
Expand All @@ -14,7 +14,7 @@ const PlanariaDTemplate = "006a223139694733575459537362796f7333754a373333794b347
const PlanariaDTemplateAlternate = "6a223139694733575459537362796f7333754a373333794b347a45696f69314665734e55"

// PlanariaD processor
func PlanariaD(tx *whatsonchain.TxInfo) (*bt.Tx, error) {
func PlanariaD(tx *chainstate.TxInfo) (*bt.Tx, error) {
// Loop through all of the outputs and check for pubkeyhash output
for _, out := range tx.Vout {
// if any output contains a pubkeyhash output, include this tx in the filter
Expand Down
4 changes: 2 additions & 2 deletions chainstate/filters/pubkeyhash.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package filters

import (
"github.com/BuxOrg/bux/chainstate"
"github.com/libsv/go-bt"
"github.com/mrz1836/go-whatsonchain"
)

// PubKeyHash processor
func PubKeyHash(tx *whatsonchain.TxInfo) (*bt.Tx, error) {
func PubKeyHash(tx *chainstate.TxInfo) (*bt.Tx, error) {
// log.Printf("Attempting to filter for pubkeyhash: %#v", tx)
// Loop through all the outputs and check for pubkeyhash output
for _, out := range tx.Vout {
Expand Down
4 changes: 2 additions & 2 deletions chainstate/filters/rarecandy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package filters
import (
"strings"

"github.com/BuxOrg/bux/chainstate"
"github.com/libsv/go-bt"
"github.com/mrz1836/go-whatsonchain"
)

// RareCandyFrogCartelScriptTemplate string template for a Rare Candy Frog Cartel NTF
const RareCandyFrogCartelScriptTemplate = "a914179b4c7a45646a509473df5a444b6e18b723bd148876"

// RareCandyFrogCartel processor
func RareCandyFrogCartel(tx *whatsonchain.TxInfo) (*bt.Tx, error) {
func RareCandyFrogCartel(tx *chainstate.TxInfo) (*bt.Tx, error) {
// Loop through all the outputs and check for pubkeyhash output
for _, out := range tx.Vout {
// if any output contains a pubkeyhash output, include this tx in the filter
Expand Down
9 changes: 1 addition & 8 deletions chainstate/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"regexp"
"strings"

"github.com/mrz1836/go-whatsonchain"
boom "github.com/tylertreat/BoomFilters"
)

Expand All @@ -28,12 +27,6 @@ type BloomProcessorFilter struct {
regex *regexp.Regexp
}

// TxInfo wrapped WhatsOnChain transaction info object
type TxInfo struct {
whatsonchain.TxInfo
Error string `json:"error"`
}

// NewBloomProcessor initialize a new bloom processor
func NewBloomProcessor(maxCells uint, falsePositiveRate float64) *BloomProcessor {
return &BloomProcessor{
Expand Down Expand Up @@ -241,7 +234,7 @@ func (p *RegexProcessor) Reload(_ string, items []string) (err error) {

// FilterTransactionPublishEvent check whether a filter matches a tx event
func (p *RegexProcessor) FilterTransactionPublishEvent(eData []byte) (string, error) {
transaction := whatsonchain.TxInfo{}
transaction := TxInfo{}
if err := json.Unmarshal(eData, &transaction); err != nil {
return "", err
}
Expand Down

0 comments on commit 483328d

Please sign in to comment.