Created
January 9, 2024 14:00
-
-
Save cloakd/f2abed5c0ea82bb980926e06b4463979 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"flag" | |
"github.com/alphabatem/fluxbot/helius" | |
"github.com/gagliardetto/solana-go" | |
"github.com/gagliardetto/solana-go/rpc" | |
"github.com/joho/godotenv" | |
"github.com/rs/zerolog/log" | |
"os" | |
) | |
func init() { | |
err := godotenv.Load(".env") | |
if err != nil { | |
log.Fatal().Err(err).Msg("Error loading .env file") | |
} | |
} | |
func main() { | |
id := flag.String("hook", "", "Webhook to inspect") | |
flag.Parse() | |
h := &helius.HeliusService{} | |
err := h.Configure(nil) | |
if err != nil { | |
log.Fatal().Err(err) | |
} | |
err = h.Start() | |
if err != nil { | |
log.Fatal().Err(err) | |
} | |
log.Info().Str("id", *id).Msg("Viewing Webhook") | |
wh, err := h.ShowWebhook(*id) | |
if err != nil { | |
log.Fatal().Err(err) | |
} | |
c := rpc.New(os.Getenv("RPC_URL")) | |
tx, err := c.GetTransaction(context.TODO(), | |
solana.MustSignatureFromBase58("5Un6isEqs6Xdd8u2Y6SSTmFwsRaBtvPapgKRoWvsm65K7vySemuDknT6NMFemZFjJrXduVrRNZqaNzUiqY6YopZk"), &rpc.GetTransactionOpts{ | |
Commitment: rpc.CommitmentConfirmed, | |
Encoding: solana.EncodingBase64, | |
}) | |
if err != nil { | |
log.Fatal().Err(err) | |
} | |
txn, err := tx.Transaction.GetTransaction() | |
if err != nil { | |
log.Fatal().Err(err) | |
} | |
filter := map[string]struct{}{} | |
log.Info().Msgf("Adding: %v accounts", len(txn.Message.AccountKeys)) | |
for _, a := range txn.Message.AccountKeys { | |
filter[a.String()] = struct{}{} | |
} | |
for _, a := range wh.AccountAddresses { | |
if _, ok := filter[a]; ok { | |
log.Print(a) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment