Event JSON
{
"id": "3dab7c42e9003ca5e9ea45e0382adc1726b046e8512de1cd30e70a4288f4e12e",
"pubkey": "2b9a828913e945b2315406523c0e578a076bad56ea3c4ea7931392f70d1a8a3c",
"created_at": 1717983183,
"kind": 1,
"tags": [
[
"e",
"956894de469882b17a1b17992c54695ea16a8156769f22b3bb6209763b4d996c",
"",
"root"
],
[
"e",
"bdccfdaa3f2c63a904ec5391fb4cd05521eddabe9a6cf7286ec5fae6fab24c16"
],
[
"e",
"247ba416e88644082031dcd5678383d8090137df9f4bd1b2add0926c4e329da8",
"",
"reply"
],
[
"p",
"33c74427f3b2b73d5e38f3e6c991c122a55d204072356f71da49a0e209fb6940"
],
[
"p",
"2b9a828913e945b2315406523c0e578a076bad56ea3c4ea7931392f70d1a8a3c"
],
[
"r",
"nostr.DerivePublicKey"
],
[
"r",
"nostr.EncodePrivateKey"
],
[
"r",
"nostr.EncodePublicKey"
],
[
"r",
"file.txt"
],
[
"r",
"ioutil.ReadFile"
],
[
"r",
"log.Fatalf"
],
[
"r",
"nostr.Now"
],
[
"r",
"sk.Sign"
],
[
"r",
"nostr.Publish"
],
[
"r",
"fmt.Println"
],
[
"r",
"fmt.Println"
]
],
"content": "package main\n\nimport (\n\t\"fmt\"\n\t\"github.com/nbd-wtf/go-nostr\"\n\t\t\n\t\"io/ioutil\"\n\t\"log\"\n\t\n)\n\nfunc main() {\n\t// Generate a new private key\n\tsk = \"private key\"\n\t// Derive the public key from the private key\n\tpk, _ := nostr.DerivePublicKey(sk)\n\t// Encode the private key into NIP-19 format\n\tnsec, _ := nostr.EncodePrivateKey(sk)\n\t// Encode the public key into NIP-19 format\n\tnpub, _ := nostr.EncodePublicKey(pk)\n\n\n\tfilePath := \"path/to/your/file.txt\"\n\t// Read the file into a byte slice\n\tcontent, err := ioutil.ReadFile(filePath)\n\tif err!= nil {\n\t\tlog.Fatalf(\"Failed to read file: %v\", err)\n\t}\n\t// Convert the byte slice to a string\n\tdmcontent := string(content)\n\n\t// Create a new event to represent the DM\n\tevent := \u0026nostr.Event{\n\t\tType: \"dm\",\n\t\tPayload: map[string]interface{}{\n\t\t\t\"recipient\": npub,\n\t\t\t\"content\": dmcontent,\n\t\t},\n\t\tTimestamp: nostr.Now(),\n\t\tSignature: sk.Sign([]byte(fmt.Sprintf(\"%s %s\", nsec, npub))),\n\t}\n\n\t// Publish the event to a relay\n\trelayURL := \"wss://your-relay-url-here\"\n\terr = nostr.Publish(event, relayURL)\n\tif err!= nil {\n\t\tfmt.Println(\"Error publishing event:\", err)\n\t\treturn\n\t}\n\n\tfmt.Println(\"Direct message sent successfully!\")\n}\n",
"sig": "86308e13ee2a624d9b1a2ab80964e7023e48ea6dc900cae42467c4a4af60f8d3e8eb59c28f0b9c92b0974ea5fbeeb81886a952b18758fcc87fdec78e5149e35e"
}