Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating handlers to handle new wallet format #22

Open
wants to merge 4 commits into
base: cleanup
Choose a base branch
from

Conversation

Maphikza
Copy link
Contributor

No description provided.

Copy link
Collaborator

@illuzen illuzen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code seems generally fine, could use some more comments.

I don't understand how this fits into the larger system, maybe some info in the PR description could help.

@@ -21,7 +21,7 @@ func handleLatestTransactions(c *fiber.Ctx) error {

// Get the latest 10 transactions
var transactions []types.WalletTransactions
result := db.Order("date desc").Limit(10).Find(&transactions)
result := db.Order("date desc").Limit(-1).Find(&transactions)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does Limit(-1) do here? Also should update the comment @Maphikza

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I have recently moved back to relay code and this is no longer necessary as we are no longer setting limits.

This is how it looks now.

var transactions []types.WalletTransactions
result := db.Order("date desc").Find(&transactions)

"github.com/spf13/viper"
)

const envFile = ".env"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to use the config.json for this since we already store a private key there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind 411 is also being worked on right now and already looks different. You can reject this part for now as I am working on it with Cypher.

const envFile = ".env"
const nostrPrivateKeyVar = "NOSTR_PRIVATE_KEY"

type RelayInfo struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should reuse the NIP11RelayInfo struct in websocket/types.go

And maybe that's not the right place for the struct if it gets used all over the app. We are using it in the dht code as well.

Let's put that refactor in a different PR, tho. No need to complicate this right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noted.

DHTkey string `json:"dhtkey,omitempty"`
}

func createKind411Event(privateKey *secp256k1.PrivateKey, publicKey *secp256k1.PublicKey, store stores.Store) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably have a place where we describe all non-standard kinds we support but can we have a comment in this file somewhere describing what this kind411 is and why we are overwriting old versions of them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

return privateKey, publicKey, nil
}

func generateEd25519Keypair(privateKeyHex string) (ed25519.PrivateKey, ed25519.PublicKey, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may have been obsoleted by the client making the key now. Just guessing, tho.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will look into it as well. If it is not necessary I will remove it.

@@ -104,6 +112,37 @@ func main() {
queryCache := viper.GetStringMapString("query_cache")
store.InitStore(queryCache)

// generate server priv key if it does not exist
err := generateAndSaveNostrPrivateKey()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a function generateKey() in host.go, probably should reuse that if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grandmaster stuff. Colby knew the code is due for refactoring but we hadn't had time for it yet. These are all good points. I will probably push small changes from tomorrow afternoon to make the next review quicker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants