Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
xenartist committed Nov 11, 2024
2 parents e88efa4 + b6236d9 commit 1414e29
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 142 deletions.
4 changes: 4 additions & 0 deletions lol/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var GPUAlgorithms = []string{
"BeamHash (GPU>6GB)",
"Ethash (GPU>6GB)",
"Blake3 (GPU>4GB)",
"Etchash (GPU>4GB)",
"KarlsenHash (GPU>3GB)",
}

Expand Down Expand Up @@ -53,6 +54,9 @@ func StartMining(app *tview.Application, logView *tview.TextView, logMessage uti
case "Blake3 (GPU>4GB)":
algorithm = "ALEPH"
host = "blake3.unmineable.com"
case "Etchash (GPU>4GB)":
algorithm = "ETCHASH"
host = "etchash.unmineable.com"
case "FishHash (GPU>6GB)":
algorithm = "FISHHASH"
host = "fishhash.unmineable.com"
Expand Down
2 changes: 1 addition & 1 deletion ui/menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

func CreateMainMenu() *tview.List {
mainMenu := tview.NewList().
AddItem("unmineable-solXEN (2.3.0)", "", 0, nil).
AddItem("unmineable-solXEN (4.0.0)", "", 0, nil).
AddItem(WALLET_STRING, "", 'a', nil).
AddItem(SOLXEN_CPU_MINER_STRING, "", 'b', func() {
UpdateCPUMinerPublicKeyTextView() // Update the Public Key text view
Expand Down
278 changes: 139 additions & 139 deletions ui/tokenharvest.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ui

import (
"encoding/json"
"fmt"
"regexp"
"strconv"
Expand All @@ -20,7 +19,8 @@ type BurnMemo struct {
}

var tokenOptions = []string{"solXEN", "xencat", "PV", "ORE"}
var autoHarvestCounter = 0

// var autoHarvestCounter = 0

func CreateTokenHarvestUI(app *tview.Application) ModuleUI {
var moduleUI = CreateModuleUI(TOKEN_HARVEST_STRING, app)
Expand Down Expand Up @@ -114,17 +114,17 @@ func createAutoHarvestForm(app *tview.Application, moduleUI *ModuleUI, walletInf
})

// 5. Dropdown for burn interval
burnOptions := []string{"Off", "Burn/69", "Burn/100", "Burn/420"}
burnIndex := 0
for i, option := range burnOptions {
if option == config.HarvestBurn {
burnIndex = i
break
}
}
autoHarvestForm.AddDropDown("Burn Interval", burnOptions, burnIndex, func(option string, index int) {
config.HarvestBurn = option
})
// burnOptions := []string{"Off", "Burn/69", "Burn/100", "Burn/420"}
// burnIndex := 0
// for i, option := range burnOptions {
// if option == config.HarvestBurn {
// burnIndex = i
// break
// }
// }
// autoHarvestForm.AddDropDown("Burn Interval", burnOptions, burnIndex, func(option string, index int) {
// config.HarvestBurn = option
// })

// Add a channel to trigger config reload
reloadConfigChan := make(chan struct{})
Expand Down Expand Up @@ -290,55 +290,55 @@ func createAutoHarvestForm(app *tview.Application, moduleUI *ModuleUI, walletInf
utils.LogMessage(moduleUI.LogView, fmt.Sprintf("SOL: %v -> %s: %s successfully", config.SOLPerHarvest, config.TokenToHarvest, result))

// Increment counter and check for burn condition
autoHarvestCounter++
// autoHarvestCounter++

// Set auto burn interval
var autoBurnInterval int = 0

switch config.HarvestBurn {
case "Off":
autoBurnInterval = -1
case "Burn/69":
autoBurnInterval = 69
case "Burn/100":
autoBurnInterval = 100
case "Burn/420":
autoBurnInterval = 420
}

if autoBurnInterval != -1 && autoHarvestCounter >= autoBurnInterval {
// Reset counter
autoHarvestCounter = 0

// Parse the received token amount
tokenAmount := strings.Split(result, " ")[0]

// Burn the tokens after a delay to ensure the swap completed
go func(amount, token string) {
time.Sleep(5 * time.Minute)

burnMemo := BurnMemo{
Title: "solXEN Burn with Memo",
Image: "https://xxx.png",
Content: "solXEN To Da Moon",
Author: "solXEN",
}

jsonData, err := json.Marshal(burnMemo)
memoText := string(jsonData)
if err != nil {
utils.LogMessage(moduleUI.LogView, "Error marshalling burn memo: "+err.Error())
return
}

burnResult, err := utils.BurnToken(amount, token, memoText)
if err != nil {
utils.LogMessage(moduleUI.LogView, fmt.Sprintf("Error burning tokens: %v", err))
} else {
utils.LogMessage(moduleUI.LogView, burnResult)
}
}(tokenAmount, config.TokenToHarvest)
}
// var autoBurnInterval int = 0

// switch config.HarvestBurn {
// case "Off":
// autoBurnInterval = -1
// case "Burn/69":
// autoBurnInterval = 69
// case "Burn/100":
// autoBurnInterval = 100
// case "Burn/420":
// autoBurnInterval = 420
// }

// if autoBurnInterval != -1 && autoHarvestCounter >= autoBurnInterval {
// // Reset counter
// autoHarvestCounter = 0

// // Parse the received token amount
// tokenAmount := strings.Split(result, " ")[0]

// // Burn the tokens after a delay to ensure the swap completed
// go func(amount, token string) {
// time.Sleep(5 * time.Minute)

// burnMemo := BurnMemo{
// Title: "solXEN Burn with Memo",
// Image: "https://xxx.png",
// Content: "solXEN To Da Moon",
// Author: "solXEN",
// }

// jsonData, err := json.Marshal(burnMemo)
// memoText := string(jsonData)
// if err != nil {
// utils.LogMessage(moduleUI.LogView, "Error marshalling burn memo: "+err.Error())
// return
// }

// burnResult, err := utils.BurnToken(amount, token, memoText)
// if err != nil {
// utils.LogMessage(moduleUI.LogView, fmt.Sprintf("Error burning tokens: %v", err))
// } else {
// utils.LogMessage(moduleUI.LogView, burnResult)
// }
// }(tokenAmount, config.TokenToHarvest)
// }

// Update wallet info after 60 seconds
go func() {
Expand Down Expand Up @@ -437,7 +437,7 @@ func createManualHarvestForm(app *tview.Application, moduleUI *ModuleUI, walletI
updateTokenAmount()

// 3. Swap button
manualHarvestForm.AddButton("Harvest (No Burn)", func() {
manualHarvestForm.AddButton("Harvest", func() {

// Get SOL balance
solBalance, err := utils.GetSOLBalance(utils.GetGlobalPublicKey())
Expand Down Expand Up @@ -472,90 +472,90 @@ func createManualHarvestForm(app *tview.Application, moduleUI *ModuleUI, walletI
})

// Add Burn Memo input field
titleInput := tview.NewInputField().
SetLabel("Title: ").
SetText("solXEN Burn with Memo")
// titleInput := tview.NewInputField().
// SetLabel("Title: ").
// SetText("solXEN Burn with Memo")

imageInput := tview.NewInputField().
SetLabel("Image: ").
SetText("https://xxx.png")
// imageInput := tview.NewInputField().
// SetLabel("Image: ").
// SetText("https://xxx.png")

contentInput := tview.NewInputField().
SetLabel("Content: ").
SetText("solXEN To Da Moon")
// contentInput := tview.NewInputField().
// SetLabel("Content: ").
// SetText("solXEN To Da Moon")

authorInput := tview.NewInputField().
SetLabel("Author: ").
SetText("solXEN")
// authorInput := tview.NewInputField().
// SetLabel("Author: ").
// SetText("solXEN")

manualHarvestForm.AddFormItem(titleInput)
manualHarvestForm.AddFormItem(imageInput)
manualHarvestForm.AddFormItem(contentInput)
manualHarvestForm.AddFormItem(authorInput)
// manualHarvestForm.AddFormItem(titleInput)
// manualHarvestForm.AddFormItem(imageInput)
// manualHarvestForm.AddFormItem(contentInput)
// manualHarvestForm.AddFormItem(authorInput)

// Add Manual Harvest & Burn button (new)
manualHarvestForm.AddButton("Harvest (and Burn)", func() {
// Get SOL balance
solBalance, err := utils.GetSOLBalance(utils.GetGlobalPublicKey())
if err != nil {
utils.LogMessage(moduleUI.LogView, "Error getting SOL balance: "+err.Error())
return
}

// Check if the SOL balance is greater than 0.000006
if solBalance <= 0.000006 {
utils.LogMessage(moduleUI.LogView, "Insufficient SOL balance. Minimum required: 0.000006 SOL")
return
}

utils.LogMessage(moduleUI.LogView, fmt.Sprintf("SOL: %s for %s", solAmount, selectedToken))

result, err := utils.ExchangeSolForToken(solAmount, selectedToken)
if err != nil {
utils.LogMessage(moduleUI.LogView, "Error: "+err.Error())
} else {
tokenAmountText.SetText("Amount(Est.): \n" + result + " " + selectedToken)
utils.LogMessage(moduleUI.LogView, fmt.Sprintf("SOL: %s -> %s: %s successfully", solAmount, selectedToken, result))

// Extract token amount from result
tokenAmount := strings.Split(result, " ")[0]

// Burn tokens after delay
go func() {
time.Sleep(5 * time.Minute)

burnMemo := BurnMemo{
Title: titleInput.GetText(),
Image: imageInput.GetText(),
Content: contentInput.GetText(),
Author: authorInput.GetText(),
}

jsonData, err := json.Marshal(burnMemo)
if err != nil {
utils.LogMessage(moduleUI.LogView, "Error marshalling burn memo: "+err.Error())
return
}
memoText := string(jsonData)

burnResult, err := utils.BurnToken(tokenAmount, selectedToken, memoText)
if err != nil {
utils.LogMessage(moduleUI.LogView, fmt.Sprintf("Error burning tokens: %v", err))
} else {
utils.LogMessage(moduleUI.LogView, burnResult)
}

// Update wallet info
UpdateWalletInfo(app, walletInfoView)
}()

// Update wallet info after initial purchase
go func() {
time.Sleep(60 * time.Second)
UpdateWalletInfo(app, walletInfoView)
}()
}
})
// manualHarvestForm.AddButton("Harvest (and Burn)", func() {
// // Get SOL balance
// solBalance, err := utils.GetSOLBalance(utils.GetGlobalPublicKey())
// if err != nil {
// utils.LogMessage(moduleUI.LogView, "Error getting SOL balance: "+err.Error())
// return
// }

// // Check if the SOL balance is greater than 0.000006
// if solBalance <= 0.000006 {
// utils.LogMessage(moduleUI.LogView, "Insufficient SOL balance. Minimum required: 0.000006 SOL")
// return
// }

// utils.LogMessage(moduleUI.LogView, fmt.Sprintf("SOL: %s for %s", solAmount, selectedToken))

// result, err := utils.ExchangeSolForToken(solAmount, selectedToken)
// if err != nil {
// utils.LogMessage(moduleUI.LogView, "Error: "+err.Error())
// } else {
// tokenAmountText.SetText("Amount(Est.): \n" + result + " " + selectedToken)
// utils.LogMessage(moduleUI.LogView, fmt.Sprintf("SOL: %s -> %s: %s successfully", solAmount, selectedToken, result))

// // Extract token amount from result
// tokenAmount := strings.Split(result, " ")[0]

// // Burn tokens after delay
// go func() {
// time.Sleep(5 * time.Minute)

// burnMemo := BurnMemo{
// Title: titleInput.GetText(),
// Image: imageInput.GetText(),
// Content: contentInput.GetText(),
// Author: authorInput.GetText(),
// }

// jsonData, err := json.Marshal(burnMemo)
// if err != nil {
// utils.LogMessage(moduleUI.LogView, "Error marshalling burn memo: "+err.Error())
// return
// }
// memoText := string(jsonData)

// burnResult, err := utils.BurnToken(tokenAmount, selectedToken, memoText)
// if err != nil {
// utils.LogMessage(moduleUI.LogView, fmt.Sprintf("Error burning tokens: %v", err))
// } else {
// utils.LogMessage(moduleUI.LogView, burnResult)
// }

// // Update wallet info
// UpdateWalletInfo(app, walletInfoView)
// }()

// // Update wallet info after initial purchase
// go func() {
// time.Sleep(60 * time.Second)
// UpdateWalletInfo(app, walletInfoView)
// }()
// }
// })

return manualHarvestForm
}
4 changes: 2 additions & 2 deletions utils/xoos.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type SolXENConfig struct {
SOLPerHarvest float64 `json:"solPerHarvest"`
TokenToHarvest string `json:"tokenToHarvest"`
HarvestInterval string `json:"harvestInterval"`
HarvestBurn string `json:"harvestBurn"`
// HarvestBurn string `json:"harvestBurn"`
}

func GetExecutablePath() string {
Expand All @@ -39,7 +39,7 @@ func initSolXENConfig() {
SOLPerHarvest: 0.001,
TokenToHarvest: "solXEN",
HarvestInterval: "Off",
HarvestBurn: "Off",
// HarvestBurn: "Off",
}
err = WriteSolXENConfigFile(defaultConfig)
if err != nil {
Expand Down

0 comments on commit 1414e29

Please sign in to comment.