         (.setChannelId channel-id)
         (.setTxId tx-id)
         (.setEpoch epoch)
-        (.setExtension (.toByteString ^ProposalPackage$ChaincodeHeaderExtension
-                                      (clj->proto extension)))
+        (.setExtension (with-default-empty-byte-string [extension]
+                         (.toByteString ^ProposalPackage$ChaincodeHeaderExtension
+                                        (clj->proto extension))))
         (.build))))
 
 (defn make-channel-header
   [& {:keys [type version timestamp channel-id tx-id epoch extension]
-      :or {type :endorser-transaction version 1 extension ByteString/EMPTY
-           timestamp (System/currentTimeMillis) epoch 0}}]
+      :or {type :endorser-transaction version 1 timestamp (System/currentTimeMillis) epoch 0}}]
   (map->ChannelHeader {:type type :version version :timestamp timestamp :epoch epoch
                        :channel-id channel-id :tx-id tx-id :extension extension}))
 

    (-> (Chaincode$ChaincodeDeploymentSpec/newBuilder)
        (.setChaincodeSpec ^Chaincode$ChaincodeSpec (clj->proto chaincode-spec))
        (.setEffectiveDate ^Timestamp (clj->proto (make-timestamp effective-date)))
        (.setCodePackage (ByteString/copyFrom code-package))
        (.setExecEnv (exec-env-map exec-env))
        (.build))))


           ))

;;;
;;; Macros
(defmacro with-default-empty-byte-string [[arg] & body]
  `(if (nil? ~arg)
     ByteString/EMPTY
     ~@body))

;;;
;;;
(defprotocol ICljToProto
  (clj->proto [this]))
