I want to access the local repo keystore programatically in Go. I tried:
" repo, err := fsrepo.Open("~/.ipfs")" // to get local repo
and that would allow me to access the keystore like repo.Keystore.Put(name, key). But I get the error above likely due to the fact that the daemon is running. But it doesn’t make sense to me because it is something similar to what is done in these functions. KeyGenCmd.
Is there a workaround to grabbing local keystore, or using keys in a temp keystore for publishing and signing commands?
You should be going thru the IPFS API rather than accessing the files directly right? Unless you’re forking the entire IPFS codebase you probably don’t even need to know how it accesses those files internally.
Yeah, there were just problems I was having with what seemed an easy and proper workflow. I was following this simple example on their docs for publishing IPNS records. Ultimately, to publish the entry to ipfs I actually don’t even need to do this stuff because, the IPFS API Publish method that is used, doesn’t accept an ipns entry object. So I fixed my problem just using the api commands like this, roughly:
// Go
const KeyName = "temp"
sh := shell.NewShell(localhost)
key, err := sh.KeyGen(context.Background(), KeyName) //generate temp key to local node
if err != nil {
panic(err)
}
publishToIPNS(ipfsPath, key.Name) // publish ipfsPath to ipfs under temp key
err = deleteKey(key.Name) // delete temp key
if err != nil {
panic(err)
}