diff --git a/cmd/getndf.go b/cmd/getndf.go index 4a214538572a559ac614d31fae63cb386a4fe691..8a107960597d96e163e2d5d0963b3c6291e51113 100644 --- a/cmd/getndf.go +++ b/cmd/getndf.go @@ -101,12 +101,11 @@ var getNDFCmd = &cobra.Command{ // Gateway lookup if gwHost != "" { - resp, err := xxdk.DownloadNdfFromGateway(gwHost, cert) - fmt.Printf("%s", resp.PartialNDF.Ndf) + ndfJSon, err := xxdk.DownloadNdfFromGateway(gwHost, cert) if err != nil { jww.FATAL.Panicf("%v", err) } - fmt.Printf("%s", resp.PartialNDF.Ndf) + fmt.Printf("%s", ndfJSon) return } diff --git a/xxdk/ndf.go b/xxdk/ndf.go index 861fea406db35ca272a2dcb66e9a54f7fae0313d..a5e2ae703430283aa0dd007b7d5df648683daefb 100644 --- a/xxdk/ndf.go +++ b/xxdk/ndf.go @@ -26,10 +26,9 @@ import ( // DownloadNdfFromGateway will download an NDF from a gateway on the cMix network. // It will take the given address and certificate and send a request to a gateway // for an NDF over HTTP/2 using the xx network's gRPC implementation. -// This returns a gRPC protobuf message which contains the NDF in the -// PartialNDF field of the pb.GatewayPollResponse. +// This returns a JSON marshalled version of the NDF. func DownloadNdfFromGateway(address string, cert []byte) ( - *pb.GatewayPollResponse, error) { + []byte, error) { // Establish parameters for gRPC params := connect.GetDefaultHostParams() params.AuthEnabled = false @@ -60,7 +59,12 @@ func DownloadNdfFromGateway(address string, cert []byte) ( } // Send poll request and receive response containing NDF - return comms.SendPoll(host, pollMsg) + resp, err := comms.SendPoll(host, pollMsg) + if err != nil { + return nil, err + } + + return resp.PartialNDF.Ndf, nil } // DownloadAndVerifySignedNdfWithUrl retrieves the NDF from a specified URL.