INNER CODE UNIT · Go
toBinary
wavesplatform/gowaves · cmd/convert/main.go:118
func toBinary(tx proto.Transaction, cfg config) error {
bts, err := proto.MarshalTx(cfg.scheme, tx)
if err != nil {
return fmt.Errorf("failed to serialize transaction: %w", err)
}
var w = cfg.out
if cfg.base64 {
w = base64.NewEncoder(base64.StdEncoding, cfg.out)
defer func(w io.Closer) {
if clErr := w.Close(); clErr != nil {
log.Printf("failed to close Base64 encoder: %v", clErr)
}
}(w)
}
if _, wErr := w.Write(bts); wErr != nil {
return fmt.Errorf("failed to write transaction: %w", wErr)
}
return nil