Files
rfc.vac.dev/assets/js/a1cbd28d.235d81c4.js
2025-08-01 18:13:23 +00:00

1 line
105 KiB
JavaScript

"use strict";(self.webpackChunklogos_docs_template=self.webpackChunklogos_docs_template||[]).push([[7430],{86343:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>s,contentTitle:()=>r,default:()=>k,frontMatter:()=>l,metadata:()=>o,toc:()=>u});var a=t(87462),i=(t(67294),t(3905));const l={title:"36/WAKU2-BINDINGS-API",name:"Waku v2 C Bindings API",status:"draft",editor:"Richard Ramos &lt;richard@status.im&gt;",contributors:["Franck Royer &lt;franck@status.im&gt;"]},r=void 0,o={unversionedId:"standards/core/36/bindings-api",id:"standards/core/36/bindings-api",title:"36/WAKU2-BINDINGS-API",description:"- Status: draft",source:"@site/waku/standards/core/36/bindings-api.md",sourceDirName:"standards/core/36",slug:"/standards/core/36/bindings-api",permalink:"/waku/standards/core/36/bindings-api",draft:!1,tags:[],version:"current",frontMatter:{title:"36/WAKU2-BINDINGS-API",name:"Waku v2 C Bindings API",status:"draft",editor:"Richard Ramos &lt;richard@status.im&gt;",contributors:["Franck Royer &lt;franck@status.im&gt;"]},sidebar:"defaultSidebar",previous:{title:"34/WAKU2-PEER-EXCHANGE",permalink:"/waku/standards/core/34/peer-exchange"},next:{title:"64/WAKU2-NETWORK",permalink:"/waku/standards/core/64/network"}},s={},u=[{value:"Introduction",id:"introduction",level:2},{value:"Design requirements",id:"design-requirements",level:2},{value:"The API",id:"the-api",level:2},{value:"General",id:"general",level:3},{value:"<code>WakuCallBack</code> type",id:"wakucallback-type",level:4},{value:"Status Codes",id:"status-codes",level:3},{value:"<code>JsonMessage</code> type",id:"jsonmessage-type",level:3},{value:"<code>DecodedPayload</code> type",id:"decodedpayload-type",level:3},{value:"<code>FilterSubscription</code> type",id:"filtersubscription-type",level:3},{value:"<code>ContentFilter</code> type",id:"contentfilter-type",level:3},{value:"<code>StoreQuery</code> type",id:"storequery-type",level:3},{value:"<code>StoreResponse</code> type",id:"storeresponse-type",level:3},{value:"<code>PagingOptions</code> type",id:"pagingoptions-type",level:3},{value:"<code>Index</code> type",id:"index-type",level:3},{value:"Events",id:"events",level:2},{value:"<code>JsonSignal</code> type",id:"jsonsignal-type",level:3},{value:"<code>JsonMessageEvent</code> type",id:"jsonmessageevent-type",level:3},{value:"waku_set_event_callback",id:"waku_set_event_callback",level:3},{value:"Node management",id:"node-management",level:2},{value:"<code>JsonConfig</code> type",id:"jsonconfig-type",level:3},{value:"<code>GossipsubParameters</code> type",id:"gossipsubparameters-type",level:3},{value:"<code>Websocket</code> type",id:"websocket-type",level:3},{value:"waku_new",id:"waku_new",level:3},{value:"waku_start",id:"waku_start",level:3},{value:"waku_stop",id:"waku_stop",level:3},{value:"waku_peerid",id:"waku_peerid",level:3},{value:"waku_listen_addresses",id:"waku_listen_addresses",level:3},{value:"Connecting to peers",id:"connecting-to-peers",level:2},{value:"waku_add_peer",id:"waku_add_peer",level:3},{value:"waku_connect",id:"waku_connect",level:3},{value:"waku_connect_peerid",id:"waku_connect_peerid",level:3},{value:"waku_disconnect",id:"waku_disconnect",level:3},{value:"waku_peer_cnt",id:"waku_peer_cnt",level:3},{value:"waku_peers",id:"waku_peers",level:3},{value:"Waku Relay",id:"waku-relay",level:2},{value:"waku_content_topic",id:"waku_content_topic",level:3},{value:"waku_pubsub_topic",id:"waku_pubsub_topic",level:3},{value:"waku_default_pubsub_topic",id:"waku_default_pubsub_topic",level:3},{value:"waku_relay_publish",id:"waku_relay_publish",level:3},{value:"waku_relay_enough_peers",id:"waku_relay_enough_peers",level:3},{value:"waku_relay_subscribe",id:"waku_relay_subscribe",level:3},{value:"waku_relay_unsubscribe",id:"waku_relay_unsubscribe",level:3},{value:"waku_relay_topics",id:"waku_relay_topics",level:3},{value:"Waku Filter",id:"waku-filter",level:2},{value:"waku_filter_subscribe",id:"waku_filter_subscribe",level:3},{value:"waku_filter_ping",id:"waku_filter_ping",level:3},{value:"waku_filter_unsubscribe",id:"waku_filter_unsubscribe",level:3},{value:"waku_filter_unsubscribe_all",id:"waku_filter_unsubscribe_all",level:3},{value:"Waku Legacy Filter",id:"waku-legacy-filter",level:2},{value:"waku_legacy_filter_subscribe",id:"waku_legacy_filter_subscribe",level:3},{value:"waku_legacy_filter_unsubscribe",id:"waku_legacy_filter_unsubscribe",level:3},{value:"Waku Lightpush",id:"waku-lightpush",level:2},{value:"waku_lightpush_publish",id:"waku_lightpush_publish",level:3},{value:"Waku Store",id:"waku-store",level:2},{value:"waku_store_query",id:"waku_store_query",level:3},{value:"waku_store_local_query",id:"waku_store_local_query",level:3},{value:"Encrypting messages",id:"encrypting-messages",level:2},{value:"waku_encode_symmetric",id:"waku_encode_symmetric",level:3},{value:"waku_encode_asymmetric",id:"waku_encode_asymmetric",level:3},{value:"Decrypting messages",id:"decrypting-messages",level:2},{value:"waku_decode_symmetric",id:"waku_decode_symmetric",level:3},{value:"waku_decode_asymmetric",id:"waku_decode_asymmetric",level:3},{value:"DNS Discovery",id:"dns-discovery",level:2},{value:"waku_dns_discovery",id:"waku_dns_discovery",level:3},{value:"DiscoveryV5",id:"discoveryv5",level:2},{value:"waku_discv5_update_bootnodes",id:"waku_discv5_update_bootnodes",level:3},{value:"Copyright",id:"copyright",level:2}],p={toc:u};function k(e){let{components:n,...t}=e;return(0,i.kt)("wrapper",(0,a.Z)({},p,t,{components:n,mdxType:"MDXLayout"}),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"Status: draft"),(0,i.kt)("li",{parentName:"ul"},"Editor: Richard Ramos ","<",(0,i.kt)("a",{parentName:"li",href:"mailto:richard@status.im"},"richard@status.im"),">"),(0,i.kt)("li",{parentName:"ul"},"Contributors:",(0,i.kt)("ul",{parentName:"li"},(0,i.kt)("li",{parentName:"ul"},"Franck Royer ","<",(0,i.kt)("a",{parentName:"li",href:"mailto:franck@status.im"},"franck@status.im"),">")))),(0,i.kt)("h2",{id:"introduction"},"Introduction"),(0,i.kt)("p",null,"Native applications that wish to integrate Waku may not be able to use nwaku and\nits JSON RPC API due to constraints\non packaging, performance or executables."),(0,i.kt)("p",null,"An alternative is to link existing Waku implementation as a static or\ndynamic library in their application."),(0,i.kt)("p",null,"This specification describes the C API that SHOULD be implemented\nby native Waku library and that SHOULD be used to consume them."),(0,i.kt)("h2",{id:"design-requirements"},"Design requirements"),(0,i.kt)("p",null,"The API should be generic enough, so:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"it can be implemented by both nwaku and go-waku C-Bindings,"),(0,i.kt)("li",{parentName:"ul"},"it can be consumed from a variety of languages such as C#, Kotlin, Swift,\nRust, C++, etc.")),(0,i.kt)("p",null,"The selected format to pass data to and from the API is ",(0,i.kt)("inlineCode",{parentName:"p"},"JSON"),"."),(0,i.kt)("p",null,"It has been selected due to its widespread usage and\neasiness of use. Other alternatives MAY replace it in the future (C\nstructure, protobuf) if it brings limitations that need to be lifted."),(0,i.kt)("h2",{id:"the-api"},"The API"),(0,i.kt)("h3",{id:"general"},"General"),(0,i.kt)("h4",{id:"wakucallback-type"},(0,i.kt)("inlineCode",{parentName:"h4"},"WakuCallBack")," type"),(0,i.kt)("p",null,"All the API functions require passing callbacks\nwhich will be executed depending on the result of the execution result.\nThese callbacks are defined as"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"typedef void (*WakuCallBack) (const char* msg, size_t len_0);\n")),(0,i.kt)("p",null,"With ",(0,i.kt)("inlineCode",{parentName:"p"},"msg")," containing a ",(0,i.kt)("inlineCode",{parentName:"p"},"\\0")," terminated string, and ",(0,i.kt)("inlineCode",{parentName:"p"},"len_0")," the length of this string.\nThe format of the data sent to these callbacks\nwill depend on the function being executed.\nThe data can be characters, numeric or json."),(0,i.kt)("h3",{id:"status-codes"},"Status Codes"),(0,i.kt)("p",null,"The API functions return an integer with status codes\ndepending on the execution result.\nThe following status codes are defined:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"0")," - Success"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"1")," - Error"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"2")," - Missing callback")),(0,i.kt)("h3",{id:"jsonmessage-type"},(0,i.kt)("inlineCode",{parentName:"h3"},"JsonMessage")," type"),(0,i.kt)("p",null,"A Waku Message in JSON Format:"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts"},"{\n payload: string;\n contentTopic: string;\n version: number;\n timestamp: number;\n}\n")),(0,i.kt)("p",null,"Fields:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"payload"),": base64 encoded payload,\n",(0,i.kt)("a",{parentName:"li",href:"/"},(0,i.kt)("inlineCode",{parentName:"a"},"waku_utils_base64_encode")),"\ncan be used for this."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"contentTopic"),": The content topic to be set on the message."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"version"),": The Waku Message version number."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"timestamp"),": Unix timestamp in nanoseconds.")),(0,i.kt)("h3",{id:"decodedpayload-type"},(0,i.kt)("inlineCode",{parentName:"h3"},"DecodedPayload")," type"),(0,i.kt)("p",null,"A payload once decoded, used when a received Waku Message is encrypted:"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts"},"interface DecodedPayload {\n pubkey?: string;\n signature?: string;\n data: string;\n padding: string;\n }\n")),(0,i.kt)("p",null,"Fields:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"pubkey"),": Public key that signed the message (optional),\nhex encoded with ",(0,i.kt)("inlineCode",{parentName:"li"},"0x")," prefix,"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"signature"),": Message signature (optional), hex encoded with ",(0,i.kt)("inlineCode",{parentName:"li"},"0x")," prefix,"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"data"),": Decrypted message payload base64 encoded,"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"padding"),": Padding base64 encoded.")),(0,i.kt)("h3",{id:"filtersubscription-type"},(0,i.kt)("inlineCode",{parentName:"h3"},"FilterSubscription")," type"),(0,i.kt)("p",null,"The criteria to create subscription to a light node in JSON Format:"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts"},"{\n contentFilters: ContentFilter[];\n pubsubTopic: string?;\n}\n")),(0,i.kt)("p",null,"Fields:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"contentFilters"),": Array of ",(0,i.kt)("a",{parentName:"li",href:"#contentfilter-type"},(0,i.kt)("inlineCode",{parentName:"a"},"ContentFilter")),"\nbeing subscribed to / unsubscribed from."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"topic"),": Optional pubsub topic.")),(0,i.kt)("h3",{id:"contentfilter-type"},(0,i.kt)("inlineCode",{parentName:"h3"},"ContentFilter")," type"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts"},"{\n contentTopic: string;\n}\n")),(0,i.kt)("p",null,"Fields:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"contentTopic"),": The content topic of a Waku message.")),(0,i.kt)("h3",{id:"storequery-type"},(0,i.kt)("inlineCode",{parentName:"h3"},"StoreQuery")," type"),(0,i.kt)("p",null,"Criteria used to retrieve historical messages"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts"},"interface StoreQuery {\n pubsubTopic?: string;\n contentFilters?: ContentFilter[];\n startTime?: number;\n endTime?: number;\n pagingOptions?: PagingOptions\n }\n")),(0,i.kt)("p",null,"Fields:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"pubsubTopic"),": The pubsub topic on which messages are published."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"contentFilters"),":\nArray of ",(0,i.kt)("a",{parentName:"li",href:"#contentfilter-type"},(0,i.kt)("inlineCode",{parentName:"a"},"ContentFilter"))," to query for historical messages,"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"startTime"),": The inclusive lower bound on the timestamp of queried messages.\nThis field holds the Unix epoch time in nanoseconds."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"endTime"),": The inclusive upper bound on the timestamp of queried messages.\nThis field holds the Unix epoch time in nanoseconds."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"pagingOptions"),": Paging information in ",(0,i.kt)("a",{parentName:"li",href:"#pagingoptions-type"},(0,i.kt)("inlineCode",{parentName:"a"},"PagingOptions"))," format.")),(0,i.kt)("h3",{id:"storeresponse-type"},(0,i.kt)("inlineCode",{parentName:"h3"},"StoreResponse")," type"),(0,i.kt)("p",null,"The response received after doing a query to a store node:"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts"},"interface StoreResponse {\n messages: JsonMessage[];\n pagingOptions?: PagingOptions;\n }\n")),(0,i.kt)("p",null,"Fields:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"messages"),": Array of retrieved historical messages\nin ",(0,i.kt)("a",{parentName:"li",href:"#jsonmessage-type"},(0,i.kt)("inlineCode",{parentName:"a"},"JsonMessage"))," format."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"pagingOption"),": Paging information in ",(0,i.kt)("a",{parentName:"li",href:"#pagingoptions-type"},(0,i.kt)("inlineCode",{parentName:"a"},"PagingOptions"))," format\nfrom which to resume further historical queries")),(0,i.kt)("h3",{id:"pagingoptions-type"},(0,i.kt)("inlineCode",{parentName:"h3"},"PagingOptions")," type"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts"},"interface PagingOptions {\n pageSize: number;\n cursor?: Index;\n forward: bool;\n }\n")),(0,i.kt)("p",null,"Fields:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"pageSize"),": Number of messages to retrieve per page."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"cursor"),": Message Index from which to perform pagination.\nIf not included and forward is set to true,\npaging will be performed from the beginning of the list.\nIf not included and forward is set to false,\npaging will be performed from the end of the list."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"forward"),": ",(0,i.kt)("inlineCode",{parentName:"li"},"true")," if paging forward, ",(0,i.kt)("inlineCode",{parentName:"li"},"false")," if paging backward")),(0,i.kt)("h3",{id:"index-type"},(0,i.kt)("inlineCode",{parentName:"h3"},"Index")," type"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts"},"interface Index {\n digest: string;\n receiverTime: number;\n senderTime: number;\n pubsubTopic: string;\n }\n")),(0,i.kt)("p",null,"Fields:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"digest"),": Hash of the message at this ",(0,i.kt)("a",{parentName:"li",href:"#index-type"},(0,i.kt)("inlineCode",{parentName:"a"},"Index")),"."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"receiverTime"),": UNIX timestamp in nanoseconds\nat which the message at this ",(0,i.kt)("a",{parentName:"li",href:"#index-type"},(0,i.kt)("inlineCode",{parentName:"a"},"Index"))," was received."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"senderTime"),": UNIX timestamp in nanoseconds at which the message is generated\nby its sender."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"pubsubTopic"),": The pubsub topic of the message at this ",(0,i.kt)("a",{parentName:"li",href:"#index-type"},(0,i.kt)("inlineCode",{parentName:"a"},"Index")),".")),(0,i.kt)("h2",{id:"events"},"Events"),(0,i.kt)("p",null,"Asynchronous events require a callback to be registered.\nAn example of an asynchronous event that might be emitted is receiving a message.\nWhen an event is emitted,\nthis callback will be triggered receiving a JSON string of type ",(0,i.kt)("inlineCode",{parentName:"p"},"JsonSignal"),"."),(0,i.kt)("h3",{id:"jsonsignal-type"},(0,i.kt)("inlineCode",{parentName:"h3"},"JsonSignal")," type"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts"},"{\n type: string;\n event: any;\n}\n")),(0,i.kt)("p",null,"Fields:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"type"),": Type of signal being emitted. Currently, only ",(0,i.kt)("inlineCode",{parentName:"li"},"message")," is available."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"event"),": Format depends on the type of signal.")),(0,i.kt)("p",null,"For example:"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-json"},'{\n "type": "message",\n "event": {\n "pubsubTopic": "/waku/2/default-waku/proto",\n "messageId": "0x6496491e40dbe0b6c3a2198c2426b16301688a2daebc4f57ad7706115eac3ad1",\n "wakuMessage": {\n "payload": "TODO",\n "contentTopic": "/my-app/1/notification/proto",\n "version": 1,\n "timestamp": 1647826358000000000\n }\n }\n}\n')),(0,i.kt)("table",null,(0,i.kt)("thead",{parentName:"table"},(0,i.kt)("tr",{parentName:"thead"},(0,i.kt)("th",{parentName:"tr",align:"left"},(0,i.kt)("inlineCode",{parentName:"th"},"type")),(0,i.kt)("th",{parentName:"tr",align:null},(0,i.kt)("inlineCode",{parentName:"th"},"event")," Type"))),(0,i.kt)("tbody",{parentName:"table"},(0,i.kt)("tr",{parentName:"tbody"},(0,i.kt)("td",{parentName:"tr",align:"left"},(0,i.kt)("inlineCode",{parentName:"td"},"message")),(0,i.kt)("td",{parentName:"tr",align:null},(0,i.kt)("inlineCode",{parentName:"td"},"JsonMessageEvent"))))),(0,i.kt)("h3",{id:"jsonmessageevent-type"},(0,i.kt)("inlineCode",{parentName:"h3"},"JsonMessageEvent")," type"),(0,i.kt)("p",null,"Type of ",(0,i.kt)("inlineCode",{parentName:"p"},"event")," field for a ",(0,i.kt)("inlineCode",{parentName:"p"},"message")," event:"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts"},"{\n pubsubTopic: string;\n messageId: string;\n wakuMessage: JsonMessage;\n}\n")),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"pubsubTopic"),": The pubsub topic on which the message was received."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"messageId"),": The message id."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"wakuMessage"),": The message in ",(0,i.kt)("a",{parentName:"li",href:"#jsonmessage-type"},(0,i.kt)("inlineCode",{parentName:"a"},"JsonMessage"))," format.")),(0,i.kt)("h3",{id:"waku_set_event_callback"},"waku_set_event_callback"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern void waku_set_event_callback(WakuCallBack cb){}\n")),(0,i.kt)("p",null,"Register callback to act as event handler and receive application signals,\nwhich are used to react to asynchronous events in Waku."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack cb"),": callback that will be executed when an async event is emitted.")),(0,i.kt)("h2",{id:"node-management"},"Node management"),(0,i.kt)("h3",{id:"jsonconfig-type"},(0,i.kt)("inlineCode",{parentName:"h3"},"JsonConfig")," type"),(0,i.kt)("p",null,"Type holding a node configuration:"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts"},"interface JsonConfig {\n host?: string;\n port?: number;\n advertiseAddr?: string;\n nodeKey?: string;\n keepAliveInterval?: number;\n relay?: boolean;\n relayTopics?: Array<string>;\n gossipsubParameters?: GossipSubParameters;\n minPeersToPublish?: number\n legacyFilter?: boolean;\n discV5?: boolean;\n discV5BootstrapNodes?: Array<string>;\n discV5UDPPort?: number;\n store?: boolean;\n databaseURL?: string;\n storeRetentionMaxMessages?: number;\n storeRetentionTimeSeconds?: number;\n websocket?: Websocket;\n dns4DomainName?: string;\n}\n")),(0,i.kt)("p",null,"Fields:"),(0,i.kt)("p",null,"All fields are optional.\nIf a key is ",(0,i.kt)("inlineCode",{parentName:"p"},"undefined"),", or ",(0,i.kt)("inlineCode",{parentName:"p"},"null"),", a default value will be set."),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"host"),": Listening IP address.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"0.0.0.0"),"."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"port"),": Libp2p TCP listening port.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"60000"),".\nUse ",(0,i.kt)("inlineCode",{parentName:"li"},"0")," for random."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"advertiseAddr"),": External address to advertise to other nodes.\nCan be ip4, ip6 or dns4, dns6.\nIf ",(0,i.kt)("inlineCode",{parentName:"li"},"null"),", the multiaddress(es) generated from the ip and\nport specified in the config (or default ones) will be used.\nDefault: ",(0,i.kt)("inlineCode",{parentName:"li"},"null"),"."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"nodeKey"),": Secp256k1 private key in Hex format (",(0,i.kt)("inlineCode",{parentName:"li"},"0x123...abc"),").\nDefault random."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"keepAliveInterval"),":\nInterval in seconds for pinging peers to keep the connection alive.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"20"),"."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"relay"),": Enable relay protocol.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"true"),"."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"relayTopics"),":\nArray of pubsub topics that WakuRelay will automatically subscribe to\nwhen the node starts\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"[]")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"gossipSubParameters"),": custom gossipsub parameters.\nSee ",(0,i.kt)("inlineCode",{parentName:"li"},"GossipSubParameters")," section for defaults"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"minPeersToPublish"),": The minimum number of peers required on a topic\nto allow broadcasting a message.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"0"),"."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"legacyFilter"),": Enable Legacy Filter protocol.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"false"),"."),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"discV5"),": Enable DiscoveryV5.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"false")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"discV5BootstrapNodes"),": Array of bootstrap nodes ENR"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"discV5UDPPort"),": UDP port for DiscoveryV5\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"9000")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"store"),": Enable store protocol to persist message history\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"false")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"databaseURL"),": url connection string. Accepts SQLite and\nPostgreSQL connection strings\nDefault: ",(0,i.kt)("inlineCode",{parentName:"li"},"sqlite3://store.db")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"storeRetentionMaxMessages"),": max number of messages to store in the database.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"10000")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"storeRetentionTimeSeconds"),": max number of seconds that a message will be persisted\nin the database.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"2592000")," (30d)"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"websocket"),": custom websocket support parameters. See ",(0,i.kt)("inlineCode",{parentName:"li"},"Websocket")," section for defaults"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"dns4DomainName"),": the domain name resolving to the node's public IPv4 address.")),(0,i.kt)("p",null,"For example:"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-json"},'{\n "host": "0.0.0.0",\n "port": 60000,\n "advertiseAddr": "1.2.3.4",\n "nodeKey": "0x123...567",\n "keepAliveInterval": 20,\n "relay": true,\n "minPeersToPublish": 0\n}\n')),(0,i.kt)("h3",{id:"gossipsubparameters-type"},(0,i.kt)("inlineCode",{parentName:"h3"},"GossipsubParameters")," type"),(0,i.kt)("p",null,"Type holding custom gossipsub configuration:"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts"},"interface GossipSubParameters {\n D?: number;\n D_low?: number;\n D_high?: number;\n D_score?: number;\n D_out?: number;\n HistoryLength?: number;\n HistoryGossip?: number;\n D_lazy?: number;\n GossipFactor?: number;\n GossipRetransmission?: number;\n HeartbeatInitialDelayMs?: number;\n HeartbeatIntervalSeconds?: number;\n SlowHeartbeatWarning?: number;\n FanoutTTLSeconds?: number;\n PrunePeers?: number;\n PruneBackoffSeconds?: number;\n UnsubscribeBackoffSeconds?: number;\n Connectors?: number;\n MaxPendingConnections?: number;\n ConnectionTimeoutSeconds?: number;\n DirectConnectTicks?: number;\n DirectConnectInitialDelaySeconds?: number;\n OpportunisticGraftTicks?: number;\n OpportunisticGraftPeers?: number;\n GraftFloodThresholdSeconds?: number;\n MaxIHaveLength?: number;\n MaxIHaveMessages?: number;\n IWantFollowupTimeSeconds?: number;\n}\n")),(0,i.kt)("p",null,"Fields:"),(0,i.kt)("p",null,"All fields are optional.\nIf a key is ",(0,i.kt)("inlineCode",{parentName:"p"},"undefined"),", or ",(0,i.kt)("inlineCode",{parentName:"p"},"null"),", a default value will be set."),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"d"),": optimal degree for a GossipSub topic mesh.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"6")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"dLow"),": lower bound on the number of peers we keep in a GossipSub topic mesh\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"5")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"dHigh"),": upper bound on the number of peers we keep in a GossipSub topic mesh.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"12")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"dScore"),": affects how peers are selected when pruning a mesh due to over subscription.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"4")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"dOut"),": sets the quota for the number of outbound connections\nto maintain in a topic mesh.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"2")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"historyLength"),": controls the size of the message cache used for gossip.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"5")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"historyGossip"),": controls how many cached message ids\nwe will advertise in IHAVE gossip messages.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"3")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"dLazy"),": affects how many peers we will emit gossip to at each heartbeat.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"6")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"gossipFactor"),": affects how many peers we will emit gossip to at each heartbeat.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"0.25")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"gossipRetransmission"),":\ncontrols how many times we will allow a peer to request the same message id\nthrough IWANT gossip before we start ignoring them.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"3")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"heartbeatInitialDelayMs"),": short delay in milliseconds before\nthe heartbeat timer begins after the router is initialized.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"100")," milliseconds"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"heartbeatIntervalSeconds"),": controls the time between heartbeats.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"1")," second"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"slowHeartbeatWarning"),": duration threshold for heartbeat processing before\nemitting a warning.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"0.1")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"fanoutTTLSeconds"),": controls how long we keep track of the fanout state.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"60")," seconds"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"prunePeers"),": controls the number of peers to include in prune Peer eXchange.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"16")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"pruneBackoffSeconds"),": controls the backoff time for pruned peers.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"60")," seconds"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"unsubscribeBackoffSeconds"),": controls the backoff time to use when unsuscribing\nfrom a topic.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"10")," seconds"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"connectors"),": number of active connection attempts for peers obtained through PX.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"8")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"maxPendingConnections"),": maximum number of pending connections\nfor peers attempted through px.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"128")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"connectionTimeoutSeconds"),": timeout in seconds for connection attempts.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"30")," seconds"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"directConnectTicks"),": the number of heartbeat ticks\nfor attempting to reconnect direct peers that are not currently connected.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"300")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"directConnectInitialDelaySeconds"),": initial delay before opening connections to\ndirect peers.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"1")," second"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"opportunisticGraftTicks"),": number of heartbeat ticks for attempting to\nimprove the mesh with opportunistic grafting.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"60")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"opportunisticGraftPeers"),": the number of peers to opportunistically graft.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"2")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"graftFloodThresholdSeconds"),": If a GRAFT comes before GraftFloodThresholdSeconds\nhas elapsed since the last PRUNE,\nthen there is an extra score penalty applied to the peer through P7.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"10")," seconds"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"maxIHaveLength"),": max number of messages to include in an IHAVE message,\nalso controls the max number of IHAVE ids we will accept and\nrequest with IWANT from a peer within a heartbeat.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"5000")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"maxIHaveMessages"),": max number of IHAVE messages to accept from a peer\nwithin a heartbeat.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"10")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"iWantFollowupTimeSeconds"),": Time to wait for a message requested\nthrough IWANT following an IHAVE advertisement.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"3")," seconds"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"seenMessagesTTLSeconds"),": configures when a previously seen message ID\ncan be forgotten about.\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"120")," seconds")),(0,i.kt)("h3",{id:"websocket-type"},(0,i.kt)("inlineCode",{parentName:"h3"},"Websocket")," type"),(0,i.kt)("p",null,"Type holding custom websocket support configuration:"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-ts"},"interface Websocket {\n enabled?: bool;\n host?: string;\n port?: number;\n secure?: bool;\n certPath?: string;\n keyPath?: string;\n}\n")),(0,i.kt)("p",null,"Fields:"),(0,i.kt)("p",null,"All fields are optional.\nIf a key is ",(0,i.kt)("inlineCode",{parentName:"p"},"undefined"),", or ",(0,i.kt)("inlineCode",{parentName:"p"},"null"),", a default value will be set.\nIf using ",(0,i.kt)("inlineCode",{parentName:"p"},"secure")," websockets support, ",(0,i.kt)("inlineCode",{parentName:"p"},"certPath")," and\n",(0,i.kt)("inlineCode",{parentName:"p"},"keyPath")," become mandatory attributes.\nUnless selfsigned certificates are used,\nit will probably make sense in the ",(0,i.kt)("inlineCode",{parentName:"p"},"JsonConfiguration"),"\nto specify the domain name used in the certificate in the ",(0,i.kt)("inlineCode",{parentName:"p"},"dns4DomainName")," attribute."),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"enabled"),": indicates if websockets support will be enabled\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"false")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"host"),": listening address for websocket connections\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"0.0.0.0")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"port"),": TCP listening port for websocket connection\n(",(0,i.kt)("inlineCode",{parentName:"li"},"0")," for random, binding to ",(0,i.kt)("inlineCode",{parentName:"li"},"443")," requires root access)\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"60001"),", if secure websockets support is enabled, the default is ",(0,i.kt)("inlineCode",{parentName:"li"},"6443\u201c")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"secure"),": enable secure websockets support\nDefault ",(0,i.kt)("inlineCode",{parentName:"li"},"false")),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"certPath"),": secure websocket certificate path"),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("inlineCode",{parentName:"li"},"keyPath"),": secure websocket key path")),(0,i.kt)("h3",{id:"waku_new"},"waku_new"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_new(char* jsonConfig, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Instantiates a Waku node."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* jsonConfig"),":\nJSON string containing the options used to initialize a waku node.\nType ",(0,i.kt)("a",{parentName:"li",href:"#jsonconfig-type"},(0,i.kt)("inlineCode",{parentName:"a"},"JsonConfig")),".\nIt can be ",(0,i.kt)("inlineCode",{parentName:"li"},"NULL")," to use defaults."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": ",(0,i.kt)("a",{parentName:"li",href:"#wakucallback-type"},(0,i.kt)("inlineCode",{parentName:"a"},"WakuCallBack")),".\nCallback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h3",{id:"waku_start"},"waku_start"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_start(WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Starts a Waku node mounting all the protocols that were enabled\nduring the Waku node instantiation."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),":\ncallback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h3",{id:"waku_stop"},"waku_stop"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_stop(WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Stops a Waku node."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h3",{id:"waku_peerid"},"waku_peerid"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_peerid(WakuCallBack onOkCb, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Get the peer ID of the waku node."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will receive the base58 encoded peer ID,\nfor example ",(0,i.kt)("inlineCode",{parentName:"li"},"QmWjHKUrXDHPCwoWXpUZ77E8o6UbAoTTZwf1AD1tDC4KNP")),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h3",{id:"waku_listen_addresses"},"waku_listen_addresses"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_listen_addresses(WakuCallBack onOkCb, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Get the multiaddresses the Waku node is listening to."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will receive a json array of multiaddresses.\nThe multiaddresses are ",(0,i.kt)("inlineCode",{parentName:"li"},"string"),"s. For example:")),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-json"},'[\n "/ip4/127.0.0.1/tcp/30303",\n "/ip4/1.2.3.4/tcp/30303",\n "/dns4/waku.node.example/tcp/8000/wss"\n]\n')),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," and ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h2",{id:"connecting-to-peers"},"Connecting to peers"),(0,i.kt)("h3",{id:"waku_add_peer"},"waku_add_peer"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_add_peer(char* address, char* protocolId, WakuCallBack onOkCb, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Add a node multiaddress and protocol to the waku node's peerstore."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* address"),": A multiaddress (with peer id) to reach the peer being added."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* protocolId"),": A protocol we expect the peer to support."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will receive the base 58 peer ID of the peer that was added."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h3",{id:"waku_connect"},"waku_connect"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_connect(char* address, int timeoutMs, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Dial peer using a multiaddress."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* address"),": A multiaddress to reach the peer being dialed."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"int timeoutMs"),": Timeout value in milliseconds to execute the call.\nIf the function execution takes longer than this value,\nthe execution will be canceled and an error returned.\nUse ",(0,i.kt)("inlineCode",{parentName:"li"},"0")," for no timeout."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h3",{id:"waku_connect_peerid"},"waku_connect_peerid"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_connect_peerid(char* peerId, int timeoutMs, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Dial peer using its peer ID."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* peerID"),": Peer ID to dial.\nThe peer must be already known.\nIt must have been added before with ",(0,i.kt)("a",{parentName:"li",href:"#waku_add_peer"},(0,i.kt)("inlineCode",{parentName:"a"},"waku_add_peer")),"\nor previously dialed with ",(0,i.kt)("a",{parentName:"li",href:"#waku_add_peer"},(0,i.kt)("inlineCode",{parentName:"a"},"waku_connect")),"."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"int timeoutMs"),": Timeout value in milliseconds to execute the call.\nIf the function execution takes longer than this value,\nthe execution will be canceled and an error returned.\nUse ",(0,i.kt)("inlineCode",{parentName:"li"},"0")," for no timeout."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h3",{id:"waku_disconnect"},"waku_disconnect"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_disconnect(char* peerId, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Disconnect a peer using its peerID"),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* peerID"),": Peer ID to disconnect."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h3",{id:"waku_peer_cnt"},"waku_peer_cnt"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_peer_cnt(WakuCallBack onOkCb, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Get number of connected peers."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will receive the number of connected peers."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h3",{id:"waku_peers"},"waku_peers"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_peers(WakuCallBack onOkCb, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Retrieve the list of peers known by the Waku node."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will receive a json array with the list of peers.\nThis list has this format:")),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-json"},'[\n {\n "peerID": "16Uiu2HAmJb2e28qLXxT5kZxVUUoJt72EMzNGXB47RedcBafeDCBA",\n "protocols": [\n "/ipfs/id/1.0.0",\n "/vac/waku/relay/2.0.0",\n "/ipfs/ping/1.0.0"\n ],\n "addrs": [\n "/ip4/1.2.3.4/tcp/30303"\n ],\n "connected": true\n }\n]\n')),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h2",{id:"waku-relay"},"Waku Relay"),(0,i.kt)("h3",{id:"waku_content_topic"},"waku_content_topic"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_content_topic(char* applicationName, unsigned int applicationVersion, char* contentTopicName, char* encoding, WakuCallBack onOkCb){}\n")),(0,i.kt)("p",null,"Create a content topic string according to ",(0,i.kt)("a",{parentName:"p",href:"../../../informational/23/topics"},"RFC 23"),"."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* applicationName")),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"unsigned int applicationVersion")),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* contentTopicName")),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* encoding"),": depending on the payload, use ",(0,i.kt)("inlineCode",{parentName:"li"},"proto"),", ",(0,i.kt)("inlineCode",{parentName:"li"},"rlp")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"rfc26")),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will receive the content topic formatted according to ",(0,i.kt)("a",{parentName:"li",href:"../../../informational/23/topics"},"RFC 23"),":\n",(0,i.kt)("inlineCode",{parentName:"li"},"/{application-name}/{version-of-the-application}/{content-topic-name}/{encoding}")),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," callback")),(0,i.kt)("h3",{id:"waku_pubsub_topic"},"waku_pubsub_topic"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_pubsub_topic(char* name, char* encoding, WakuCallBack onOkCb){}\n")),(0,i.kt)("p",null,"Create a pubsub topic string according to ",(0,i.kt)("a",{parentName:"p",href:"../../../informational/23/topics"},"RFC 23"),"."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* name")),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* encoding"),": depending on the payload, use ",(0,i.kt)("inlineCode",{parentName:"li"},"proto"),", ",(0,i.kt)("inlineCode",{parentName:"li"},"rlp")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"rfc26")),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will get populated with a pubsub topic formatted according to ",(0,i.kt)("a",{parentName:"li",href:"../../../informational/23/topics"},"RFC 23"),":\n",(0,i.kt)("inlineCode",{parentName:"li"},"/waku/2/{topic-name}/{encoding}")),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," callback")),(0,i.kt)("h3",{id:"waku_default_pubsub_topic"},"waku_default_pubsub_topic"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_default_pubsub_topic(WakuCallBack onOkCb){}\n")),(0,i.kt)("p",null,"Returns the default pubsub topic used for exchanging waku messages\ndefined in ",(0,i.kt)("a",{parentName:"p",href:"../10/waku2"},"RFC 10"),"."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will get populated with ",(0,i.kt)("inlineCode",{parentName:"li"},"/waku/2/default-waku/proto")),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," callback")),(0,i.kt)("h3",{id:"waku_relay_publish"},"waku_relay_publish"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_relay_publish(char* messageJson, char* pubsubTopic, int timeoutMs, WakuCallBack onOkCb, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Publish a message using Waku Relay."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* messageJson"),":\nJSON string containing the ",(0,i.kt)("a",{parentName:"li",href:"../14/message"},"Waku Message"),"\nas ",(0,i.kt)("a",{parentName:"li",href:"#jsonmessage-type"},(0,i.kt)("inlineCode",{parentName:"a"},"JsonMessage")),"."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* pubsubTopic"),": pubsub topic on which to publish the message.\nIf ",(0,i.kt)("inlineCode",{parentName:"li"},"NULL"),", it uses the default pubsub topic."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"int timeoutMs"),": Timeout value in milliseconds to execute the call.\nIf the function execution takes longer than this value,\nthe execution will be canceled and an error returned.\nUse ",(0,i.kt)("inlineCode",{parentName:"li"},"0")," for no timeout."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"If the execution is successful, the ",(0,i.kt)("inlineCode",{parentName:"p"},"result")," field contains the message ID."),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will get populated with the message ID"),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h3",{id:"waku_relay_enough_peers"},"waku_relay_enough_peers"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_relay_enough_peers(char* pubsubTopic, WakuCallBack onOkCb, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Determine if there are enough peers to publish a message on a given pubsub topic."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* pubsubTopic"),": Pubsub topic to verify.\nIf ",(0,i.kt)("inlineCode",{parentName:"li"},"NULL"),", it verifies the number of peers in the default pubsub topic."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will receive a string ",(0,i.kt)("inlineCode",{parentName:"li"},"boolean")," indicating whether there are enough peers,\ni.e. ",(0,i.kt)("inlineCode",{parentName:"li"},"true")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"false")),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h3",{id:"waku_relay_subscribe"},"waku_relay_subscribe"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_relay_subscribe(char* topic, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Subscribe to a Waku Relay pubsub topic to receive messages."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* topic"),": Pubsub topic to subscribe to.\nIf ",(0,i.kt)("inlineCode",{parentName:"li"},"NULL"),", it subscribes to the default pubsub topic."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("p",null,"Events"),(0,i.kt)("p",null,"When a message is received,\na ",(0,i.kt)("inlineCode",{parentName:"p"},'"message"')," event is emitted containing the message, pubsub topic,\nand node ID in which\nthe message was received."),(0,i.kt)("p",null,"The ",(0,i.kt)("inlineCode",{parentName:"p"},"event")," type is ",(0,i.kt)("a",{parentName:"p",href:"#jsonmessageevent-type"},(0,i.kt)("inlineCode",{parentName:"a"},"JsonMessageEvent")),"."),(0,i.kt)("p",null,"For Example:"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-json"},'{\n "type": "message",\n "event": {\n "pubsubTopic": "/waku/2/default-waku/proto",\n "messageId": "0x6496491e40dbe0b6c3a2198c2426b16301688a2daebc4f57ad7706115eac3ad1",\n "wakuMessage": {\n "payload": "TODO",\n "contentTopic": "/my-app/1/notification/proto",\n "version": 1,\n "timestamp": 1647826358000000000\n }\n }\n}\n')),(0,i.kt)("h3",{id:"waku_relay_unsubscribe"},"waku_relay_unsubscribe"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_relay_unsubscribe(char* topic, WakuCallBack onErrCb)\n")),(0,i.kt)("p",null,"Closes the pubsub subscription to a pubsub topic. No more messages will be received\nfrom this pubsub topic."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* pusubTopic"),": Pubsub topic to unsubscribe from.\nIf ",(0,i.kt)("inlineCode",{parentName:"li"},"NULL"),", unsubscribes from the default pubsub topic."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h3",{id:"waku_relay_topics"},"waku_relay_topics"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_relay_topics(WakuCallBack onOkCb, WakuCallBack onErrCb)\n")),(0,i.kt)("p",null,"Get the list of subscribed pubsub topics in Waku Relay."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will receive a json array of pubsub topics\ni.e ",(0,i.kt)("inlineCode",{parentName:"li"},'["pubsubTopic1", "pubsubTopic2"]')),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h2",{id:"waku-filter"},"Waku Filter"),(0,i.kt)("h3",{id:"waku_filter_subscribe"},"waku_filter_subscribe"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_filter_subscribe(char* filterJSON, char* peerID, int timeoutMs, WakuCallBack onOkCb, WakuCallBack onErrCb)\n")),(0,i.kt)("p",null,"Creates a subscription to a filter full node matching a content filter.."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* filterJSON"),":\nJSON string containing the ",(0,i.kt)("a",{parentName:"li",href:"#filtersubscription-type"},(0,i.kt)("inlineCode",{parentName:"a"},"FilterSubscription")),"\nto subscribe to."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* peerID"),": Peer ID to subscribe to.\nThe peer must be already known.\nIt must have been added before with ",(0,i.kt)("a",{parentName:"li",href:"#waku_add_peer"},(0,i.kt)("inlineCode",{parentName:"a"},"waku_add_peer")),"\nor previously dialed with ",(0,i.kt)("a",{parentName:"li",href:"#waku_connect"},(0,i.kt)("inlineCode",{parentName:"a"},"waku_connect_peer")),".\nUse ",(0,i.kt)("inlineCode",{parentName:"li"},"NULL")," to automatically select a node."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"int timeoutMs"),": Timeout value in milliseconds to execute the call.\nIf the function execution takes longer than this value,\nthe execution will be canceled and an error returned.\nUse ",(0,i.kt)("inlineCode",{parentName:"li"},"0")," for no timeout."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will receive the subscription details, for example:")),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-json"},'{\n "peerID": "....",\n "pubsubTopic": "...",\n "contentTopics": [...]\n}\n')),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("p",null,"Events"),(0,i.kt)("p",null,"When a message is received,\na ",(0,i.kt)("inlineCode",{parentName:"p"},'"message"')," event is emitted containing the message, pubsub topic,\nand node ID in which the message was received."),(0,i.kt)("p",null,"The ",(0,i.kt)("inlineCode",{parentName:"p"},"event")," type is ",(0,i.kt)("a",{parentName:"p",href:"#jsonmessageevent-type"},(0,i.kt)("inlineCode",{parentName:"a"},"JsonMessageEvent")),"."),(0,i.kt)("p",null,"For Example:"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-json"},'{\n "type": "message",\n "event": {\n "pubsubTopic": "/waku/2/default-waku/proto",\n "messageId": "0x6496491e40dbe0b6c3a2198c2426b16301688a2daebc4f57ad7706115eac3ad1",\n "wakuMessage": {\n "payload": "TODO",\n "contentTopic": "/my-app/1/notification/proto",\n "version": 1,\n "timestamp": 1647826358000000000\n }\n }\n}\n')),(0,i.kt)("h3",{id:"waku_filter_ping"},"waku_filter_ping"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_filter_ping(char* peerID, int timeoutMs, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Used to know if a service node has an active subscription for this client"),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* peerID"),": Peer ID to check for an active subscription\nThe peer must be already known.\nIt must have been added before with ",(0,i.kt)("a",{parentName:"li",href:"#waku_connect"},(0,i.kt)("inlineCode",{parentName:"a"},"waku_add_peer")),"\nor previously dialed with ",(0,i.kt)("a",{parentName:"li",href:"#waku_connect"},(0,i.kt)("inlineCode",{parentName:"a"},"waku_connect_peer")),"."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"int timeoutMs"),": Timeout value in milliseconds to execute the call.\nIf the function execution takes longer than this value,\nthe execution will be canceled and an error returned.\nUse ",(0,i.kt)("inlineCode",{parentName:"li"},"0")," for no timeout."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h3",{id:"waku_filter_unsubscribe"},"waku_filter_unsubscribe"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_filter_unsubscribe(filterJSON *C.char, char* peerID, int timeoutMs, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Sends a requests to a service node to stop pushing messages matching this filter\nto this client.\nIt might be used to modify an existing subscription by\nproviding a subset of the original filter criteria"),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* filterJSON"),": JSON string containing the ",(0,i.kt)("a",{parentName:"li",href:"#filtersubscription-type"},(0,i.kt)("inlineCode",{parentName:"a"},"FilterSubscription")),"\ncriteria to unsubscribe from"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* peerID"),": Peer ID to unsubscribe from\nThe peer must be already known.\nIt must have been added before with ",(0,i.kt)("a",{parentName:"li",href:"#waku_add_peer"},(0,i.kt)("inlineCode",{parentName:"a"},"waku_add_peer")),"\nor previously dialed with ",(0,i.kt)("a",{parentName:"li",href:"#waku_connect"},(0,i.kt)("inlineCode",{parentName:"a"},"waku_connect_peer")),"."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"int timeoutMs"),": Timeout value in milliseconds to execute the call.\nIf the function execution takes longer than this value,\nthe execution will be canceled and an error returned.\nUse ",(0,i.kt)("inlineCode",{parentName:"li"},"0")," for no timeout."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h3",{id:"waku_filter_unsubscribe_all"},"waku_filter_unsubscribe_all"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_filter_unsubscribe_all(char* peerID, int timeoutMs, WakuCallBack onOkCb, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Sends a requests to a service node (or all service nodes) to stop pushing messages"),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* peerID"),": Peer ID to unsubscribe from\nThe peer must be already known.\nIt must have been added before with ",(0,i.kt)("a",{parentName:"li",href:"#waku_add_peer"},(0,i.kt)("inlineCode",{parentName:"a"},"waku_add_peer")),"\nor previously dialed with ",(0,i.kt)("a",{parentName:"li",href:"#waku_connect"},(0,i.kt)("inlineCode",{parentName:"a"},"waku_connect_peer")),".\nUse ",(0,i.kt)("inlineCode",{parentName:"li"},"NULL")," to unsubscribe from all peers with active subscriptions"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"int timeoutMs"),": Timeout value in milliseconds to execute the call.\nIf the function execution takes longer than this value,\nthe execution will be canceled and an error returned.\nUse ",(0,i.kt)("inlineCode",{parentName:"li"},"0")," for no timeout."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will receive an array\nwith information about the state of each unsubscription attempt (one per peer)")),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-json"},'[\n {\n "peerID": ....,\n "error": "" // Empty if succesful\n },\n ...\n]\n')),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h2",{id:"waku-legacy-filter"},"Waku Legacy Filter"),(0,i.kt)("h3",{id:"waku_legacy_filter_subscribe"},"waku_legacy_filter_subscribe"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_legacy_filter_subscribe(char* filterJSON, char* peerID, int timeoutMs, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Creates a subscription in a lightnode for messages that matches a content filter\nand optionally a ",(0,i.kt)("a",{parentName:"p",href:"https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor"},"PubSub ",(0,i.kt)("inlineCode",{parentName:"a"},"topic")),"."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* filterJSON"),":\nJSON string containing the ",(0,i.kt)("a",{parentName:"li",href:"#waku_legacy_filter_subscribe"},(0,i.kt)("inlineCode",{parentName:"a"},"LegacyFilterSubscription")),"\nto subscribe to."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* peerID"),": Peer ID to subscribe to.\nThe peer must be already known.\nIt must have been added before with ",(0,i.kt)("a",{parentName:"li",href:"#waku_add_peer"},(0,i.kt)("inlineCode",{parentName:"a"},"waku_add_peer")),"\nor previously dialed with ",(0,i.kt)("a",{parentName:"li",href:"#waku_connect"},(0,i.kt)("inlineCode",{parentName:"a"},"waku_connect_peer")),".\nUse ",(0,i.kt)("inlineCode",{parentName:"li"},"NULL")," to automatically select a node."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"int timeoutMs"),": Timeout value in milliseconds to execute the call.\nIf the function execution takes longer than this value,\nthe execution will be canceled and an error returned.\nUse ",(0,i.kt)("inlineCode",{parentName:"li"},"0")," for no timeout."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("p",null,"Events"),(0,i.kt)("p",null,"When a message is received,\na ",(0,i.kt)("inlineCode",{parentName:"p"},'"message"')," event is emitted containing the message, pubsub topic,\nand node ID in which the message was received."),(0,i.kt)("p",null,"The ",(0,i.kt)("inlineCode",{parentName:"p"},"event")," type is ",(0,i.kt)("a",{parentName:"p",href:"#jsonmessageevent-type"},(0,i.kt)("inlineCode",{parentName:"a"},"JsonMessageEvent")),"."),(0,i.kt)("p",null,"For Example:"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-json"},'{\n "type": "message",\n "event": {\n "pubsubTopic": "/waku/2/default-waku/proto",\n "messageId": "0x6496491e40dbe0b6c3a2198c2426b16301688a2daebc4f57ad7706115eac3ad1",\n "wakuMessage": {\n "payload": "TODO",\n "contentTopic": "/my-app/1/notification/proto",\n "version": 1,\n "timestamp": 1647826358000000000\n }\n }\n}\n')),(0,i.kt)("h3",{id:"waku_legacy_filter_unsubscribe"},"waku_legacy_filter_unsubscribe"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_legacy_filter_unsubscribe(char* filterJSON, int timeoutMs, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Removes subscriptions in a light node matching a content filter and,\noptionally, a ",(0,i.kt)("a",{parentName:"p",href:"https://github.com/libp2p/specs/blob/master/pubsub/README.md#the-topic-descriptor"},"PubSub ",(0,i.kt)("inlineCode",{parentName:"a"},"topic")),"."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* filterJSON"),": JSON string containing the ",(0,i.kt)("a",{parentName:"li",href:"#filtersubscription-type"},(0,i.kt)("inlineCode",{parentName:"a"},"LegacyFilterSubscription")),"."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"int timeoutMs"),": Timeout value in milliseconds to execute the call.\nIf the function execution takes longer than this value,\nthe execution will be canceled and an error returned.\nUse ",(0,i.kt)("inlineCode",{parentName:"li"},"0")," for no timeout."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h2",{id:"waku-lightpush"},"Waku Lightpush"),(0,i.kt)("h3",{id:"waku_lightpush_publish"},"waku_lightpush_publish"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_lightpush_publish(char* messageJSON, char* topic, char* peerID, int timeoutMs, WakuCallBack onOkCb, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Publish a message using Waku Lightpush."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* messageJson"),":\nJSON string containing the ",(0,i.kt)("a",{parentName:"li",href:"../14/message"},"Waku Message")," as ",(0,i.kt)("a",{parentName:"li",href:"#jsonmessage-type"},(0,i.kt)("inlineCode",{parentName:"a"},"JsonMessage")),"."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* pubsubTopic"),": pubsub topic on which to publish the message.\nIf ",(0,i.kt)("inlineCode",{parentName:"li"},"NULL"),", it uses the default pubsub topic."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* peerID"),": Peer ID supporting the lightpush protocol.\nThe peer must be already known.\nIt must have been added before with ",(0,i.kt)("a",{parentName:"li",href:"#waku_add_peer"},(0,i.kt)("inlineCode",{parentName:"a"},"waku_add_peer")),"\nor previously dialed with ",(0,i.kt)("a",{parentName:"li",href:"#waku_connect"},(0,i.kt)("inlineCode",{parentName:"a"},"waku_connect_peer")),".\nUse ",(0,i.kt)("inlineCode",{parentName:"li"},"NULL")," to automatically select a node."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"int timeoutMs"),": Timeout value in milliseconds to execute the call.\nIf the function execution takes longer than this value,\nthe execution will be canceled and an error returned.\nUse ",(0,i.kt)("inlineCode",{parentName:"li"},"0")," for no timeout."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Note: ",(0,i.kt)("inlineCode",{parentName:"p"},"messageJson.version")," is overwritten to ",(0,i.kt)("inlineCode",{parentName:"p"},"0"),"."),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will receive the message ID"),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h2",{id:"waku-store"},"Waku Store"),(0,i.kt)("h3",{id:"waku_store_query"},"waku_store_query"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_store_query(char* queryJSON, char* peerID, int timeoutMs, WakuCallBack onOkCb, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Retrieves historical messages on specific content topics.\nThis method may be called with ",(0,i.kt)("a",{parentName:"p",href:"#pagingoptions-type"},(0,i.kt)("inlineCode",{parentName:"a"},"PagingOptions")),",\nto retrieve historical messages on a per-page basis.\nIf the request included ",(0,i.kt)("a",{parentName:"p",href:"#pagingoptions-type"},(0,i.kt)("inlineCode",{parentName:"a"},"PagingOptions")),", the node\nmust return messages on a per-page basis and\ninclude ",(0,i.kt)("a",{parentName:"p",href:"#pagingoptions-type"},(0,i.kt)("inlineCode",{parentName:"a"},"PagingOptions"))," in the response.\nThese ",(0,i.kt)("a",{parentName:"p",href:"#pagingoptions-type"},(0,i.kt)("inlineCode",{parentName:"a"},"PagingOptions")),"\nmust contain a cursor pointing to the Index from which a new page can be requested."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* queryJSON"),": JSON string containing the ",(0,i.kt)("a",{parentName:"li",href:"#storequery-type"},(0,i.kt)("inlineCode",{parentName:"a"},"StoreQuery")),"."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* peerID"),": Peer ID supporting the store protocol.\nThe peer must be already known.\nIt must have been added before with ",(0,i.kt)("a",{parentName:"li",href:"#waku_add_peer"},(0,i.kt)("inlineCode",{parentName:"a"},"waku_add_peer")),"\nor previously dialed with ",(0,i.kt)("a",{parentName:"li",href:"#waku_connect"},(0,i.kt)("inlineCode",{parentName:"a"},"waku_connect_peer")),"."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"int timeoutMs"),": Timeout value in milliseconds to execute the call.\nIf the function execution takes longer than this value,\nthe execution will be canceled and an error returned.\nUse ",(0,i.kt)("inlineCode",{parentName:"li"},"0")," for no timeout."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will receive a ",(0,i.kt)("a",{parentName:"li",href:"#storeresponse-type"},(0,i.kt)("inlineCode",{parentName:"a"},"StoreResponse")),"."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h3",{id:"waku_store_local_query"},"waku_store_local_query"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_store_local_query(char* queryJSON, WakuCallBack onOkCb, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Retrieves locally stored historical messages on specific content topics.\nThis method may be called with ",(0,i.kt)("a",{parentName:"p",href:"#pagingoptions-type"},(0,i.kt)("inlineCode",{parentName:"a"},"PagingOptions")),",\nto retrieve historical messages on a per-page basis.\nIf the request included ",(0,i.kt)("a",{parentName:"p",href:"#pagingoptions-type"},(0,i.kt)("inlineCode",{parentName:"a"},"PagingOptions")),", the node\nmust return messages on a per-page basis and\ninclude ",(0,i.kt)("a",{parentName:"p",href:"#pagingoptions-type"},(0,i.kt)("inlineCode",{parentName:"a"},"PagingOptions"))," in the response.\nThese ",(0,i.kt)("a",{parentName:"p",href:"#pagingoptions-type"},(0,i.kt)("inlineCode",{parentName:"a"},"PagingOptions")),"\nmust contain a cursor pointing to the Index from which a new page can be requested."),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* queryJSON"),": JSON string containing the ",(0,i.kt)("a",{parentName:"li",href:"#storequery-type"},(0,i.kt)("inlineCode",{parentName:"a"},"StoreQuery")),"."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"int timeoutMs"),": Timeout value in milliseconds to execute the call.\nIf the function execution takes longer than this value,\nthe execution will be canceled and an error returned.\nUse ",(0,i.kt)("inlineCode",{parentName:"li"},"0")," for no timeout."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly. ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will receive a ",(0,i.kt)("a",{parentName:"li",href:"#storeresponse-type"},(0,i.kt)("inlineCode",{parentName:"a"},"StoreResponse")),"."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h2",{id:"encrypting-messages"},"Encrypting messages"),(0,i.kt)("h3",{id:"waku_encode_symmetric"},"waku_encode_symmetric"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_encode_symmetric(char* messageJson, char* symmetricKey, char* optionalSigningKey, WakuCallBack onOkCb, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Encrypt a message using symmetric encryption and optionally sign the message"),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* messageJson"),":\nJSON string containing the ",(0,i.kt)("a",{parentName:"li",href:"../14/message"},"Waku Message")," as ",(0,i.kt)("a",{parentName:"li",href:"#jsonmessage-type"},(0,i.kt)("inlineCode",{parentName:"a"},"JsonMessage")),"."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* symmetricKey"),": hex encoded secret key to be used for encryption."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* optionalSigningKey"),": hex encoded private key to be used to sign the message."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Note: ",(0,i.kt)("inlineCode",{parentName:"p"},"messageJson.version")," is overwritten to ",(0,i.kt)("inlineCode",{parentName:"p"},"1"),"."),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will receive the encrypted waku message which can be broadcasted with relay\nor lightpush protocol publish functions."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h3",{id:"waku_encode_asymmetric"},"waku_encode_asymmetric"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_encode_asymmetric(char* messageJson, char* publicKey, char* optionalSigningKey, WakuCallBack onOkCb, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Encrypt a message using asymmetric encryption and optionally sign the message"),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* messageJson"),":\nJSON string containing the ",(0,i.kt)("a",{parentName:"li",href:"../14/message"},"Waku Message")," as ",(0,i.kt)("a",{parentName:"li",href:"#jsonmessage-type"},(0,i.kt)("inlineCode",{parentName:"a"},"JsonMessage")),"."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* publicKey"),": hex encoded public key to be used for encryption."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* optionalSigningKey"),": hex encoded private key to be used to sign the message."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Note: ",(0,i.kt)("inlineCode",{parentName:"p"},"messageJson.version")," is overwritten to ",(0,i.kt)("inlineCode",{parentName:"p"},"1"),"."),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will receive the encrypted waku message which can be broadcasted with relay\nor lightpush protocol publish functions."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h2",{id:"decrypting-messages"},"Decrypting messages"),(0,i.kt)("h3",{id:"waku_decode_symmetric"},"waku_decode_symmetric"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_decode_symmetric(char* messageJson, char* symmetricKey, WakuCallBack onOkCb, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Decrypt a message using a symmetric key"),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* messageJson"),":\nJSON string containing the ",(0,i.kt)("a",{parentName:"li",href:"../14/message"},"Waku Message")," as ",(0,i.kt)("a",{parentName:"li",href:"#jsonmessage-type"},(0,i.kt)("inlineCode",{parentName:"a"},"JsonMessage")),"."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* symmetricKey"),": 32 byte symmetric key hex encoded."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Note: ",(0,i.kt)("inlineCode",{parentName:"p"},"messageJson.version")," is expected to be ",(0,i.kt)("inlineCode",{parentName:"p"},"1"),"."),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will receive the decoded payload as a ",(0,i.kt)("a",{parentName:"li",href:"#decodedpayload-type"},(0,i.kt)("inlineCode",{parentName:"a"},"DecodedPayload")),".")),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-json"},'{\n "pubkey": "0x......",\n "signature": "0x....",\n "data": "...",\n "padding": "..."\n}\n')),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h3",{id:"waku_decode_asymmetric"},"waku_decode_asymmetric"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_decode_asymmetric(char* messageJson, char* privateKey, WakuCallBack onOkCb, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Decrypt a message using a secp256k1 private key"),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* messageJson"),":\nJSON string containing the ",(0,i.kt)("a",{parentName:"li",href:"../14/message"},"Waku Message")," as ",(0,i.kt)("a",{parentName:"li",href:"#jsonmessage-type"},(0,i.kt)("inlineCode",{parentName:"a"},"JsonMessage")),"."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* privateKey"),": secp256k1 private key hex encoded."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Note: ",(0,i.kt)("inlineCode",{parentName:"p"},"messageJson.version")," is expected to be ",(0,i.kt)("inlineCode",{parentName:"p"},"1"),"."),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will receive the decoded payload as a ",(0,i.kt)("a",{parentName:"li",href:"#decodedpayload-type"},(0,i.kt)("inlineCode",{parentName:"a"},"DecodedPayload")),".")),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-json"},'{\n "pubkey": "0x......",\n "signature": "0x....",\n "data": "...",\n "padding": "..."\n}\n')),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h2",{id:"dns-discovery"},"DNS Discovery"),(0,i.kt)("h3",{id:"waku_dns_discovery"},"waku_dns_discovery"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_dns_discovery(char* url, char* nameserver, int timeoutMs, WakuCallBack onOkCb, WakuCallBack onErrCb){}\n")),(0,i.kt)("p",null,"Returns a list of multiaddress and enrs given a url to a DNS discoverable ENR tree"),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* url"),": URL containing a discoverable ENR tree"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* nameserver"),": The nameserver to resolve the ENR tree url.\nIf ",(0,i.kt)("inlineCode",{parentName:"li"},"NULL")," or empty, it will automatically use the default system dns."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"int timeoutMs"),": Timeout value in milliseconds to execute the call.\nIf the function execution takes longer than this value,\nthe execution will be canceled and an error returned.\nUse ",(0,i.kt)("inlineCode",{parentName:"li"},"0")," for no timeout."),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onOkCb"),": callback to be executed if the function is succesful"),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," will receive an array objects describing the multiaddresses,\nenr and peerID each node found.")),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-json"},'[\n {\n "peerID":"16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ",\n "multiaddrs":[\n "/ip4/134.209.139.210/tcp/30303/p2p/16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ",\n "/dns4/node-01.do-ams3.wakuv2.test.statusim.net/tcp/8000/wss/p2p/16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ"\n ],\n "enr":"enr:-M-4QCtJKX2WDloRYDT4yjeMGKUCRRcMlsNiZP3cnPO0HZn6IdJ035RPCqsQ5NvTyjqHzKnTM6pc2LoKliV4CeV0WrgBgmlkgnY0gmlwhIbRi9KKbXVsdGlhZGRyc7EALzYobm9kZS0wMS5kby1hbXMzLndha3V2Mi50ZXN0LnN0YXR1c2ltLm5ldAYfQN4DiXNlY3AyNTZrMaEDnr03Tuo77930a7sYLikftxnuG3BbC3gCFhA4632ooDaDdGNwgnZfg3VkcIIjKIV3YWt1Mg8"\n },\n ...\n]\n')),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onOkCb")," or ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h2",{id:"discoveryv5"},"DiscoveryV5"),(0,i.kt)("h3",{id:"waku_discv5_update_bootnodes"},"waku_discv5_update_bootnodes"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre",className:"language-c"},"extern int waku_discv5_update_bootnodes(char* bootnodes, WakuCallBack onErrCb)`\n")),(0,i.kt)("p",null,"Update the bootnode list used for discovering new peers via DiscoveryV5"),(0,i.kt)("p",null,"Parameters"),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"char* bootnodes"),": JSON array containing the bootnode ENRs i.e. ",(0,i.kt)("inlineCode",{parentName:"li"},'["enr:...", "enr:..."]')),(0,i.kt)("li",{parentName:"ol"},(0,i.kt)("inlineCode",{parentName:"li"},"WakuCallBack onErrCb"),": callback to be executed if the function fails")),(0,i.kt)("p",null,"Returns"),(0,i.kt)("p",null,(0,i.kt)("inlineCode",{parentName:"p"},"int")," with a status code. Possible values:"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},"0 - The operation was completed successfuly."),(0,i.kt)("li",{parentName:"ul"},"1 - The operation failed for any reason.\n",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," will be executed with the reason the function execution failed."),(0,i.kt)("li",{parentName:"ul"},"2 - The function is missing the ",(0,i.kt)("inlineCode",{parentName:"li"},"onErrCb")," callback")),(0,i.kt)("h2",{id:"copyright"},"Copyright"),(0,i.kt)("p",null,"Copyright and related rights waived via\n",(0,i.kt)("a",{parentName:"p",href:"https://creativecommons.org/publicdomain/zero/1.0/"},"CC0"),"."))}k.isMDXComponent=!0},3905:(e,n,t)=>{t.d(n,{Zo:()=>p,kt:()=>d});var a=t(67294);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function l(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function r(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?l(Object(t),!0).forEach((function(n){i(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):l(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function o(e,n){if(null==e)return{};var t,a,i=function(e,n){if(null==e)return{};var t,a,i={},l=Object.keys(e);for(a=0;a<l.length;a++)t=l[a],n.indexOf(t)>=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)t=l[a],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}var s=a.createContext({}),u=function(e){var n=a.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):r(r({},n),e)),t},p=function(e){var n=u(e.components);return a.createElement(s.Provider,{value:n},e.children)},k={inlineCode:"code",wrapper:function(e){var n=e.children;return a.createElement(a.Fragment,{},n)}},c=a.forwardRef((function(e,n){var t=e.components,i=e.mdxType,l=e.originalType,s=e.parentName,p=o(e,["components","mdxType","originalType","parentName"]),c=u(t),d=i,m=c["".concat(s,".").concat(d)]||c[d]||k[d]||l;return t?a.createElement(m,r(r({ref:n},p),{},{components:t})):a.createElement(m,r({ref:n},p))}));function d(e,n){var t=arguments,i=n&&n.mdxType;if("string"==typeof e||i){var l=t.length,r=new Array(l);r[0]=c;var o={};for(var s in n)hasOwnProperty.call(n,s)&&(o[s]=n[s]);o.originalType=e,o.mdxType="string"==typeof e?e:i,r[1]=o;for(var u=2;u<l;u++)r[u]=t[u];return a.createElement.apply(null,r)}return a.createElement.apply(null,t)}c.displayName="MDXCreateElement"}}]);